]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
conver to new function syntax
authorAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 16:04:49 +0000 (12:04 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 16:04:49 +0000 (12:04 -0400)
src/tests/keywords/if-regex-match-named
src/tests/keywords/if-tlv
src/tests/keywords/map-xlat-nested-overwrite
src/tests/keywords/pack
src/tests/keywords/pap
src/tests/keywords/pap-ssha2
src/tests/keywords/urlquote
src/tests/keywords/xlat-eval

index 955cfc64f914794d6ca4c35be67776b8bd106b26..31a6ef01063b764b0a10e169b45050ae60a44839 100644 (file)
@@ -7,7 +7,7 @@ if (('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) {
        }
 
 # Check failure when no previous capture - full capture
-if ("%{regex:}") {
+if (%regex()) {
        test_fail
 }
 
@@ -18,7 +18,7 @@ if (!(&Module-Failure-Message[*] == "No previous regex capture")) {
 &request -= &Module-Failure-Message[*]
 
 # Check failure when no previous capture - named group
-if ("%regex(foo)") {
+if (%regex(foo)) {
        test_fail
 }
 
@@ -29,7 +29,7 @@ if (!(&Module-Failure-Message[*] == "No previous named regex capture group")) {
 &request -= &Module-Failure-Message[*]
 
 # Check failure when no previous capture - numbered group
-if ("%regex(%{Tmp-Integer-1})") {
+if (%regex(%{Tmp-Integer-1})) {
        test_fail
 }
 
index df1ecdfe80ab0b264168df9161e1a9ebe78999ea..a6ae44917f2aec1b43208268dd2621878b15e929 100644 (file)
@@ -2,9 +2,9 @@
 # PRE: if
 #
 
-"%{map:&TLS-Certificate.Issuer = 'foo'}"
+%map("&TLS-Certificate.Issuer = 'foo'")
 
-if (!&TLS-Certificate.Issuer) {
+if !(&TLS-Certificate.Issuer == 'foo') {
        test_fail
 }
 
index 312770f84df142a82795f374749d9aea1e93c5b4..e32c597ce025cc0d169e0e45dc0ee33f77c68ff9 100644 (file)
@@ -5,15 +5,15 @@
 #
 &Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-0 := 'testing123'"
 
-if (!("%map(%{Tmp-String-0})" == 1)) {
+if (!(%map("%{Tmp-String-0}") == 1)) {
        test_fail
 }
 
-if (!("%map(%{Tmp-String-0})" == 1)) {
+if (!(%map("%{Tmp-String-0}") == 1)) {
        test_fail
 }
 
-if (!(%{map:request.Tmp-Group-0.Tmp-String-1 := 'testing000'} == 1)) {
+if (!(%map("request.Tmp-Group-0.Tmp-String-1 := 'testing000'") == 1)) {
        test_fail
 }
 
index 6708afa110e893f41b0f721bc834878dc87754d2..ad98f3aa2e0c8b5c6fdf0c84a9b6f29a8a3b12e7 100644 (file)
@@ -8,7 +8,16 @@
 }
 
 
-&Tmp-Octets-0 := "%{pack:%{Framed-IP-Address}%{NAS-Port}%{NAS-IP-Address}}"
+&Tmp-Octets-0 := %pack(%{Framed-IP-Address}%{NAS-Port}%{NAS-IP-Address})
+
+if (!(&Tmp-Octets-0 == 0x7f000001000008407f000002)) {
+       test_fail
+}
+
+#
+#  With octet addition, we don't need %pack() any more!
+#
+&Tmp-Octets-0 := (octets) &Framed-IP-Address + (octets) &NAS-Port + (octets) &NAS-IP-Address
 
 if (!(&Tmp-Octets-0 == 0x7f000001000008407f000002)) {
        test_fail
index 411cd550009ea15fd0452e8f15f5cfaddb1b2229..205c25c0bd0aaff0539eaf20e4e0cb3b41ed33b7 100644 (file)
@@ -39,7 +39,7 @@ if (reject) {
 #  Hex encoded SSHA password
 #
 &control := {
-       &Password.With-Header = "{ssha}%{hex:%{sha1:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+       &Password.With-Header = "{ssha}%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 }
 
 pap.authorize
@@ -54,14 +54,14 @@ if (reject) {
 #  Base64 encoded SSHA password
 #
 &control := {
-        &Tmp-String-1 = "%{hex:%{sha1:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+        &Tmp-String-1 = "%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 }
 
 # To Binary
 &control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
 
 # To Base64
-&control.Tmp-String-1 := "%(base64.encode:%{control.Tmp-Octets-0})"
+&control.Tmp-String-1 := "%base64.encode(%{control.Tmp-Octets-0})"
 &control.Password.With-Header := "{ssha}%{control.Tmp-String-1}"
 
 pap.authorize
@@ -76,15 +76,15 @@ if (reject) {
 #  Base64 of Base64 encoded SSHA password
 #
 &control := {
-       &Tmp-String-1 = "%{hex:%{sha1:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+       &Tmp-String-1 = "%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 }
 
 # To Binary
 &control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
 
 # To Base64
-&control.Tmp-String-1 := "{ssha}%(base64.encode:%{control.Tmp-Octets-0})"
-&control.Password.With-Header := "%(base64.encode:%{control.Tmp-String-1})"
+&control.Tmp-String-1 := "{ssha}%base64.encode(%{control.Tmp-Octets-0})"
+&control.Password.With-Header := "%base64.encode(%{control.Tmp-String-1})"
 
 pap.authorize
 pap.authenticate {
index 76902d94564a1fd4b7cafc624ebec28892fe0004..74c3bf85069c84c837bc4d039b5381ed729b5f27 100644 (file)
@@ -21,7 +21,7 @@ if (!('${feature.tls}' == 'yes')) {
 #  Hex encoded SSHA2-512 password
 #
 &control += {
-       &Password.With-Header = "{ssha512}%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+       &Password.With-Header = "{ssha512}%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 }
 
 pap.authorize
@@ -37,13 +37,13 @@ if (reject) {
 #
 #  Base64 encoded SSHA2-512 password
 #
-&control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+&control.Tmp-String-1 := "%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 
 # To Binary
 &control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
 
 # To Base64
-&control.Tmp-String-1 := "%(base64.encode:%{control.Tmp-Octets-0})"
+&control.Tmp-String-1 := "%base64.encode(%{control.Tmp-Octets-0})"
 
 &control += {
        &Password.With-Header = "{ssha512}%{control.Tmp-String-1}"
@@ -62,7 +62,7 @@ if (reject) {
 #
 #  Base64 of Base64 encoded SSHA2-512 password
 #
-&control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%hex(%{Tmp-String-0})"
+&control.Tmp-String-1 := "%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
 
 # To Binary
 &control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
@@ -71,7 +71,7 @@ if (reject) {
 &control.Tmp-String-1 := "{ssha512}%(base64.encode:%{control.Tmp-Octets-0})"
 
 &control += {
-       &Password.With-Header = "%(base64.encode:%{control.Tmp-String-1})"
+       &Password.With-Header = "%base64.encode(%{control.Tmp-String-1})"
 }
 
 pap.authorize
@@ -87,7 +87,7 @@ if (reject) {
 #
 #  Base64 of SHA2-384 password (in SHA2-Password)
 #
-&control.Password.SHA2 := "%{hex:%sha2_384(%{User-Password})}"
+&control.Password.SHA2 := %hex(%sha2_384(%{User-Password}))
 
 pap.authorize
 pap.authenticate {
@@ -104,7 +104,7 @@ if (reject) {
 #
 #  Base64 of SHA2-256 password (in SHA2-256-Password)
 #
-&control.Password.SHA2-256 := "%{hex:%sha2_256(%{User-Password})}"
+&control.Password.SHA2-256 := "%hex(%sha2_256(%{User-Password}))"
 
 pap.authorize
 pap.authenticate {
index 98e8df8de8be38ac5272180aba573485b9f06409..575f48ea568627508d423573bf137411cc2ebe9e 100644 (file)
@@ -42,7 +42,7 @@ if (!(&Tmp-String-9 == &Tmp-String-4)) {
 &Tmp-String-1 := "%urlunquote(%{Tmp-String-0})"
 
 &request -= &Tmp-String-2[*]
-&Tmp-String-2 := "%{urlunquote:%%E,123}"
+&Tmp-String-2 := "%urlunquote(%%E,123)"
 
 if (!(&Tmp-String-1 == &Tmp-String-0)) {
        test_fail
index 1e40cbd3a129b2ce2ee3a16ba2e85ee0f41d33fc..4e931696766ac25c5893477519adae5892ad00c6 100644 (file)
@@ -15,21 +15,21 @@ if (!("%eval(%{Tmp-Integer-0})" == 4)) {
        test_fail
 }
 
-if (!("%{eval:%{Tmp-Integer-0[1]}}" == 8)) {
+if (!(%eval(%{Tmp-Integer-0[1]}) == 8)) {
        test_fail
 }
 
 #
 #  Check double expansion works
 #
-if (!("%eval(%{Tmp-String-0})" == 'foo')) {
+if (!(%eval(%{Tmp-String-0}) == 'foo')) {
        test_fail
 }
 
 #
 #  Using an attribute as a dynamic index for another attribute
 #
-if (!("%{eval:\%{Tmp-String-1[%{Tmp-Integer-0[2]}]\}}" == 'bar')) {
+if (!(%eval("\%{Tmp-String-1[%{Tmp-Integer-0[2]}]}") == 'bar')) {
        test_fail
 }