From: Arran Cudbard-Bell Date: Tue, 2 Apr 2024 15:52:09 +0000 (-0500) Subject: Add rlm_rest cancellation test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=270f28874bcc22d185fdf37e33f041edb4d0ddd3;p=thirdparty%2Ffreeradius-server.git Add rlm_rest cancellation test --- diff --git a/scripts/ci/openresty-setup.sh b/scripts/ci/openresty-setup.sh index ae05cddd75a..9b7747828f1 100755 --- a/scripts/ci/openresty-setup.sh +++ b/scripts/ci/openresty-setup.sh @@ -28,7 +28,7 @@ PASSWORD="whatever" CONF="${BUILDDIR}/nginx.conf" # Find the mime.types file -MIME_TYPES_LOCATIONS="/usr/local/openresty/nginx/conf/mime.types /opt/homebrew/etc/openresty/mime.types /usr/local/etc/nginx/mime.types /etc/nginx/mime.types" +MIME_TYPES_LOCATIONS="/usr/local/etc/openresty/mime.types /opt/homebrew/etc/openresty/mime.types /usr/local/etc/nginx/mime.types /etc/nginx/mime.types" for i in ${MIME_TYPES_LOCATIONS}; do if [ -e "${i}" ]; then MIME_TYPES="${i}" @@ -126,6 +126,15 @@ http { content_by_lua_file ${APIDIR}/json-api.lua; } + location ~ ^/delay/([0-9]*)$ { + default_type 'application/json'; + add_header 'Content-Type' 'application/json'; + content_by_lua_block { + ngx.sleep(tonumber(ngx.var[1])) + ngx.say('{\"delay_us\":' .. ngx.ctx.openresty_request_time_us .. '}') + } + } + location ~ ^/post(.*)$ { content_by_lua_file ${APIDIR}/post-api.lua; } diff --git a/src/tests/modules/rest/module.conf b/src/tests/modules/rest/module.conf index 0813cf9d010..e5113f68bb6 100644 --- a/src/tests/modules/rest/module.conf +++ b/src/tests/modules/rest/module.conf @@ -69,3 +69,14 @@ rest restshorttimeout { timeout = 0.5 } } + +rest rest_delay { + connect_uri = "http://$ENV{REST_TEST_SERVER}:$ENV{REST_TEST_SERVER_PORT}/" + authorize { + request { + uri = "${...connect_uri}/delay/1" + method = "GET" + } + tls = ${...rest.tls} + } +} diff --git a/src/tests/modules/rest/rest_timeout.unlang b/src/tests/modules/rest/rest_timeout.unlang new file mode 100644 index 00000000000..c6f02e196fa --- /dev/null +++ b/src/tests/modules/rest/rest_timeout.unlang @@ -0,0 +1,17 @@ +# Pre-set Login-LAT-Node to check correct operator behaviour +&control.Login-LAT-Node := "foo" + +# Test "authorize" rest call. Uses http to a GET end point + +redundant { + timeout 0.1s { + rest_delay + } + ok +} + +if (&REST-HTTP-Status-Code) { + test_fail +} + +test_pass