From: Nick Porter Date: Wed, 15 Feb 2023 10:41:13 +0000 (+0000) Subject: Add test of rest response timeout X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2be17be0f31f3df5364e2ae78efc44d72271c5d;p=thirdparty%2Ffreeradius-server.git Add test of rest response timeout --- diff --git a/scripts/ci/openresty-setup.sh b/scripts/ci/openresty-setup.sh index 6a73ac9df2d..44cc28b0613 100755 --- a/scripts/ci/openresty-setup.sh +++ b/scripts/ci/openresty-setup.sh @@ -83,6 +83,10 @@ http { location ~ ^/post(.*)$ { content_by_lua_file ${APIDIR}/post-api.lua; } + + location ~ ^/delay(.*)$ { + content_by_lua_file ${APIDIR}/delay-api.lua; + } } server { diff --git a/scripts/ci/openresty/delay-api.lua b/scripts/ci/openresty/delay-api.lua new file mode 100644 index 00000000000..aa4f61b99e9 --- /dev/null +++ b/scripts/ci/openresty/delay-api.lua @@ -0,0 +1,6 @@ +-- Simple API represending a slow response for testing timeouts + +local t0 = os.clock() +while os.clock() - t0 <= 2 do end + +ngx.say("Delayed response") diff --git a/src/tests/modules/rest/module.conf b/src/tests/modules/rest/module.conf index b3d3580e322..08467681877 100644 --- a/src/tests/modules/rest/module.conf +++ b/src/tests/modules/rest/module.conf @@ -23,6 +23,7 @@ rest { xlat { tls = ${..tls} + timeout = 0.5 } authorize { diff --git a/src/tests/modules/rest/rest_xlat.unlang b/src/tests/modules/rest/rest_xlat.unlang index 7629791ee6d..f2aaaee870e 100644 --- a/src/tests/modules/rest/rest_xlat.unlang +++ b/src/tests/modules/rest/rest_xlat.unlang @@ -133,4 +133,15 @@ if (!(&Tmp-String-2 == "{\"station\":\"aa:bb:cc:dd:ee:ff\"}\n" )) { test_fail } +# Test against endpoint which will time out +&Tmp-String-2 := "%(rest:http://%{Tmp-String-0}:%{Tmp-Integer-0}/delay)" + +if (&REST-HTTP-Status-Code) { + test_fail +} + +if (!(&Module-Failure-Message == "curl request failed: Timeout was reached (28)")) { + test_fail +} + test_pass