]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove Tmp- attributes from linelog module tests
authorNick Porter <nick@portercomputing.co.uk>
Fri, 5 Jan 2024 16:48:24 +0000 (16:48 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 5 Jan 2024 16:48:24 +0000 (16:48 +0000)
src/tests/modules/linelog/linelog-delim.unlang
src/tests/modules/linelog/linelog-escapes.unlang
src/tests/modules/linelog/linelog-multi.unlang
src/tests/modules/linelog/linelog.unlang
src/tests/modules/linelog/linelog_xlat.unlang
src/tests/modules/linelog/module.conf

index de280f46d32e6054709d36006870c40a5e9661c2..a0b74b06e1fa8a5ec31208e9759a664aa0baca8e 100644 (file)
@@ -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 {
index c9946e0ff7b10162dbe5145ea37a77daf2ce9c72..6f5fd5b3fa0c81dbca309e8365d591219cc26509 100644 (file)
@@ -1,3 +1,6 @@
+string test_string1
+string test_string2
+
 &control.Exec-Export := 'PATH="$ENV{PATH}:/bin:/usr/bin:/opt/bin:/usr/local/bin"'
 
 #
 
 #  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 {
index f8f9e2227f3c4737852ba4f4141146d7cbb89fb2..73bbc8604ca2a6e5be30b3fd1bc0db255c74ecaa 100644 (file)
@@ -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'
 }
 
 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
index 723ff1976d30b5f368b6dbafa807c067d016827d..7d0c132df6862e697cd5f64533317e9a407cb690 100644 (file)
@@ -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
 }
 
index 59ec49a775678d32168f1a0b674a8749a000111b..324154d8b03fa9ea99501f6b199237856a70291f 100644 (file)
@@ -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"'
 
 #
 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 {
index eae06742c5a76d3767c43b162bbd3d3efc3d164f..c9a2e2b49cb251391e93a14f5d05faa0f08f9fe2 100644 (file)
@@ -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[*]
        }
 }