From: Nick Porter Date: Fri, 5 Jan 2024 16:48:24 +0000 (+0000) Subject: Remove Tmp- attributes from linelog module tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4acc019c1b64fee443906350ce735408e448c556;p=thirdparty%2Ffreeradius-server.git Remove Tmp- attributes from linelog module tests --- diff --git a/src/tests/modules/linelog/linelog-delim.unlang b/src/tests/modules/linelog/linelog-delim.unlang index de280f46d32..a0b74b06e1f 100644 --- a/src/tests/modules/linelog/linelog-delim.unlang +++ b/src/tests/modules/linelog/linelog-delim.unlang @@ -1,3 +1,5 @@ +string test_string + &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"' # @@ -6,9 +8,9 @@ %file.rm("$ENV{MODULE_TEST_DIR}/test_delim.log") linelog_fmt_delim -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_delim.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_delim.log") -if (&Tmp-String-0 == 'bob, ') { +if (&test_string == 'bob, ') { test_pass } else { @@ -17,9 +19,9 @@ else { # Check strings are appended linelog_fmt_delim -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_delim.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_delim.log") -if (&Tmp-String-0 == 'bob, bob, ') { +if (&test_string == 'bob, bob, ') { test_pass } else { diff --git a/src/tests/modules/linelog/linelog-escapes.unlang b/src/tests/modules/linelog/linelog-escapes.unlang index c9946e0ff7b..6f5fd5b3fa0 100644 --- a/src/tests/modules/linelog/linelog-escapes.unlang +++ b/src/tests/modules/linelog/linelog-escapes.unlang @@ -1,3 +1,6 @@ +string test_string1 +string test_string2 + &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"' # @@ -7,30 +10,30 @@ # Raw attribute value should be written out without further molestation. # Because the value is wrapped in '' the \n is left as \n. -&control.Tmp-String-0 := 'test_attr' -&control.Tmp-String-1 := 'foo\nbar' +&control.Filter-Id := 'test_attr' +&control.Callback-Id := 'foo\nbar' linelog_escapes -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") -&Tmp-String-1 := "%hex(%{Tmp-String-0})" +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") +&test_string2 := "%hex(%{test_string1})" # # Note that there's a '5f6e' here, which is "\n" # And we don't have a '0a', which is the unescaped "\n" # -if (&Tmp-String-1 == '666f6f5c6e626172') { +if (&test_string2 == '666f6f5c6e626172') { test_pass } else { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") # # This is left alone, and not "\n" --> 0x0a, too. # -if (&Tmp-String-0 == 'foo\nbar') { +if (&test_string1 == 'foo\nbar') { test_pass } else { @@ -39,23 +42,23 @@ else { # Raw attribute value should be written out without further molestation. # Because the value is wrapped in "" the \n is converted to 0x0a (binary). -&control.Tmp-String-0 := 'test_attr' -&control.Tmp-String-1 := "foo\nbar" +&control.Filter-Id := 'test_attr' +&control.Callback-Id := "foo\nbar" linelog_escapes -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log", 2) -&Tmp-String-1 := "%hex(%{Tmp-String-0})" +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log", 2) +&test_string2 := "%hex(%{test_string1})" -if (&Tmp-String-1 == '666f6f0a626172') { +if (&test_string2 == '666f6f0a626172') { test_pass } else { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_escapes.log") -if (&Tmp-String-0 == "bar") { +if (&test_string1 == "bar") { test_pass } else { diff --git a/src/tests/modules/linelog/linelog-multi.unlang b/src/tests/modules/linelog/linelog-multi.unlang index f8f9e2227f3..73bbc8604ca 100644 --- a/src/tests/modules/linelog/linelog-multi.unlang +++ b/src/tests/modules/linelog/linelog-multi.unlang @@ -1,3 +1,5 @@ +string test_string + &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"' # @@ -6,7 +8,7 @@ %file.rm("$ENV{MODULE_TEST_DIR}/test_multi.log") # Check multiple string type attributes are logged correctly -&control.Tmp-String-0 := 'test_multi_str' +&control.Filter-Id := 'test_multi_str' &control += { &Reply-Message = '0' @@ -23,45 +25,38 @@ } linelog_ref_multi -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_multi.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_multi.log") -if (&Tmp-String-0 == '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ') { - test_pass -} -else { +if !(&test_string == '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ') { test_fail } # Check octet type attributes are logged in raw form &control += { - &Tmp-Octets-0 = 0x686970706f # Hippo - &Tmp-Octets-0 = 0x0a # new line - &Tmp-Octets-0 = 0x626c6970706f # Blippo + &Class = 0x686970706f # Hippo + &Class = 0x0a # new line + &Class = 0x626c6970706f # Blippo } -&control.Tmp-String-0 := 'test_multi_octets' +&control.Filter-Id := 'test_multi_octets' linelog_ref_multi -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_multi.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_multi.log") -if (&Tmp-String-0 == ', blippo, ') { - test_pass -} -else { +if !(&test_string == ', blippo, ') { test_fail } # When no attributes that match are available, linelog should return noop -&control.Tmp-String-0 := 'test_empty' +&control.Filter-Id := 'test_empty' linelog_ref_multi -if (noop) { - test_pass -} -else { +if !(noop) { test_fail } # Remove the file %file.rm("$ENV{MODULE_TEST_DIR}/test_multi.log") + +test_pass diff --git a/src/tests/modules/linelog/linelog.unlang b/src/tests/modules/linelog/linelog.unlang index 723ff1976d3..7d0c132df68 100644 --- a/src/tests/modules/linelog/linelog.unlang +++ b/src/tests/modules/linelog/linelog.unlang @@ -1,3 +1,6 @@ +string test_string +uint32 test_integer + &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"' # @@ -6,95 +9,74 @@ %file.rm("$ENV{MODULE_TEST_DIR}/test_a.log") # Check linelog fails over to the default message (an xlat expansion) -&control.Tmp-String-0 := 'test_default' +&control.Filter-Id := 'test_default' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == 'bob default') { - test_pass -} -else { +if !(&test_string == 'bob default') { test_fail } # Check linelog adds a newline at the end of each message (also tests if execs pointed to by refs work) -&control.Tmp-String-0 := 'test_exec' +&control.Filter-Id := 'test_exec' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == 'bob exec') { - test_pass -} -else { +if !(&test_string == 'bob exec') { test_fail } # Check it's not overwriting the same line repeatedly -&Tmp-String-0 := %file.head("$ENV{MODULE_TEST_DIR}/test_a.log"); +&test_string := %file.head("$ENV{MODULE_TEST_DIR}/test_a.log"); -if (&Tmp-String-0 == 'bob default') { - test_pass -} -else { +if !(&test_string == 'bob default') { test_fail } # Check linelog can use attrs pointed to by refs -&control.Tmp-String-0 := 'test_attr' +&control.Filter-Id := 'test_attr' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == 'bob') { - test_pass -} -else { +if !(&test_string == 'bob') { test_fail } # Check linelog can use xlats pointed to by refs -&control.Tmp-String-0 := 'test_xlat' +&control.Filter-Id := 'test_xlat' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == 'bob xlat') { - test_pass -} -else { +if !(&test_string == 'bob xlat') { test_fail } # Check linelog can use literals pointed to by refs -&control.Tmp-String-0 := 'test_literal' +&control.Filter-Id := 'test_literal' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == '%{User-Name} literal') { - test_pass -} -else { +if !(&test_string == '%{User-Name} literal') { test_fail } # Check linelog can use empty conf pairs -&control.Tmp-String-0 := 'test_empty' +&control.Filter-Id := 'test_empty' linelog_fmt_and_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_a.log") -if (&Tmp-String-0 == '') { - test_pass -} -else { +if !(&test_string == '') { test_fail } @@ -105,13 +87,10 @@ else { %file.rm("$ENV{MODULE_TEST_DIR}/test_b.log") # Check behaviour when we don't have a default configured (should not create new file) -&control.Tmp-String-0 := 'test_default' +&control.Filter-Id := 'test_default' linelog_ref -if (noop) { - test_pass -} -else { +if !(noop) { test_fail } @@ -123,16 +102,13 @@ else { } ok -&control.Tmp-String-0 := 'test_exec' +&control.Filter-Id := 'test_exec' linelog_ref -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_b.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_b.log") -if (&Tmp-String-0 == 'bob exec') { - test_pass -} -else { +if !(&test_string == 'bob exec') { test_fail } @@ -143,76 +119,58 @@ else { %file.rm("$ENV{MODULE_TEST_DIR}/test_c.log") # Check behaviour using an attribute ref as a path -&control.Tmp-String-0 := '.messages.test_xlat' +&control.Filter-Id := '.messages.test_xlat' linelog_fmt_and_ref_attr -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") -if (&Tmp-String-0 == 'bob xlat') { - test_pass -} -else { +if !(&test_string == 'bob xlat') { test_fail } # Check behaviour using an attribute ref (non existent path, with default also an attribute ref) -&control.Tmp-String-0 := 'test_xlat' +&control.Filter-Id := 'test_xlat' linelog_fmt_and_ref_attr -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") -if (&Tmp-String-0 == 'bob') { - test_pass -} -else { +if !(&test_string == 'bob') { test_fail } # Check '.' is always prefixed to the path -&control.Tmp-String-0 := 'messages.test_xlat' +&control.Filter-Id := 'messages.test_xlat' linelog_fmt_and_ref_attr -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") -if (&Tmp-String-0 == 'bob xlat') { - test_pass -} -else { +if !(&test_string == 'bob xlat') { test_fail } # Check '..' results in a 'fail' (can't go up one level) -&control.Tmp-String-0 := '..messages.test_attr' +&control.Filter-Id := '..messages.test_attr' linelog_fmt_and_ref_attr { fail = 1 } -if (fail) { - test_pass -} -else { +if !(fail) { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_c.log") -if (&Tmp-String-0 == 'bob xlat') { - test_pass -} -else { +if !(&test_string == 'bob xlat') { test_fail } # Check '.messages' results in a 'fail' (messages is a section) -&control.Tmp-String-0 := '.messages' +&control.Filter-Id := '.messages' linelog_fmt_and_ref_attr { fail = 1 } -if (fail) { - test_pass -} -else { +if !(fail) { test_fail } @@ -224,12 +182,9 @@ else { linelog_fmt -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_d.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_d.log") -if (&Tmp-String-0 == 'bob') { - test_pass -} -else { +if !(&test_string == 'bob') { test_fail } @@ -240,45 +195,33 @@ else { %file.rm("$ENV{MODULE_TEST_DIR}/test_e.log") # Set attribute used in header line -&control.Tmp-String-1 := "%t" +&control.Callback-Id := "%t" linelog_header -&Tmp-String-0 := %file.head("$ENV{MODULE_TEST_DIR}/test_e.log") +&test_string := %file.head("$ENV{MODULE_TEST_DIR}/test_e.log") -if (&Tmp-String-0 == "Log started %{control.Tmp-String-1}") { - test_pass -} -else { +if !(&test_string == "Log started %{control.Callback-Id}") { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_e.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_e.log") -if (&Tmp-String-0 == 'bob,olobobob') { - test_pass -} -else { +if !(&test_string == 'bob,olobobob') { test_fail } linelog_header -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_e.log") +&test_string := %file.tail("$ENV{MODULE_TEST_DIR}/test_e.log") -if (&Tmp-String-0 == 'bob,olobobob') { - test_pass -} -else { +if !(&test_string == 'bob,olobobob') { test_fail } -&Tmp-Integer-0 := %exec('/bin/sh', '-c', "wc -l < $ENV{MODULE_TEST_DIR}/test_e.log") +&test_integer := %exec('/bin/sh', '-c', "wc -l < $ENV{MODULE_TEST_DIR}/test_e.log") -if (&Tmp-Integer-0 == 3) { - test_pass -} -else { +if !(&test_integer == 3) { test_fail } diff --git a/src/tests/modules/linelog/linelog_xlat.unlang b/src/tests/modules/linelog/linelog_xlat.unlang index 59ec49a7756..324154d8b03 100644 --- a/src/tests/modules/linelog/linelog_xlat.unlang +++ b/src/tests/modules/linelog/linelog_xlat.unlang @@ -1,3 +1,7 @@ +string test_string1 +string test_string2 +string test_string3 + &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"' # @@ -8,23 +12,23 @@ if (%linelog_fmt_delim_xlat('bob') != 5) { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") -if (&Tmp-String-0 == 'bob, ') { +if (&test_string1 == 'bob, ') { test_pass } else { test_fail } -&Tmp-String-1 := 'more' -&Tmp-String-2 := 'bob' +&test_string2 := 'more' +&test_string3 := 'bob' -if (%linelog_fmt_delim_xlat("%{Tmp-String-1}%{Tmp-String-2}") != 9) { +if (%linelog_fmt_delim_xlat("%{test_string2}%{test_string3}") != 9) { test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") -if (&Tmp-String-0 == 'bob, morebob, ') { +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") +if (&test_string1 == 'bob, morebob, ') { test_pass } else { @@ -42,9 +46,9 @@ if (%linelog_fmt_delim_xlat("{ \"foo\" : \"bar\", \"baz\" : \"boink\" }") == 36) test_fail } -&Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") +&test_string1 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log") -if (&Tmp-String-0 == '{ "foo" : "bar", "baz" : "boink" }, ') { +if (&test_string1 == '{ "foo" : "bar", "baz" : "boink" }, ') { test_pass } else { diff --git a/src/tests/modules/linelog/module.conf b/src/tests/modules/linelog/module.conf index eae06742c5a..c9a2e2b49cb 100644 --- a/src/tests/modules/linelog/module.conf +++ b/src/tests/modules/linelog/module.conf @@ -8,7 +8,7 @@ linelog linelog_fmt_and_ref { format = "%{User-Name} default" - reference = ".messages.%{control.Tmp-String-0}" + reference = ".messages.%{control.Filter-Id}" messages { test_exec = `/bin/echo "%{User-Name} exec"` @@ -27,7 +27,7 @@ linelog linelog_ref { filename = $ENV{MODULE_TEST_DIR}/test_b.log } - reference = ".messages.%{control.Tmp-String-0}" + reference = ".messages.%{control.Filter-Id}" messages { test_exec = `/bin/echo "%{User-Name} exec"` @@ -47,7 +47,7 @@ linelog linelog_fmt_and_ref_attr { format = &User-Name - reference = &control.Tmp-String-0 + reference = &control.Filter-Id messages { test_exec = `/bin/echo "%{User-Name} exec"` @@ -76,7 +76,7 @@ linelog linelog_header { filename = $ENV{MODULE_TEST_DIR}/test_e.log } - header = "Log started %{control.Tmp-String-1}" + header = "Log started %{control.Callback-Id}" format = "%{User-Name},%{User-Password}" } @@ -88,10 +88,10 @@ linelog linelog_escapes { filename = $ENV{MODULE_TEST_DIR}/test_escapes.log } - reference = ".messages.%{control.Tmp-String-0}" + reference = ".messages.%{control.Filter-Id}" messages { - test_attr = &control.Tmp-String-1 + test_attr = &control.Callback-Id test_xlat = "%{User-Name}\n\tbar" test_literal = 'foo\nbar' } @@ -132,11 +132,11 @@ linelog linelog_ref_multi { delimiter = ", " - reference = ".messages.%{control.Tmp-String-0}" + reference = ".messages.%{control.Filter-Id}" messages { test_multi_str = &control.Reply-Message[*] - test_multi_octets = &control.Tmp-Octets-0[*] + test_multi_octets = &control.Class[*] test_empty = &control.User-Name[*] } }