# = 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
}
&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
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
#
# 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
# 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
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
&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
#
# 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
# 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
# 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
#
# 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
# 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
&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
test_fail
}
-if !(&control.Tmp-String-6 == "") {
+if &control.Tmp-String-6 {
test_fail
}
# 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
}
# 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
}
# 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
}
# 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
}
# 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
}
# 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
# 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
}
#
# 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
}
#
%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")
&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")
# 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
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})"
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} || }
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 %{ || }
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
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.
# @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
match %md5('arg"')
count
-match 157
+match 159
# 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
# 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!