]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move %(foo:) to new syntax
authorAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 16:32:24 +0000 (12:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 16:32:24 +0000 (12:32 -0400)
14 files changed:
src/tests/keywords/join
src/tests/keywords/pad
src/tests/keywords/pairs
src/tests/keywords/return-within-if-after-policy
src/tests/keywords/suberequest-cancel
src/tests/keywords/subrequest-detach
src/tests/keywords/unpack
src/tests/keywords/xlat-attr-index
src/tests/keywords/xlat-config
src/tests/keywords/xlat-eval
src/tests/keywords/xlat-explode
src/tests/keywords/xlat-list
src/tests/keywords/xlat-redundant
src/tests/keywords/xlat-subst

index 796549be398a632c24ad645273cc78facad0ecd5..7946e96f03bde47c8b58a05804fa5a4c7ae2f0c4 100644 (file)
@@ -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
 }
index 4c0948ba653495c8db68684663083acea8547394..529a94039688daf177ccc308a2a0bf58018ad568 100644 (file)
@@ -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
 }
 
index 494621399f855ee3b4604fe479f0daa6258d212a..4ded3a1876af4267f054e551b6591b70b706c8cb 100644 (file)
 }
 
 &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') {
index df109b851668688270b400eb68f35b93cdf55e53..1c383f3b19034560f94caf95766c56df68bd6b12 100644 (file)
@@ -7,7 +7,7 @@ if ('true' == 'true') {
        accept
        success
        if(&User-Name == 'bob') {
-               "%(debug:%debug(0))"    # Noop
+               %debug(%debug(0))       # Noop
                return
        }
        test_fail
index 659409bbbebe2af870250ed6da781c378ebb8180..b596d9a76564ee7d5fc4a2bd139fef88a469df15 100644 (file)
@@ -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
index 58456cb351c2e3cdde9395bb2292479559bbe8f1..fd1848847cedbc51bd4d62053fb7a4863ac7f983 100644 (file)
@@ -38,7 +38,7 @@ subrequest Access-Request {
        detach
 
        # Smoke test for cancelling detached requests
-       %(cancel:)
+       %cancel()
 }
 
 success
index 42ab5af1dbff34f0b95546aa70fe536ab1204b37..f9f9a34682fe6d1d32a1c3cdf577cf4485b62261 100644 (file)
@@ -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
index c4342cd2898f59960c50004d2217a8545247919e..bdbc1d238badc52bc3831bc953726908a6cec539 100644 (file)
@@ -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[#]}
 }
 
index 3279ac71dbbf403db072763ac7f43c3d7c660390..ab7dcf3b56da06b0002e85705feb198877710013 100644 (file)
@@ -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
 }
index 4e931696766ac25c5893477519adae5892ad00c6..4510588f7c9571406a65df3fd6a37f462520206f 100644 (file)
@@ -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
 }
 
index 9def851422c8d6d9982b162780d47d4801211e25..8c551557c2b5226eaf2ae5a3c7834d04d57b9f26 100644 (file)
 }
 
 &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
index 496a54f819eafce63ea5d6db509defd38ddba1c7..05cf83d43ced7ddd975bc477954784b534bbdc1a 100644 (file)
@@ -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.[#]}
 }
 
index 64938ced1ae255fdb41f65999a8ba119ad662cfd..bffd7b32971f3bfae88f62e6219b598559cca76e 100644 (file)
@@ -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
 }
 
index ed9d012d077e5eaeeffe995fa51a9676787c5ddd..dae2c30bd786445c07695508807320011a288c44 100644 (file)
@@ -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
 }