From: Alan T. DeKok Date: Mon, 9 Oct 2023 16:32:24 +0000 (-0400) Subject: move %(foo:) to new syntax X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a65bd33e0f77c78253c294b1b3b95d01cb32490;p=thirdparty%2Ffreeradius-server.git move %(foo:) to new syntax --- diff --git a/src/tests/keywords/join b/src/tests/keywords/join index 796549be39..7946e96f03 100644 --- a/src/tests/keywords/join +++ b/src/tests/keywords/join @@ -28,13 +28,13 @@ debug_request # # @todo - fix this... # -&control.Tmp-String-1 := "%(concat:%(join:%{control.[*]} %{request.Tmp-IP-Address-0}) '. ')" +&control.Tmp-String-1 := %concat(%join(%{control.[*]}, %{request.Tmp-IP-Address-0}), '. ') if (!(&control.Tmp-String-1 == "bob. hello. ab c. de fg. 123. 192.168.1.254")) { test_fail } -&control.Tmp-String-2 := "%(concat:%(join:%{control.Tmp-String-0[*]} %{control.Tmp-Integer-0}) ,)" +&control.Tmp-String-2 := %concat(%join(%{control.Tmp-String-0[*]}, %{control.Tmp-Integer-0}), ',') if (!(&control.Tmp-String-2 == "ab c,de fg,123")) { test_fail } diff --git a/src/tests/keywords/pad b/src/tests/keywords/pad index 4c0948ba65..529a940396 100644 --- a/src/tests/keywords/pad +++ b/src/tests/keywords/pad @@ -7,38 +7,38 @@ # # rpad tests # -if (!(%(rpad:%{Tmp-String-0} 7) == "test ")) { +if (!(%rpad(%{Tmp-String-0}, 7) == "test ")) { test_fail } -if (!(%(rpad:%{Tmp-String-0} 2) == "test")) { +if (!(%rpad(%{Tmp-String-0}, 2) == "test")) { test_fail } -if (!(%(rpad:%{Tmp-String-0} 7 x) == "testxxx")) { +if (!(%rpad(%{Tmp-String-0}, 7, 'x') == "testxxx")) { test_fail } -if (!(%(rpad:%{Tmp-String-0} 7 xy) == "testxyx")) { +if (!(%rpad(%{Tmp-String-0}, 7, 'xy') == "testxyx")) { test_fail } # # lpad tests # -if (!(%(lpad:%{Tmp-String-0} 7) == " test")) { +if (!(%lpad(%{Tmp-String-0}, 7) == " test")) { test_fail } -if (!(%(lpad:%{Tmp-String-0} 2) == "test")) { +if (!(%lpad(%{Tmp-String-0}, 2) == "test")) { test_fail } -if (!(%(lpad:%{Tmp-String-0} 7 x) == "xxxtest")) { +if (!(%lpad(%{Tmp-String-0}, 7, 'x') == "xxxtest")) { test_fail } -if (!(%(lpad:%{Tmp-String-0} 7 xy) == "xyxtest")) { +if (!(%lpad(%{Tmp-String-0}, 7, 'xy') == "xyxtest")) { test_fail } diff --git a/src/tests/keywords/pairs b/src/tests/keywords/pairs index 494621399f..4ded3a1876 100644 --- a/src/tests/keywords/pairs +++ b/src/tests/keywords/pairs @@ -11,12 +11,12 @@ } &request += { - &Tmp-String-1 = "%(concat:%(pairs:Tmp-Group-0.[*]) ', ')" - &Tmp-String-2 = "%(pairs:Tmp-Group-0.Tmp-String-0)" - &Tmp-String-3 = "%(concat:%(pairs:Tmp-Group-0.Tmp-String-0[*]) ', ')" - &Tmp-String-4 = "%(concat:%(pairs:control.[*]) ', ')" - &Tmp-String-5 = "%(pairs:control.User-Name)" - &Tmp-String-6 = "%(pairs:request.Tmp-Group-0)" + &Tmp-String-1 = "%concat(%pairs(Tmp-Group-0.[*]), ', ')" + &Tmp-String-2 = "%pairs(Tmp-Group-0.Tmp-String-0)" + &Tmp-String-3 = "%concat(%pairs(Tmp-Group-0.Tmp-String-0[*]), ', ')" + &Tmp-String-4 = "%concat(%pairs(control.[*]), ', ')" + &Tmp-String-5 = "%pairs(control.User-Name)" + &Tmp-String-6 = "%pairs(request.Tmp-Group-0)" } if !(&Tmp-String-1 == 'Tmp-String-0 = "This is a string", Tmp-String-0 = "This is another one", Tmp-Octets-0 = 0x000504030201, Tmp-Integer-0 = 7331') { diff --git a/src/tests/keywords/return-within-if-after-policy b/src/tests/keywords/return-within-if-after-policy index df109b8516..1c383f3b19 100644 --- a/src/tests/keywords/return-within-if-after-policy +++ b/src/tests/keywords/return-within-if-after-policy @@ -7,7 +7,7 @@ if ('true' == 'true') { accept success if(&User-Name == 'bob') { - "%(debug:%debug(0))" # Noop + %debug(%debug(0)) # Noop return } test_fail diff --git a/src/tests/keywords/suberequest-cancel b/src/tests/keywords/suberequest-cancel index 659409bbbe..b596d9a765 100644 --- a/src/tests/keywords/suberequest-cancel +++ b/src/tests/keywords/suberequest-cancel @@ -4,14 +4,14 @@ # Cancel in subrequest subrequest Access-Request { - %(cancel:) + %cancel() test_fail } # Cancel in nested subrequest subrequest Access-Request { subrequest Access-Request { - %(cancel:) + %cancel() test_fail } } @@ -19,7 +19,7 @@ subrequest Access-Request { # Cancel parent with active subrequest, will run on next timer service %cancel(100ms) subrequest Access-Request { - %(delay_10s:1s) + %delay_10s(1s) } test_fail diff --git a/src/tests/keywords/subrequest-detach b/src/tests/keywords/subrequest-detach index 58456cb351..fd1848847c 100644 --- a/src/tests/keywords/subrequest-detach +++ b/src/tests/keywords/subrequest-detach @@ -38,7 +38,7 @@ subrequest Access-Request { detach # Smoke test for cancelling detached requests - %(cancel:) + %cancel() } success diff --git a/src/tests/keywords/unpack b/src/tests/keywords/unpack index 42ab5af1db..f9f9a34682 100644 --- a/src/tests/keywords/unpack +++ b/src/tests/keywords/unpack @@ -4,8 +4,8 @@ &Framed-IP-Address := 127.0.0.1 &Tmp-Octets-0 := &Framed-IP-Address -&Tmp-String-0 := "%(unpack:%{Tmp-Octets-0} 0 ipaddr)" -&Tmp-IP-Address-0 := "%(unpack:%{Tmp-Octets-0} 0 ipaddr)" +&Tmp-String-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')" +&Tmp-IP-Address-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')" if !(&Tmp-String-0 == "127.0.0.1") { test_fail @@ -16,7 +16,7 @@ if !(&Tmp-IP-Address-0 == 127.0.0.1) { } &Tmp-Octets-0 := 0x000001020304 -&Tmp-Integer-0 := "%(unpack:%{Tmp-Octets-0} 4 uint16)" +&Tmp-Integer-0 := "%unpack(%{Tmp-Octets-0}, 4, 'uint16')" # Octets 4 and 5 == 0x0304 == 772 if ~(&Tmp-Integer-0 == 772) { @@ -25,20 +25,20 @@ if ~(&Tmp-Integer-0 == 772) { # truncation &Tmp-String-0 := "0x0011223344556677" -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 ether)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'ether')" if !(&Tmp-String-1 == "00:11:22:33:44:55") { test_fail } &Tmp-String-0 := "0x48656C6C6F" -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')" if !(&Tmp-String-1 == "Hello") { test_fail } # Offset beyond data length &request -= &Tmp-String-1[*] -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 10 string)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 10, 'string')" if !(&Tmp-String-1 == "") { test_fail @@ -50,7 +50,7 @@ if (!(&Module-Failure-Message == "unpack offset 10 is larger than input data len &request -= &Module-Failure-Message[*] # Invalid destination data type -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 thing)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'thing')" if !(&Tmp-String-1 == "") { test_fail } @@ -60,7 +60,7 @@ if (!(&Module-Failure-Message == "Invalid data type 'thing'")) { } # Invalid source data type -&Tmp-String-1 := "%(unpack:%{Tmp-Integer-0} 0 string)" +&Tmp-String-1 := "%unpack(%{Tmp-Integer-0}, 0, 'string')" if !(&Tmp-String-1 == "") { test_fail } @@ -72,7 +72,7 @@ if (!(&Module-Failure-Message == "unpack requires the input attribute to be 'str # Invalid hex string &Tmp-String-0 := '0x014sdgw' -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')" if !(&Tmp-String-1 == "") { test_fail @@ -85,7 +85,7 @@ if (!(&Module-Failure-Message == "Invalid hex string in '0x014sdgw'")) { # Zero length hex string &Tmp-String-0 := '0x' -&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)" +&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')" if !(&Tmp-String-1 == "") { test_fail diff --git a/src/tests/keywords/xlat-attr-index b/src/tests/keywords/xlat-attr-index index c4342cd289..bdbc1d238b 100644 --- a/src/tests/keywords/xlat-attr-index +++ b/src/tests/keywords/xlat-attr-index @@ -19,7 +19,7 @@ if (!("%{Tmp-IP-Address-0[*]}" == '192.0.2.1192.0.2.2')) { &request += { &Tmp-IP-Address-1 = &Tmp-IP-Address-0[1] &Tmp-IP-Address-1 = &Tmp-IP-Address-0[0] - &Tmp-String-0 = "%(concat:%{Tmp-IP-Address-0[*]} ,)" + &Tmp-String-0 = "%concat(%{Tmp-IP-Address-0[*]}, ',')" &Tmp-Integer-0 = %{Tmp-IP-Address-0[#]} } diff --git a/src/tests/keywords/xlat-config b/src/tests/keywords/xlat-config index 3279ac71db..ab7dcf3b56 100644 --- a/src/tests/keywords/xlat-config +++ b/src/tests/keywords/xlat-config @@ -8,7 +8,7 @@ if (!(&Tmp-String-0 == "no")) { } &Tmp-String-0 := "test" -&Tmp-Integer-0 := "%(config:modules.%{Tmp-String-0}.integer)" +&Tmp-Integer-0 := %config(modules.%{Tmp-String-0}.integer) if (!(&Tmp-Integer-0 == 1)) { test_fail } diff --git a/src/tests/keywords/xlat-eval b/src/tests/keywords/xlat-eval index 4e93169676..4510588f7c 100644 --- a/src/tests/keywords/xlat-eval +++ b/src/tests/keywords/xlat-eval @@ -36,7 +36,7 @@ if (!(%eval("\%{Tmp-String-1[%{Tmp-Integer-0[2]}]}") == 'bar')) { # # Check yielding works # -if ((time_delta)"%(reschedule:)" > 1s) { +if ((time_delta)%reschedule() > 1s) { test_fail } diff --git a/src/tests/keywords/xlat-explode b/src/tests/keywords/xlat-explode index 9def851422..8c551557c2 100644 --- a/src/tests/keywords/xlat-explode +++ b/src/tests/keywords/xlat-explode @@ -16,11 +16,11 @@ } &request += { - &Tmp-String-1 = "%(concat:%(explode:%{Class} |) ,)" - &Tmp-String-2 = "%(concat:%(explode:%{Calling-Station-ID} |) ,)" - &Tmp-String-3 = "%(concat:%(explode:%{control.User-Name[*]} |) ,)" - &Tmp-String-4 = "%(concat:%(explode:%{control.Reply-Message} |) ,)" - &Tmp-String-5 = "%(concat:%(explode:%{control.Tmp-String-0} '. ') ,)" + &Tmp-String-1 = "%concat(%explode(%{Class}, '|'), ',')" + &Tmp-String-2 = "%concat(%explode(%{Calling-Station-ID}, '|'), ',')" + &Tmp-String-3 = "%concat(%explode(%{control.User-Name[*]}, |), ',')" + &Tmp-String-4 = "%concat(%explode(%{control.Reply-Message}, |), ',')" + &Tmp-String-5 = "%concat(%explode(%{control.Tmp-String-0}, '. '), ',')" } debug_all diff --git a/src/tests/keywords/xlat-list b/src/tests/keywords/xlat-list index 496a54f819..05cf83d43c 100644 --- a/src/tests/keywords/xlat-list +++ b/src/tests/keywords/xlat-list @@ -31,7 +31,7 @@ if !("%{control.[*]}" == '192.0.2.1192.0.2.2') { &request += { &Tmp-IP-Address-1 = %{control.[1]} &Tmp-IP-Address-1 = %{control.[0]} - &Tmp-String-0 = %(concat:%{control.[*]} ,) + &Tmp-String-0 = %concat(%{control.[*]}, ',') &Tmp-Integer-0 = %{control.[#]} } diff --git a/src/tests/keywords/xlat-redundant b/src/tests/keywords/xlat-redundant index 64938ced1a..bffd7b3297 100644 --- a/src/tests/keywords/xlat-redundant +++ b/src/tests/keywords/xlat-redundant @@ -2,18 +2,18 @@ # # PRE: if # -if (!(%(concat:%(test1.passthrough:foo bar) '|') == "foo|bar")) { +if (!(%concat(%(test1.passthrough:foo bar),'|') == "foo|bar")) { test_fail } -if (!(%(concat:%(test2.passthrough:foo bar) '|') == "foo|bar")) { +if (!(%concat(%(test2.passthrough:foo bar), '|') == "foo|bar")) { test_fail } # # The config has a "redundant" block for test1 and test2. # -if (!(%(concat:%(redundant_test:foo bar) '|') == "foo|bar")) { +if (!(%concat(%(redundant_test:foo bar), '|') == "foo|bar")) { test_fail } diff --git a/src/tests/keywords/xlat-subst b/src/tests/keywords/xlat-subst index ed9d012d07..dae2c30bd7 100644 --- a/src/tests/keywords/xlat-subst +++ b/src/tests/keywords/xlat-subst @@ -7,68 +7,68 @@ # # Global substitution -if (!(%(subst:%{Tmp-String-0} a b) == 'bbb')) { +if (!(%subst(%{Tmp-String-0}, 'a', 'b') == 'bbb')) { test_fail } # No match -if (!(%(subst:%{Tmp-String-0} c b) == 'aaa')) { +if (!(%subst(%{Tmp-String-0}, 'c', 'b') == 'aaa')) { test_fail } # Line ending rewrite -if (!(%(subst:%{Tmp-String-1} \n \r) == "\r\r\r")) { +if (!(%subst(%{Tmp-String-1}, "\n", "\r") == "\r\r\r")) { test_fail } # Removal -if (!(%(subst:%{Tmp-String-0} a '') == "")) { +if (!(%subst(%{Tmp-String-0}, 'a', '') == "")) { test_fail } # Removal of last word only -if (!(%(subst:%{Tmp-String-2} dog '') == "the quick brown fox jumped over the lazy ")) { +if (!(%subst(%{Tmp-String-2}, 'dog', '') == "the quick brown fox jumped over the lazy ")) { test_fail } # Removal of first and subsequent word -if (!(%(subst:%{Tmp-String-2} the '') == " quick brown fox jumped over lazy dog")) { +if (!(%subst(%{Tmp-String-2}, 'the', '') == " quick brown fox jumped over lazy dog")) { test_fail } # Removal of middle word -if (!(%(subst:%{Tmp-String-2} jumped '') == "the quick brown fox over the lazy dog")) { +if (!(%subst(%{Tmp-String-2}, 'jumped', '') == "the quick brown fox over the lazy dog")) { test_fail } # Replacement of last word only -if (!(%(subst:%{Tmp-String-2} dog cat) == "the quick brown fox jumped over the lazy cat")) { +if (!(%subst(%{Tmp-String-2}, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) { test_fail } # Replacement of first and subsequent word -if (!(%(subst:%{Tmp-String-2} the cat) == "cat quick brown fox jumped over cat lazy dog")) { +if (!(%subst(%{Tmp-String-2}, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) { test_fail } # Replacement of middle word -if (!(%(subst:%{Tmp-String-2} jumped cat) == "the quick brown fox cat over the lazy dog")) { +if (!(%subst(%{Tmp-String-2}, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) { test_fail } if ("${feature.regex-pcre2}" == 'yes') { # Basic substitutions -if (!(%(subst:%{Tmp-String-0} /a/ b) == 'baa')) { +if (!(%subst(%{Tmp-String-0}, /a/, 'b') == 'baa')) { test_fail } # Global substitution -if (!(%(subst:%{Tmp-String-0} /a/g b) == 'bbb')) { +if (!(%subst(%{Tmp-String-0}, /a/g, 'b') == 'bbb')) { test_fail } # No match -if (!(%(subst:%{Tmp-String-0} /z/ b) == 'aaa')) { +if (!(%subst(%{Tmp-String-0}, /z/, 'b') == 'aaa')) { test_fail } @@ -77,31 +77,31 @@ if (!(%(subst:%{Tmp-String-0} /z/ b) == 'aaa')) { # # Check that newlines really are newlines -if (!("%length(%{Tmp-String-1})" == 3)) { +if (!(%length(%{Tmp-String-1}) == 3)) { test_fail } # Strip out just the first newline -if (!(%(subst:%{Tmp-String-1} /^./s '') == "\n\n")) { +if (!(%subst(%{Tmp-String-1}, /^./s, '') == "\n\n")) { test_fail } -if (!(%(subst:%{Tmp-String-1} /\n/ '') == "\n\n")) { +if (!(%subst(%{Tmp-String-1}, /\n/, '') == "\n\n")) { test_fail } # Strip out all the newlines -if (!(%(subst:%{Tmp-String-1} /\n/g '') == '')) { +if (!(%subst(%{Tmp-String-1}, /\n/g, '') == '')) { test_fail } # Line ending switch -if (!(%(subst:%{Tmp-String-1} /\n/g \r) == "\r\r\r")) { +if (!(%subst(%{Tmp-String-1}, /\n/g, "\r") == "\r\r\r")) { test_fail } # Bad regex -if ("%(subst:%{Tmp-String-0} /***/g .)") { +if (%subst(%{Tmp-String-0}, /***/g, '.')) { test_fail } @@ -112,7 +112,7 @@ if !(&Module-Failure-Message[*] == 'Failed compiling regex: quantifier does not &request -= &Module-Failure-Message[*] # Empty regex -if ("%(subst:%{Tmp-String-0} //g .)") { +if (%subst(%{Tmp-String-0}, //g, '.')) { test_fail }