Add a test

This commit is contained in:
Alexey Milovidov 2024-02-25 23:54:55 +01:00
parent 9f4041e3f7
commit b916479025
5 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1 @@
../../../tests/config/config.d/handlers.yaml

View File

@ -0,0 +1,8 @@
http_handlers:
rule:
url: '/upyachka'
empty_query_string:
handler:
type: redirect
location: "/?query=SELECT+'Pepyaka'"
defaults:

View File

@ -66,6 +66,7 @@ ln -sf $SRC_PATH/config.d/filesystem_caches_path.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/validate_tcp_client_information.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/zero_copy_destructive_operations.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/block_number.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/handlers.yaml $DEST_SERVER_PATH/config.d/
# Not supported with fasttest.
if [ "${DEST_SERVER_PATH}" = "/etc/clickhouse-server" ]

View File

@ -0,0 +1,5 @@
Ok.
HTTP/1.1 302 Found
Location: /?query=SELECT+'Pepyaka'
HTTP/1.1 404 Not Found
Pepyaka

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
URL="${CLICKHOUSE_PORT_HTTP_PROTO}://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT_HTTP}"
# Ping handler
${CLICKHOUSE_CURL} -s -S "${URL}/"
# A handler that is configured to return a redirect
${CLICKHOUSE_CURL} -s -S -I "${URL}/upyachka" | grep -i -P '^HTTP|Location'
# This handler is configured to not accept any query string
${CLICKHOUSE_CURL} -s -S -I "${URL}/upyachka?hello=world" | grep -i -P '^HTTP|Location'
# Check that actual redirect works
${CLICKHOUSE_CURL} -s -S -L "${URL}/upyachka"