]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move to new function syntax
authorAlan T. DeKok <aland@freeradius.org>
Fri, 17 Nov 2023 14:24:14 +0000 (09:24 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 17 Nov 2023 14:53:44 +0000 (09:53 -0500)
src/tests/keywords/escape
src/tests/modules/cipher/rsa_encrypt_decrypt.unlang
src/tests/modules/cipher/rsa_sign_verify.unlang
src/tests/modules/json/encode.unlang
src/tests/modules/json/encode_error.unlang
src/tests/modules/json/parser.unlang
src/tests/modules/linelog/linelog_xlat.unlang
src/tests/modules/rest/rest_xlat.unlang
src/tests/unit/xlat/alternation.txt
src/tests/unit/xlat/base.txt
src/tests/xlat/expr.txt

index 2b51823842fce82569c408046364bcd43e621090..d87b961c8ad0dfe665738e0666535131b67b7783 100644 (file)
 # = not followed by hex and without 2 following chars
 &Tmp-String-8 := 'a=Az=y'
 
-if (!((string)"%{escape.escape:%{Tmp-String-0}}" == &Tmp-String-0)) {
+if (!((string)%escape.escape("%{Tmp-String-0}") == &Tmp-String-0)) {
        test_fail
 }
 
-if (!((string)"%{escape.escape:%{Tmp-String-1}}" == &Tmp-String-3)) {
+if (!((string)%escape.escape("%{Tmp-String-1}") == &Tmp-String-3)) {
        test_fail
 }
 
-if (!((string)"%{escape.escape:%{Tmp-String-2}}" == &Tmp-String-4)) {
+if (!((string)%escape.escape("%{Tmp-String-2}") == &Tmp-String-4)) {
        test_fail
 }
 
-if (!((string)"%{escape.unescape:%{Tmp-String-0}}" == &Tmp-String-0)) {
+if (!((string)%escape.unescape("%{Tmp-String-0}") == &Tmp-String-0)) {
        test_fail
 }
 
-if (!((string)"%{escape.unescape:%{Tmp-String-3}}" == "%{Tmp-String-1}")) {
+if (!((string)%escape.unescape("%{Tmp-String-3}") == "%{Tmp-String-1}")) {
        test_fail
 }
 
-if (!((string)"%{escape.unescape:%{Tmp-String-4}}" == &Tmp-String-2)) {
+if (!((string)%escape.unescape("%{Tmp-String-4}") == &Tmp-String-2)) {
        test_fail
 }
 
-if (!((string)"%{escape.escape:%{Tmp-String-6}}" == &Tmp-String-7)) {
+if (!((string)%escape.escape("%{Tmp-String-6}") == &Tmp-String-7)) {
        test_fail
 }
 
-if (!((string)"%{escape.unescape:%{Tmp-String-7}}" == &Tmp-String-6)) {
+if (!((string)%escape.unescape("%{Tmp-String-7}") == &Tmp-String-6)) {
        test_fail
 }
 
-if (!((string)"%{escape.unescape:%{Tmp-String-8}}" == &Tmp-String-8)) {
+if (!((string)%escape.unescape("%{Tmp-String-8}") == &Tmp-String-8)) {
        test_fail
 }
 
index 8e448b11d21a087c385ade64ee8e4dffb09ba817..ac86d59401de3f36cd6f70ac2075e15f7fed2f90 100644 (file)
@@ -1,5 +1,5 @@
 &Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := "%cipher_rsa.encrypt(%{Tmp-String-0})"
+&Tmp-Octets-0 := %cipher_rsa.encrypt(%{Tmp-String-0})
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -15,7 +15,7 @@ else {
        test_pass
 }
 
-&Tmp-String-1 := "%{cipher_rsa.decrypt:%{Tmp-Octets-0}}"
+&Tmp-String-1 := %cipher_rsa.decrypt(%{Tmp-Octets-0})
 
 if (&Tmp-String-0 != &Tmp-String-1) {
        test_fail
@@ -27,7 +27,7 @@ else {
 #
 #  Padding scheme should ensure ciphertext is not consistent
 #
-&Tmp-Octets-1 := "%{cipher_rsa.encrypt:%{Tmp-String-0}}"
+&Tmp-Octets-1 := %cipher_rsa.encrypt(%{Tmp-String-0})
 
 if (&Tmp-Octets-0 == &Tmp-Octets-1) {
        test_fail
@@ -40,7 +40,7 @@ else {
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
 &Tmp-String-0 := "Goodbye world!"
-&Tmp-Octets-0 := "%{cipher_rsa.encrypt:%{Tmp-String-0}}"
+&Tmp-Octets-0 := %cipher_rsa.encrypt(%{Tmp-String-0})
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -56,7 +56,7 @@ else {
        test_pass
 }
 
-&Tmp-String-1 := "%{cipher_rsa.decrypt:%{Tmp-Octets-0}}"
+&Tmp-String-1 := %cipher_rsa.decrypt(%{Tmp-Octets-0})
 
 if (&Tmp-String-0 != &Tmp-String-1) {
        test_fail
index d89e5269bf77d544d16a7990d53e5cce8ae01b10..0c4ba145f8c7caa58bf3daf33e47905daa474a36 100644 (file)
@@ -1,5 +1,5 @@
 &Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := "%{cipher_rsa.sign:%{Tmp-String-0}}"
+&Tmp-Octets-0 := %cipher_rsa.sign(%{Tmp-String-0})
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -12,7 +12,7 @@ if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
 
 if (&Tmp-String-0 != 'yes') {
        test_fail
@@ -22,7 +22,7 @@ if (&Tmp-String-0 != 'yes') {
 #  Verification should now fail
 #
 &Tmp-String-0 := "Goodbye world!"
-&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
 
 if (&Tmp-String-0 != 'no') {
        test_fail
@@ -32,7 +32,7 @@ if (&Tmp-String-0 != 'no') {
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
 &Tmp-String-0 := "Hello nurse!"
-&Tmp-Octets-0 := "%{cipher_rsa.sign:%{Tmp-String-0}}"
+&Tmp-Octets-0 := %cipher_rsa.sign(%{Tmp-String-0})
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -45,7 +45,7 @@ if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
 
 if (&Tmp-String-0 != 'yes') {
        test_fail
@@ -55,7 +55,7 @@ if (&Tmp-String-0 != 'yes') {
 #  Verification should now fail
 #
 &Tmp-String-0 := "Goodbye nurse!"
-&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
 
 if (&Tmp-String-0 != 'no') {
        test_fail
index f2c5b82a7d0d39be1524b58114b9154cc52c7936..e22c6800f72f99a15912281cbad3a744bbf9df75 100644 (file)
 &request -= &Net[*]
 
 # 0. Check basic xlat parsing
-&control.Tmp-String-1 := "%{json.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json.encode:&request.[*] }"
-&control.Tmp-String-3 := "%{json.encode: &request.[*]}"
-&control.Tmp-String-4 := "%{json.encode:        &request.[*]   }"
-&control.Tmp-String-5 := "%{json.encode: &request.[*]    !&Filter-Id }"
-&control.Tmp-String-6 := "%{json.encode:&request.[*] ! }"
+&control.Tmp-String-1 := %json.encode("&request.[*]")
+&control.Tmp-String-2 := %json.encode("&request.[*] ")
+&control.Tmp-String-3 := %json.encode(" &request.[*]")
+&control.Tmp-String-4 := %json.encode("         &request.[*]   ")
+&control.Tmp-String-5 := %json.encode(" &request.[*]    !&Filter-Id ")
+&control.Tmp-String-6 := %json.encode("&request.[*] ! ")
 #  Check defaults are the same as output_mode "object":
-&control.Tmp-String-7 := "%{json_object.encode:&request.[*]}"
-&control.Tmp-String-8 := "%{json_object_no.encode:&request.[*]}"
+&control.Tmp-String-7 := %json_object.encode("&request.[*]")
+&control.Tmp-String-8 := %json_object_no.encode("&request.[*]")
 
 if (!(&control.Tmp-String-1 == '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}')) {
        test_fail
@@ -48,7 +48,7 @@ if !(&control.Tmp-String-5 == '{"User-Name":{"type":"string","value":"john"},"NA
        test_fail
 }
 
-if !(&control.Tmp-String-6 == "") {
+if &control.Tmp-String-6 {
        test_fail
 }
 
@@ -56,8 +56,8 @@ if !(&control.Tmp-String-6 == "") {
 
 # These are unsorted dictionaries. Hopefully json-c doesn't suddenly
 # decide that it's going to use a different ordering of the keys...
-&control.Tmp-String-1 := "%{json_object.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_object_ex.encode:&request.[*]}"
+&control.Tmp-String-1 := %json_object.encode("&request.[*]")
+&control.Tmp-String-2 := %json_object_ex.encode("&request.[*]")
 
 if !(&control.Tmp-String-1 == '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
        test_fail
@@ -69,15 +69,15 @@ if !(&control.Tmp-String-2 == '{"pf:User-Name":{"type":"string","value":["john"]
 }
 
 # 1b. "object" empty inputs
-&control.Tmp-String-1 := "%{json_object.encode:!&request.[*]}"
+&control.Tmp-String-1 := %json_object.encode("!&request.[*]")
 
 if !(&control.Tmp-String-1 == '{}') {
        test_fail
 }
 
 # 2a. Output mode "object_simple" tests
-&control.Tmp-String-1 := "%{json_object_simple.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_object_simple_ex.encode:&request.[*]}"
+&control.Tmp-String-1 := %json_object_simple.encode("&request.[*]")
+&control.Tmp-String-2 := %json_object_simple_ex.encode("&request.[*]")
 
 if !(&control.Tmp-String-1 == '{"User-Name":"john","Filter-Id":["f1","f2"],"NAS-Port":999,"Service-Type":"Login-User"}') {
        test_fail
@@ -88,15 +88,15 @@ if !(&control.Tmp-String-2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2
 }
 
 # 2b. "object_simple" empty inputs
-&control.Tmp-String-1 := "%{json_object_simple.encode:!&request.[*]}"
+&control.Tmp-String-1 := %json_object_simple.encode("!&request.[*]")
 
 if !(&control.Tmp-String-1 == '{}') {
        test_fail
 }
 
 # 3a. Output mode "array" tests
-&control.Tmp-String-1 := "%{json_array.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_ex.encode:&request.[*]}"
+&control.Tmp-String-1 := %json_array.encode("&request.[*]")
+&control.Tmp-String-2 := %json_array_ex.encode("&request.[*]")
 
 if !(&control.Tmp-String-1 == '[{"name":"User-Name","type":"string","value":"john"},{"name":"Filter-Id","type":"string","value":"f1"},{"name":"Filter-Id","type":"string","value":"f2"},{"name":"NAS-Port","type":"uint32","value":999},{"name":"Service-Type","type":"uint32","value":"Login-User"}]') {
        test_fail
@@ -107,15 +107,15 @@ if !(&control.Tmp-String-2 == '[{"name":"pf:User-Name","type":"string","value":[
 }
 
 # 3b. "array" empty inputs
-&control.Tmp-String-1 := "%{json_array.encode:!&request.[*]}"
+&control.Tmp-String-1 := %json_array.encode("!&request.[*]")
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
 }
 
 # 4a. Output mode "array_of_names" tests
-&control.Tmp-String-1 := "%{json_array_names.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_names_ex.encode:&request.[*]}"
+&control.Tmp-String-1 := %json_array_names.encode("&request.[*]")
+&control.Tmp-String-2 := %json_array_names_ex.encode("&request.[*]")
 
 if !(&control.Tmp-String-1 == '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
        test_fail
@@ -126,15 +126,15 @@ if !(&control.Tmp-String-2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf
 }
 
 # 4b. "array_of_names" empty inputs
-&control.Tmp-String-1 := "%{json_array_names.encode:!&request.[*]}"
+&control.Tmp-String-1 := %json_array_names.encode("!&request.[*]")
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
 }
 
 # 5a. Output mode "array_of_values" tests
-&control.Tmp-String-1 := "%{json_array_values.encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_values_ex.encode:&request.[*]}"
+&control.Tmp-String-1 := %json_array_values.encode("&request.[*]")
+&control.Tmp-String-2 := %json_array_values_ex.encode("&request.[*]")
 
 if !(&control.Tmp-String-1 == '["john","f1","f2",999,"Login-User"]') {
        test_fail
@@ -145,7 +145,7 @@ if !(&control.Tmp-String-2 == '["john","f1","f2","999","1"]') {
 }
 
 # 5b. "array_of_values" empty inputs
-&control.Tmp-String-1 := "%{json_array_values.encode:!&request.[*]}"
+&control.Tmp-String-1 := %json_array_values.encode("!&request.[*]")
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
index 3f4c2ad76f3a8d1e17bcf640f45cb30d8c73dc97..91c6cf0673de7765f0e2c3509cdd0eccb0db832f 100644 (file)
@@ -2,7 +2,7 @@
 #       json xlat input parsing test - error with no input
 #
 
-&Tmp-String-1 := %{json_object_ex_encode:}  # ERROR
+&Tmp-String-1 := %json_object_ex_encode()  # ERROR
 if (&Tmp-String-1) {
        test_fail
 }
index 7858f7ebee3058e7dca83ce144dcab0b3a6950ed..0c49e4ae1565adca9893917f32a24f42e242722a 100644 (file)
 #
 
 # 0. Expect success - Field selectors
-if ("%{json_jpath_validate:$.foo.bar}" != '9:$.foo.bar') {
+if (%json_jpath_validate("$.foo.bar") != '9:$.foo.bar') {
        test_fail
 }
 
 # 1. Expect success - Field selectors
-if ("%{json_jpath_validate:@.foo.bar}" != '9:@.foo.bar') {
+if (%json_jpath_validate("@.foo.bar") != '9:@.foo.bar') {
        test_fail
 }
 
 # 2. Expect success - Array selector
-if ("%{json_jpath_validate:$.foo[1]}" != '8:$.foo[1]') {
+if (%json_jpath_validate("$.foo[1]") != '8:$.foo[1]') {
        test_fail
 }
 
 # 3. Expect success - Array selector
-if ("%{json_jpath_validate:$.foo[1:2]}" != '10:$.foo[1:2]') {
+if (%json_jpath_validate("$.foo[1:2]") != '10:$.foo[1:2]') {
        test_fail
 }
 
 # 4. Expect success - Array slice selector
-if ("%{json_jpath_validate:$.foo[:1]}" != '9:$.foo[:1]') {
+if (%json_jpath_validate("$.foo[:1]") != '9:$.foo[:1]') {
        test_fail
 }
 
 # 5. Expect success - Array slice selector
-if ("%{json_jpath_validate:$.foo[1::1]}" != '11:$.foo[1::1]') {
+if (%json_jpath_validate("$.foo[1::1]") != '11:$.foo[1::1]') {
        test_fail
 }
 
 # 6. Expect success - Array step selector
-if ("%{json_jpath_validate:$.foo[::2]}" != '10:$.foo[::2]') {
+if (%json_jpath_validate("$.foo[::2]") != '10:$.foo[::2]') {
        test_fail
 }
 
 # 7. Expect success - Array step selector
-if ("%{json_jpath_validate:$.foo[1:1:2]}" != '12:$.foo[1:1:2]') {
+if (%json_jpath_validate("$.foo[1:1:2]") != '12:$.foo[1:1:2]') {
        test_fail
 }
 
 # 8. Expect success - Array multiple selectors
-if ("%{json_jpath_validate:$.foo[1,1:1:2]}" != '14:$.foo[1,1:1:2]') {
+if (%json_jpath_validate("$.foo[1,1:1:2]") != '14:$.foo[1,1:1:2]') {
        test_fail
 }
 
 # 9. Expect success - Wildcard selector 1
-if ("%{json_jpath_validate:$.*}" != '3:$.*') {
+if (%json_jpath_validate("$.*") != '3:$.*') {
        test_fail
 }
 
 # 10. Expect success - Wildcard selector 2
-if ("%{json_jpath_validate:$.*.foo}" != '7:$.*.foo') {
+if (%json_jpath_validate("$.*.foo") != '7:$.*.foo') {
        test_fail
 }
 
 # 11. Expect success - Mixture of selectors
-if ("%{json_jpath_validate:$.foo[::2].*.bar[::1]}" != '21:$.foo[::2].*.bar[::1]') {
+if (%json_jpath_validate("$.foo[::2].*.bar[::1]") != '21:$.foo[::2].*.bar[::1]') {
        test_fail
 }
 
 # 12. Expect success - Escape sequence
-if ("%{json_jpath_validate:$.foo.bar\[\]}" != '13:$.foo.bar\[\]') {
+if (%json_jpath_validate("$.foo.bar\[\]") != '13:$.foo.bar\[\]') {
        test_fail
 }
 
 # 13. Expect success - Non escape sequence
-if ("%{json_jpath_validate:$.foo.bar\@}" != '11:$.foo.bar\@') {
+if (%json_jpath_validate("$.foo.bar\@") != '11:$.foo.bar\@') {
        test_fail
 }
 
 # 14. Expect failure - Invalid starting char
-if ("%{json_jpath_validate:[.foo}" != '0:Expected root specifier \'$\', or current node specifier \'@\'') {
+if (%json_jpath_validate("[.foo") != '0:Expected root specifier \'$\', or current node specifier \'@\'') {
        test_fail
 }
 
 # 15. Expect failure - Invalid char following root specifier
-if ("%{json_jpath_validate:$[]}" != '2:Empty selector') {
+if (%json_jpath_validate("$[]") != '2:Empty selector') {
        test_fail
 }
 
 # 16. Expect failure - Invalid char following root specifier
-if ("%{json_jpath_validate:$.}" != '2:Expected recursive descent \'..\' wildcard \'*\' or field specifier') {
+if (%json_jpath_validate("$.") != '2:Expected recursive descent \'..\' wildcard \'*\' or field specifier') {
        test_fail
 }
 
 # 17. Expect failure - Recursive descent after child delimiter
-if ("%{json_jpath_validate:$...}" != '3:Recursive descent must not be followed by child delimiter \'.\'') {
+if (%json_jpath_validate("$...") != '3:Recursive descent must not be followed by child delimiter \'.\'') {
        test_fail
 }
 
 # 18. Expect failure - Missing selector terminator
-if ("%{json_jpath_validate:$.foo[}" != '6:Missing selector terminator \']\'') {
+if (%json_jpath_validate("$.foo[") != '6:Missing selector terminator \']\'') {
        test_fail
 }
 
 # 19. Expect failure - Missing selector terminator
-if ("%{json_jpath_validate:$.foo[0}" != '7:Missing selector delimiter \',\' or terminator \']\'') {
+if (%json_jpath_validate("$.foo[0") != '7:Missing selector delimiter \',\' or terminator \']\'') {
        test_fail
 }
 
 # 20. Expect failure - Unexpected selector terminator
-if ("%{json_jpath_validate:$.foo]}" != '5:Expected field specifier \'.\' or selector \'[\'') {
+if (%json_jpath_validate("$.foo]") != '5:Expected field specifier \'.\' or selector \'[\'') {
        test_fail
 }
 
 # 21. Expect failure - Empty selector
-if ("%{json_jpath_validate:$.foo[,}" != '6:Empty selector') {
+if (%json_jpath_validate("$.foo[,") != '6:Empty selector') {
        test_fail
 }
 
 # 22. Expect failure - Empty selector
-if ("%{json_jpath_validate:$.foo[,]}" != '6:Empty selector') {
+if (%json_jpath_validate("$.foo[,]") != '6:Empty selector') {
        test_fail
 }
 
 # 23. Expect failure - Empty selector
-if ("%{json_jpath_validate:$.foo[]}" != '6:Empty selector') {
+if (%json_jpath_validate("$.foo[]") != '6:Empty selector') {
        test_fail
 }
 
 # 24. Expect failure - Empty selector
-if ("%{json_jpath_validate:$.foo[1,1:1:2,]}" != '14:Empty selector') {
+if (%json_jpath_validate("$.foo[1,1:1:2,]") != '14:Empty selector') {
        test_fail
 }
 
 # 25. Expect failure - Bad array index
-if ("%{json_jpath_validate:$.foo[a]}" != '6:Expected num, \':\' or \']\'') {
+if (%json_jpath_validate("$.foo[a]") != '6:Expected num, \':\' or \']\'') {
        test_fail
 }
 
 # 26. Expect failure - Bad array end
-if ("%{json_jpath_validate:$.foo[0:a]}" != '8:Expected num, \':\' or \']\'') {
+if (%json_jpath_validate("$.foo[0:a]") != '8:Expected num, \':\' or \']\'') {
        test_fail
 }
 
 # 27. Expect failure - Bad array slice
-if ("%{json_jpath_validate:$.foo[0:0:a]}" != '10:Expected num or \']\'') {
+if (%json_jpath_validate("$.foo[0:0:a]") != '10:Expected num or \']\'') {
        test_fail
 }
 
 # 28. Expect failure - Bad array slice value
-if ("%{json_jpath_validate:$.foo[0:0:0]}" != '10:Step cannot be 0') {
+if (%json_jpath_validate("$.foo[0:0:0]") != '10:Step cannot be 0') {
        test_fail
 }
 
 # 29. Expect failure - Field too long
-if ("%{json_jpath_validate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" != '134:Exceeded maximum field name length') {
+if (%json_jpath_validate("$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") != '134:Exceeded maximum field name length') {
        test_fail
 }
 
 # 30. Expect success - Field ok
-if ("%{json_jpath_validate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" != '134:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') {
+if (%json_jpath_validate("$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") != '134:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') {
        test_fail
 }
 
 # 31. Expect failure - Empty field
-if ("%{json_jpath_validate:$.foo.[]}" != '6:Empty field specifier') {
+if (%json_jpath_validate("$.foo.[]") != '6:Empty field specifier') {
        test_fail
 }
 
 # 32. Expect success - Nested array
-if ("%{json_jpath_validate:$[0][1]}" != '7:$[0][1]') {
+if (%json_jpath_validate("$[0][1]") != '7:$[0][1]') {
        test_fail
 }
 
 # 33. Expect success - Nested array with multiple indicies
-if ("%{json_jpath_validate:$[0][1,2]}" != '9:$[0][1,2]') {
+if (%json_jpath_validate("$[0][1,2]") != '9:$[0][1,2]') {
        test_fail
 }
 
 # 34. Expect failure - Recursive descent followed by nothing
-if ("%{json_jpath_validate:$..}" != '2:Path may not end in recursive descent') {
+if (%json_jpath_validate("$..") != '2:Path may not end in recursive descent') {
        test_fail
 }
 
 # 35. Expect success - Recursive descent followed by field
-if ("%{json_jpath_validate:$..foo}" != '6:$..foo') {
+if (%json_jpath_validate("$..foo") != '6:$..foo') {
        test_fail
 }
 
 # 36. Expect success - Recursive descent followed by selector
-if ("%{json_jpath_validate:$..[0]}" != '6:$..[0]') {
+if (%json_jpath_validate("$..[0]") != '6:$..[0]') {
        test_fail
 }
 
 # 37. Expect success - Recursive descent followed by two selectors
-if ("%{json_jpath_validate:$..foo[0]}" != '9:$..foo[0]') {
+if (%json_jpath_validate("$..foo[0]") != '9:$..foo[0]') {
        test_fail
 }
 
 # 38. Expect success - Recursive descent followed by wildcard
-if ("%{json_jpath_validate:$..*}" != '4:$..*') {
+if (%json_jpath_validate("$..*") != '4:$..*') {
        test_fail
 }
 
 # 39. Expect failure - Filter expressions NYI
-if ("%{json_jpath_validate:$.foo[?@.bar = baz]}" != '6:Filter expressions not yet implemented') {
+if (%json_jpath_validate("$.foo[?@.bar = baz]") != '6:Filter expressions not yet implemented') {
        test_fail
 }
 
 # 40. Expect failure - Expressions NYI
-if ("%{json_jpath_validate:$.foo[(@.bar = baz)]}" != '6:Expressions not yet implemented') {
+if (%json_jpath_validate("$.foo[(@.bar = baz)]") != '6:Expressions not yet implemented') {
        test_fail
 }
 
index 36a5a3446840b6563aeeabc2bce8b0aa9f147230..59ec49a775678d32168f1a0b674a8749a000111b 100644 (file)
@@ -5,7 +5,7 @@
 #
 %file.rm("$ENV{MODULE_TEST_DIR}/test_xlat.log")
 
-if (%{linelog_fmt_delim_xlat:bob} != 5) {
+if (%linelog_fmt_delim_xlat('bob') != 5) {
        test_fail
 }
 &Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log")
@@ -20,7 +20,7 @@ else {
 &Tmp-String-1 := 'more'
 &Tmp-String-2 := 'bob'
 
-if (%{linelog_fmt_delim_xlat:%{Tmp-String-1}%{Tmp-String-2}} != 9) {
+if (%linelog_fmt_delim_xlat("%{Tmp-String-1}%{Tmp-String-2}") != 9) {
        test_fail
 }
 &Tmp-String-0 := %file.tail("$ENV{MODULE_TEST_DIR}/test_xlat.log")
@@ -36,7 +36,7 @@ else {
 
 # Try with some handcrafted JSON
 
-if (%{linelog_fmt_delim_xlat:"{ \"foo\" : \"bar\", \"baz\" : \"boink\" }"} == 36) {
+if (%linelog_fmt_delim_xlat("{ \"foo\" : \"bar\", \"baz\" : \"boink\" }") == 36) {
        test_pass
 } else {
        test_fail
index cc05ebfb0f2897dbb9f07ef4c4cf3bbabb701fbd..892474260c08e41314aea25e28c2f246e41a4517 100644 (file)
@@ -70,7 +70,7 @@ if (!(&control.Tmp-String-3[0] == 'Bob') || !(&control.Tmp-String-3[1] == 'dummy
        test_fail
 }
 
-&control.Tmp-String-2 = "%{json.encode:&NAS-IP-Address}"
+&control.Tmp-String-2 = %json.encode(&NAS-IP-Address)
 
 # POST to https with JSON body data
 &Tmp-String-2 := "%(rest:POST https://%{Tmp-String-0}:%{Tmp-Integer-1}/user/%{User-Name}/mac/%{Called-Station-Id}?section=accounting %{control.Tmp-String-2})"
index 1348ca84ed6756a01142fbfc6e9d99b9f9eda9f8..2a60b1f2f536b0a2b4fe57ea5068fbfe9a082dda 100644 (file)
@@ -14,10 +14,10 @@ match %{(%{User-Name} || "bar")}
 xlat foo %{%{User-Name} || 'bar'} baz
 match foo %{(%{User-Name} || 'bar')} baz
 
-xlat %{%{test:bar} || %{User-Name}}
+xlat %{%test(bar) || %{User-Name}}
 match %{(%test(bar) || %{User-Name})}
 
-xlat %{%{test:bar} || %{%{User-Name} || 'bar'}}
+xlat %{%test(bar) || %{%{User-Name} || 'bar'}}
 match %{(%test(bar) || %{(%{User-Name} || 'bar')})}
 
 xlat %{%{User-Name} || }
@@ -29,7 +29,7 @@ match ERROR offset 23: No operand found.  Expected &ref, literal, 'quoted litera
 xlat %{%{%{User-Name} || 'foo'} || 'bar'}
 match %{(%{(%{User-Name} || 'foo')} || 'bar')}
 
-xlat %{%{%{User-Name} || 'foo'} || %{%{test:bar} || %{User-Name}}}
+xlat %{%{%{User-Name} || 'foo'} || %{%test(bar) || %{User-Name}}}
 match %{(%{(%{User-Name} || 'foo')} || %{(%test(bar) || %{User-Name})})}
 
 xlat %{ || }
index ab971df0103c7241d5524ca9ca5b0b36a6487a7a..bc63b10f60d85df2114155ef539af1cbd8da27d5 100644 (file)
@@ -187,15 +187,15 @@ match ERROR offset 7: Unexpected text - attribute names must prefixed with '&'
 xlat %{foo bar}
 match ERROR offset 7: Invalid operator
 
-xlat %{test:
-match ERROR offset 8: Missing closing brace
+xlat %test(
+match ERROR offset 7: Missing closing brace
 
-xlat %{test:%{User-Name
-match ERROR offset 19: Missing closing brace
+xlat %test(%{User-Name)
+match ERROR offset 18: Unexpected text - attribute names must prefixed with '&'
 
 # Discuss - Not sure the offset/message is correct here, but not sure if we can determine the correct offset either
-xlat %{test:%{User-Name}
-match ERROR offset 20: Missing closing brace
+xlat %test(%{User-Name}
+match ERROR offset 19: Unexpected text after argument 1
 
 xlat %{myfirstxlat
 match ERROR offset 14: Missing closing brace
@@ -241,17 +241,20 @@ match ERROR offset 44: Unexpected text after enum value.  Expected operator
 xlat_argv echo hello %{Tmp-String-0}:1234 world
 match [0]{ echo }, [1]{ hello }, [2]{ %{Tmp-String-0}:1234 }, [3]{ world }
 
-xlat %(debug: 5)
-match %debug(5)
+xlat %debug(5)
+match %debug(5)
 
-xlat %(debug: "foo")
-match %debug(, "foo")
+xlat %debug( 5)
+match %debug(5)
+
+xlat %debug("foo")
+match %debug("foo")
 
 #
 #  This is correct.
 #
-xlat %(rpad:&User-Name 5 x)
-match %rpad(&User-Name, 5, x)
+xlat %rpad(&User-Name, 5, 'x')
+match %rpad(&User-Name, 5, 'x')
 
 #
 #  The second argument should be an integer.
@@ -259,8 +262,8 @@ match %rpad(&User-Name, 5, x)
 #  @todo - parsing - we don't currently track string offsets for intermediate nodes,
 #  so the "offset 23" is wrong.  It also doesn't say *which* string is wrong.  We'll fix that later.
 #
-xlat %(rpad:&User-Name foo x)
-match ERROR offset 24: Failed parsing argument 1 as type 'uint64'
+xlat %rpad(&User-Name, foo, 'x')
+match ERROR offset 28: Failed parsing argument 1 as type 'uint64'
 
 #
 #  Argument quoting
@@ -287,4 +290,4 @@ xlat %{md5:'arg"'}
 match %md5('arg"')
 
 count
-match 157
+match 159
index 7666387e6b94eba3cdb753160a7391a9ca1aed14..b501e7d2cec7797c3f84c128a2f7b70a9c372c2b 100644 (file)
@@ -1,5 +1,5 @@
 #  this is "foo" + PRINTABLE version of the packet authentication vector
-xlat_expr "foo%{bin:000000}"
+xlat_expr "foo%bin(000000)"
 match foo\000\000\000
 
 xlat_expr 1 && 2
@@ -90,12 +90,12 @@ match 0x666f6f7f000001
 #  This just casts the octets to 'string', without
 #  any escaping.
 #
-xlat_expr "foo" + (string)%{bin:0x0001020304}
+xlat_expr "foo" + (string)%bin(0x0001020304)
 match foo\000\001\002\003\004
 
 
 # string + octets gets promoted to octets
-xlat_expr "foo" + %{bin:0x0001020304}
+xlat_expr "foo" + %bin(0x0001020304)
 match 0x666f6f0001020304
 
 # no escaping!