From: Nick Porter Date: Mon, 26 Feb 2024 17:16:58 +0000 (+0000) Subject: Add basic tests of rlm_detail X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06fe43017a53b9a334e2d8c7f3e2d408fa2b547c;p=thirdparty%2Ffreeradius-server.git Add basic tests of rlm_detail --- diff --git a/src/tests/modules/detail/all.mk b/src/tests/modules/detail/all.mk new file mode 100644 index 00000000000..64e7964b280 --- /dev/null +++ b/src/tests/modules/detail/all.mk @@ -0,0 +1,3 @@ +# +# Test the "detail" module +# diff --git a/src/tests/modules/detail/escape.attrs b/src/tests/modules/detail/escape.attrs new file mode 100644 index 00000000000..25669779954 --- /dev/null +++ b/src/tests/modules/detail/escape.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "bob" +User-Password = "hello" +Calling-Station-Id = "with-nön-ascii!" + +# +# Expected answer +# +Packet-Type == Access-Accept diff --git a/src/tests/modules/detail/escape.unlang b/src/tests/modules/detail/escape.unlang new file mode 100644 index 00000000000..7a19c82c02a --- /dev/null +++ b/src/tests/modules/detail/escape.unlang @@ -0,0 +1,13 @@ +%file.rm("$ENV{MODULE_TEST_DIR}/127-2e0-2e0-2e1-with--n-c3-b6n--ascii-21") + +&request -= &Module-Failure-Message[*] + +detail_escape + +if !%file.exists("$ENV{MODULE_TEST_DIR}/127-2e0-2e0-2e1-with--n-c3-b6n--ascii-21") { + test_fail +} + +%file.rm("$ENV{MODULE_TEST_DIR}/127-2e0-2e0-2e1-with--n-c3-b6n--ascii-21") + +test_pass diff --git a/src/tests/modules/detail/module.conf b/src/tests/modules/detail/module.conf new file mode 100644 index 00000000000..1154d18f7c6 --- /dev/null +++ b/src/tests/modules/detail/module.conf @@ -0,0 +1,33 @@ +detail { + filename = "$ENV{MODULE_TEST_DIR}/%{Net.Src.IP}-detail" + header = "%t" + + suppress { + + } +} + +# +# Instance of detail with suppressed attributes +# +detail detail_suppress { + filename = "$ENV{MODULE_TEST_DIR}/%{Net.Src.IP}-suppress" + header = "%t" + suppress { + Calling-Station-Id + Called-Station-Id + Calling-Station-Id # repeated deliberately - will produce warning in debug + NAS-Identifier + } +} + +# +# Instance of detail where attributes are escaped in the file name +# +detail detail_escape { + filename = "$ENV{MODULE_TEST_DIR}/%{Net.Src.IP}-%{Calling-Station-Id}" + escape_filenames = yes +} + +exec { +} diff --git a/src/tests/modules/detail/simple.attrs b/src/tests/modules/detail/simple.attrs new file mode 100644 index 00000000000..e904cab480d --- /dev/null +++ b/src/tests/modules/detail/simple.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "bob" +User-Password = "hello" +Calling-Station-Id = aa-bb-cc-dd-ee-ff + +# +# Expected answer +# +Packet-Type == Access-Accept diff --git a/src/tests/modules/detail/simple.unlang b/src/tests/modules/detail/simple.unlang new file mode 100644 index 00000000000..b1b0aa20ecc --- /dev/null +++ b/src/tests/modules/detail/simple.unlang @@ -0,0 +1,17 @@ +%file.rm("$ENV{MODULE_TEST_DIR}/127.0.0.1-detail") + +&request -= &Module-Failure-Message[*] + +detail + +if !%file.exists("$ENV{MODULE_TEST_DIR}/127.0.0.1-detail") { + test_fail +} + +if !%exec('/bin/sh', '-c', "grep -E Calling-Station-Id $ENV{MODULE_TEST_DIR}/127.0.0.1-detail") { + test_fail +} + +%file.rm("$ENV{MODULE_TEST_DIR}/127.0.0.1-detail") + +test_pass diff --git a/src/tests/modules/detail/suppress.attrs b/src/tests/modules/detail/suppress.attrs new file mode 100644 index 00000000000..e904cab480d --- /dev/null +++ b/src/tests/modules/detail/suppress.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "bob" +User-Password = "hello" +Calling-Station-Id = aa-bb-cc-dd-ee-ff + +# +# Expected answer +# +Packet-Type == Access-Accept diff --git a/src/tests/modules/detail/suppress.unlang b/src/tests/modules/detail/suppress.unlang new file mode 100644 index 00000000000..935b9f1a498 --- /dev/null +++ b/src/tests/modules/detail/suppress.unlang @@ -0,0 +1,20 @@ +%file.rm("$ENV{MODULE_TEST_DIR}/127.0.0.1-suppress") + +&request -= &Module-Failure-Message[*] + +detail_suppress + +if !%file.exists("$ENV{MODULE_TEST_DIR}/127.0.0.1-suppress") { + test_fail +} + +# +# Calling-Station-Id should not be in the output +# +if %exec('/bin/sh', '-c', "grep -E Calling-Station-Id $ENV{MODULE_TEST_DIR}/127.0.0.1-suppress") { + test_fail +} + +%file.rm("$ENV{MODULE_TEST_DIR}/127.0.0.1-suppress") + +test_pass