From: Nick Porter Date: Fri, 23 Feb 2024 09:42:30 +0000 (+0000) Subject: Add basic rlm_radutmp test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44cc2686875d747c7a93340ef8ba22b7c4ba5e9e;p=thirdparty%2Ffreeradius-server.git Add basic rlm_radutmp test --- diff --git a/src/tests/modules/radutmp/all.mk b/src/tests/modules/radutmp/all.mk new file mode 100644 index 00000000000..03c386cfabd --- /dev/null +++ b/src/tests/modules/radutmp/all.mk @@ -0,0 +1,3 @@ +# +# Test the radutmp module +# diff --git a/src/tests/modules/radutmp/module.conf b/src/tests/modules/radutmp/module.conf new file mode 100644 index 00000000000..caeaba4dc45 --- /dev/null +++ b/src/tests/modules/radutmp/module.conf @@ -0,0 +1,13 @@ +radutmp { + filename = $ENV{MODULE_TEST_DIR}radutmp + username = %{User-Name} + caller_id = yes +} + +exec { + wait = yes + shell_escape = yes + timeout = 1 + output_pairs = &control + program = "./build/bin/local/radwho -D share/dictionary -F $ENV{MODULE_TEST_DIR}/radutmp -u %{User-Name} -c -R" +} diff --git a/src/tests/modules/radutmp/test.attrs b/src/tests/modules/radutmp/test.attrs new file mode 100644 index 00000000000..9975efe7ab2 --- /dev/null +++ b/src/tests/modules/radutmp/test.attrs @@ -0,0 +1,33 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = 'user0@example.org' +NAS-Port = 17826193 +NAS-IP-Address = 192.0.2.10 +Calling-Station-Id = 00-11-22-33-44-55 +Framed-IP-Address = 198.51.100.59 +Acct-Status-Type = Start +Acct-Delay-Time = 1 +Acct-Input-Octets = 0 +Acct-Output-Octets = 0 +Acct-Session-Id = '00000001' +Acct-Session-Time = 0 +Acct-Input-Packets = 0 +Acct-Output-Packets = 0 +Acct-Input-Gigawords = 0 +Acct-Output-Gigawords = 0 +Event-Timestamp = 'Feb 1 2024 08:28:58 GMT' +NAS-Port-Type = Ethernet +NAS-Port-Id = 'port 001' +Service-Type = Framed-User +Framed-Protocol = PPP +Idle-Timeout = 0 +Session-Timeout = 604800 + +# +# Expected answer +# +# There's not an Accounting-Failed packet type in RADIUS... +# +Packet-Type == Access-Accept diff --git a/src/tests/modules/radutmp/test.unlang b/src/tests/modules/radutmp/test.unlang new file mode 100644 index 00000000000..0a81f3d5ccf --- /dev/null +++ b/src/tests/modules/radutmp/test.unlang @@ -0,0 +1,68 @@ +# +# Remove any historic radutmp file +# +%file.rm("$ENV{MODULE_TEST_DIR}/radutmp") + +# +# Call the module in accounting context to record the user's session +# +radutmp.accounting + +if (!ok) { + test_fail +} + +# +# Runs radwho to read back stored data as pairs into &control +# +exec + +if !(&NAS-Port == &control.NAS-Port) { + test_fail +} + +# +# Use an Interim-Update and different Framed-IP-Address to check record update +# +&Framed-IP-Address := 10.0.10.100 +&Acct-Status-Type := Interim-Update + +radutmp.accounting + +if (!ok) { + test_fail +} + +&control := {} + +exec + +if !(&Framed-IP-Address == &control.Framed-IP-Address) { + test_fail +} + +# +# Now use a Stop to clear the user's session +# +&Acct-Status-Type := Stop + +radutmp.accounting + +if (!ok) { + test_fail +} + +&control := {} + +exec + +if (&control.NAS-Port) { + test_fail +} + +# +# Tidy up +# +%file.rm("$ENV{MODULE_TEST_DIR}/radutmp") + +test_pass