]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add rlm_rest cancellation test
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 2 Apr 2024 15:52:09 +0000 (10:52 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 2 Apr 2024 16:08:25 +0000 (11:08 -0500)
scripts/ci/openresty-setup.sh
src/tests/modules/rest/module.conf
src/tests/modules/rest/rest_timeout.unlang [new file with mode: 0644]

index ae05cddd75afccff627cd350fdf80ca8c53ed770..9b7747828f142006ffd4a7db3853ae7ebec4eddc 100755 (executable)
@@ -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;
        }
index 0813cf9d010cc429774b151e7e1234cf8c118577..e5113f68bb6d711c4f379ce4819b368c622573a2 100644 (file)
@@ -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 (file)
index 0000000..c6f02e1
--- /dev/null
@@ -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