diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
commit | af754e596a8dbb05ed8580c342e7fe02e08b28e0 (patch) | |
tree | b2f334c2b55ede42081aa6710a72da784547d8ea /src/tests/modules/rest/rest_module.unlang | |
parent | Initial commit. (diff) | |
download | freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.tar.xz freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.zip |
Adding upstream version 3.2.3+dfsg.upstream/3.2.3+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tests/modules/rest/rest_module.unlang')
-rw-r--r-- | src/tests/modules/rest/rest_module.unlang | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/tests/modules/rest/rest_module.unlang b/src/tests/modules/rest/rest_module.unlang new file mode 100644 index 0000000..c78c380 --- /dev/null +++ b/src/tests/modules/rest/rest_module.unlang @@ -0,0 +1,111 @@ +# Pre-set Tmp-String-2 to check correct operator behaviour +update { + &control:Tmp-String-2 := "foo" +} + +# Test "authorize" rest call. Uses http to a GET end point +rest + +debug_control + +if (!(&reply:REST-HTTP-Status-Code == 200)) { + test_fail +} + +if (!(&control:Tmp-String-0 == "authorize")) { + test_fail +} + +if (!(&control:Tmp-String-1 == "GET")) { + test_fail +} + +if (!(&control:Tmp-String-1[*] == "/user/<username>/mac/<client>")) { + test_fail +} + +if (!(&control:User-Name == "Bob")) { + test_fail +} + +# The "op" for setting Tmp-String-2 is ^= +if (!(&control:Tmp-String-2[0] == "Bob") || !(&control:Tmp-String-2[1] == "foo")) { + test_fail +} + +# Reset control attributes +update control { + &Tmp-String-0[*] !* ANY + &Tmp-String-1[*] !* ANY + &User-Name[*] !* ANY +} + +# Pre-fill NAS-IP-Address to check operator behaviour +update { + &control:NAS-IP-Address := "10.0.0.10" +} + +# Clear previous status code and body +update reply { + &REST-HTTP-Status-Code !* ANY + &REST-HTTP-Body !* ANY +} + +# Test "accounting" rest call. Uses https to a POST end point +rest.accounting + +if (!(&reply:REST-HTTP-Status-Code == 200)) { + test_fail +} + +if (!(&control:Tmp-String-0 == "accounting")) { + test_fail +} + +if (!(&control:Tmp-String-1 == "POST")) { + test_fail +} + +if (!(&control:Tmp-String-1[*] == "/user/<username>/mac/<client>")) { + test_fail +} + +if (!(&control:User-Name == "Bob")) { + test_fail +} + +if (!(&control:Tmp-String-2[0] == "Bob") || !(&control:Tmp-String-2[1] == "Bob") || !(&control:Tmp-String-2[2] == "foo")) { + test_fail +} + +# NAS IP Address is passed in body data +if (!(&control:NAS-IP-Address[0] == "10.0.0.10") || !(&control:NAS-IP-Address[1] == "192.168.1.1")) { + test_fail +} + +debug_control + +# Clear previous status code and body +update reply { + &REST-HTTP-Status-Code !* ANY + &REST-HTTP-Body !* ANY +} + +# Test "authenticate" rest call. Uses http basic authentication +rest.authenticate + +if (!(&reply:REST-HTTP-Status-Code == 200)) { + test_fail +} + +if (!(&reply:REST-HTTP-Body == "Section: authenticate, User: Bob, Authenticated: true\n")) { + test_fail +} + +# Clear up reply +update reply { + &REST-HTTP-Status-Code !* ANY + &REST-HTTP-Body !* ANY +} + +test_pass |