+string test_string1
+string test_string2
+string test_string3
+string test_string4
+string test_string5
#
# json.encode tests
#
&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.[*] ! ")
-# 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.[*]")
+&test_string1 := %json.encode("&request.[*]")
+&test_string2 := %json.encode("&request.[*] ")
+&test_string3 := %json.encode(" &request.[*]")
+&test_string4 := %json.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"}}')) {
+if (!(&test_string1 == '{"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
}
# Check xlat input formats
-if (!(&control.Tmp-String-1 == &control.Tmp-String-2) ||
- !(&control.Tmp-String-1 == &control.Tmp-String-3) ||
- !(&control.Tmp-String-1 == &control.Tmp-String-4)) {
+if (!(&test_string1 == &test_string2) ||
+ !(&test_string1 == &test_string3) ||
+ !(&test_string1 == &test_string4)) {
test_fail
}
-# Check defaults
-if (!(&control.Tmp-String-1 == &control.Tmp-String-7) ||
- !(&control.Tmp-String-1 == &control.Tmp-String-8)) {
+# Check defaults are the same as output_mode "object":
+&test_string2 := %json_object.encode("&request.[*]")
+&test_string3 := %json_object_no.encode("&request.[*]")
+if (!(&test_string1 == &test_string2) ||
+ !(&test_string1 == &test_string3)) {
test_fail
}
-if !(&control.Tmp-String-5 == '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
+&test_string1 := %json.encode(" &request.[*] !&Filter-Id ")
+if !(&test_string1 == '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
test_fail
}
-if &control.Tmp-String-6 {
+&test_string1 := %json.encode("&request.[*] ! ")
+if &test_string1 {
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.[*]")
+&test_string1 := %json_object.encode("&request.[*]")
+&test_string2 := %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"}}') {
+if !(&test_string1 == '{"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
}
-"%{control.Tmp-String-2}"
-if !(&control.Tmp-String-2 == '{"pf:User-Name":{"type":"string","value":["john"]},"pf:Filter-Id":{"type":"string","value":["f1","f2"]},"pf:NAS-Port":{"type":"uint32","value":["999"]},"pf:Service-Type":{"type":"uint32","value":["1"]}}') {
+"%{test_string2}"
+if !(&test_string2 == '{"pf:User-Name":{"type":"string","value":["john"]},"pf:Filter-Id":{"type":"string","value":["f1","f2"]},"pf:NAS-Port":{"type":"uint32","value":["999"]},"pf:Service-Type":{"type":"uint32","value":["1"]}}') {
test_fail
}
# 1b. "object" empty inputs
-&control.Tmp-String-1 := %json_object.encode("!&request.[*]")
+&test_string1 := %json_object.encode("!&request.[*]")
-if !(&control.Tmp-String-1 == '{}') {
+if !(&test_string1 == '{}') {
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.[*]")
+&test_string1 := %json_object_simple.encode("&request.[*]")
+&test_string2 := %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"}') {
+if !(&test_string1 == '{"User-Name":"john","Filter-Id":["f1","f2"],"NAS-Port":999,"Service-Type":"Login-User"}') {
test_fail
}
-if !(&control.Tmp-String-2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2"],"pf:NAS-Port":["999"],"pf:Service-Type":["1"]}') {
+if !(&test_string2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2"],"pf:NAS-Port":["999"],"pf:Service-Type":["1"]}') {
test_fail
}
# 2b. "object_simple" empty inputs
-&control.Tmp-String-1 := %json_object_simple.encode("!&request.[*]")
+&test_string1 := %json_object_simple.encode("!&request.[*]")
-if !(&control.Tmp-String-1 == '{}') {
+if !(&test_string1 == '{}') {
test_fail
}
# 3a. Output mode "array" tests
-&control.Tmp-String-1 := %json_array.encode("&request.[*]")
-&control.Tmp-String-2 := %json_array_ex.encode("&request.[*]")
+&test_string1 := %json_array.encode("&request.[*]")
+&test_string2 := %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"}]') {
+if !(&test_string1 == '[{"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
}
-if !(&control.Tmp-String-2 == '[{"name":"pf:User-Name","type":"string","value":["john"]},{"name":"pf:Filter-Id","type":"string","value":["f1","f2"]},{"name":"pf:NAS-Port","type":"uint32","value":["999"]},{"name":"pf:Service-Type","type":"uint32","value":["1"]}]') {
+if !(&test_string2 == '[{"name":"pf:User-Name","type":"string","value":["john"]},{"name":"pf:Filter-Id","type":"string","value":["f1","f2"]},{"name":"pf:NAS-Port","type":"uint32","value":["999"]},{"name":"pf:Service-Type","type":"uint32","value":["1"]}]') {
test_fail
}
# 3b. "array" empty inputs
-&control.Tmp-String-1 := %json_array.encode("!&request.[*]")
+&test_string1 := %json_array.encode("!&request.[*]")
-if !(&control.Tmp-String-1 == '[]') {
+if !(&test_string1 == '[]') {
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.[*]")
+&test_string1 := %json_array_names.encode("&request.[*]")
+&test_string2 := %json_array_names_ex.encode("&request.[*]")
-if !(&control.Tmp-String-1 == '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
+if !(&test_string1 == '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
test_fail
}
-if !(&control.Tmp-String-2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf:NAS-Port","pf:Service-Type"]') {
+if !(&test_string2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf:NAS-Port","pf:Service-Type"]') {
test_fail
}
# 4b. "array_of_names" empty inputs
-&control.Tmp-String-1 := %json_array_names.encode("!&request.[*]")
+&test_string1 := %json_array_names.encode("!&request.[*]")
-if !(&control.Tmp-String-1 == '[]') {
+if !(&test_string1 == '[]') {
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.[*]")
+&test_string1 := %json_array_values.encode("&request.[*]")
+&test_string2 := %json_array_values_ex.encode("&request.[*]")
-if !(&control.Tmp-String-1 == '["john","f1","f2",999,"Login-User"]') {
+if !(&test_string1 == '["john","f1","f2",999,"Login-User"]') {
test_fail
}
-if !(&control.Tmp-String-2 == '["john","f1","f2","999","1"]') {
+if !(&test_string2 == '["john","f1","f2","999","1"]') {
test_fail
}
# 5b. "array_of_values" empty inputs
-&control.Tmp-String-1 := %json_array_values.encode("!&request.[*]")
+&test_string1 := %json_array_values.encode("!&request.[*]")
-if !(&control.Tmp-String-1 == '[]') {
+if !(&test_string1 == '[]') {
test_fail
}
#
# Evaluation tests
#
+uint32 test_integer
+int64 test_int64
+string test_string
-&Tmp-String-0 := "{\"foo\":\"bar\"}"
+&Filter-Id := "{\"foo\":\"bar\"}"
# 0. Simple field access
-map json &Tmp-String-0 {
- &Tmp-String-1 := '$.foo'
+map json &Filter-Id {
+ &Callback-Id := '$.foo'
}
-if !(&Tmp-String-1 == 'bar') {
+if !(&Callback-Id == 'bar') {
test_fail
}
-&Tmp-String-0 := "\
+&Filter-Id := "\
{\
\"my_array\": [0, 1, 2, 3, 4, 5], \
\"my_object\": { \
\"bool_false\": false \
}"
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Check conversion of all JSON types to strings
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$.*'
+map json &Filter-Id {
+ &Callback-Id += '$.*'
}
# 1. Array type
-if !(&Tmp-String-1[0] == '[ 0, 1, 2, 3, 4, 5 ]') {
+if !(&Callback-Id[0] == '[ 0, 1, 2, 3, 4, 5 ]') {
test_fail
}
# 2. Object type
-if !(&Tmp-String-1[1] == '{ "foo": "bar", "num": 42 }') {
+if !(&Callback-Id[1] == '{ "foo": "bar", "num": 42 }') {
test_fail
}
# 3. Integer type
-if !(&Tmp-String-1[2] == '99') {
+if !(&Callback-Id[2] == '99') {
test_fail
}
# 4. Double type
-if !(&Tmp-String-1[3] == '5.9') {
+if !(&Callback-Id[3] == '5.9') {
test_fail
}
# 5. null type
-if !(&Tmp-String-1[4] == 'null') {
+if !(&Callback-Id[4] == 'null') {
test_fail
}
# 6. Boolean true
-if !(&Tmp-String-1[5] == 'yes') {
+if !(&Callback-Id[5] == 'yes') {
test_fail
}
# 7. Boolean false
-if (&Tmp-String-1[6] != 'no') {
+if (&Callback-Id[6] != 'no') {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
#
# Now check array slicing operates correctly
#
# 8. String form
-map json &Tmp-String-0 {
- &Tmp-String-1 := '$.my_array'
+map json &Filter-Id {
+ &Callback-Id := '$.my_array'
}
-if !(&Tmp-String-1 == '[ 0, 1, 2, 3, 4, 5 ]') {
+if !(&Callback-Id == '[ 0, 1, 2, 3, 4, 5 ]') {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# 9. Simple index
-map json &Tmp-String-0 {
- &Tmp-Integer-0 := '$.my_array[0]'
+map json &Filter-Id {
+ &NAS-Port := '$.my_array[0]'
}
-if !(&Tmp-Integer-0 == 0) {
+if !(&NAS-Port == 0) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 9a. All of the array
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array.*'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array.*'
}
-if (!(&Tmp-Integer-0[0] == 0) || !(&Tmp-Integer-0[1] == 1) || !(&Tmp-Integer-0[2] == 2) || !(&Tmp-Integer-0[3] == 3) || !(&Tmp-Integer-0[4] == 4) || !(&Tmp-Integer-0[5] == 5)) {
+if (!(&NAS-Port[0] == 0) || !(&NAS-Port[1] == 1) || !(&NAS-Port[2] == 2) || !(&NAS-Port[3] == 3) || !(&NAS-Port[4] == 4) || !(&NAS-Port[5] == 5)) {
test_fail
}
-&Tmp-Integer-0 := 9
+&NAS-Port := 9
# 9b. All of the array using prepend, places the array before the existing value
-map json &Tmp-String-0 {
- &Tmp-Integer-0 ^= '$.my_array.*'
+map json &Filter-Id {
+ &NAS-Port ^= '$.my_array.*'
}
-if (!(&Tmp-Integer-0[0] == 0) || !(&Tmp-Integer-0[1] == 1) || !(&Tmp-Integer-0[2] == 2) || !(&Tmp-Integer-0[3] == 3) || !(&Tmp-Integer-0[4] == 4) || !(&Tmp-Integer-0[5] == 5) || !(&Tmp-Integer-0[6] == 9)) {
+if (!(&NAS-Port[0] == 0) || !(&NAS-Port[1] == 1) || !(&NAS-Port[2] == 2) || !(&NAS-Port[3] == 3) || !(&NAS-Port[4] == 4) || !(&NAS-Port[5] == 5) || !(&NAS-Port[6] == 9)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 10. End of the array
-map json &Tmp-String-0 {
- &Tmp-Integer-0 := '$.my_array[5]' # Past the end of the array (should be skipped)
+map json &Filter-Id {
+ &NAS-Port := '$.my_array[5]' # Past the end of the array (should be skipped)
}
-if !(&Tmp-Integer-0 == 5) {
+if !(&NAS-Port == 5) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 11. Past end of the array
-map json &Tmp-String-0 {
- &Tmp-Integer-0 := '$.my_array[6]' # Past the end of the array (should be skipped)
+map json &Filter-Id {
+ &NAS-Port := '$.my_array[6]' # Past the end of the array (should be skipped)
}
-if (&Tmp-Integer-0) {
+if (&NAS-Port) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 12. Simple slice
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[0:2]' # A single value
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[0:2]' # A single value
}
-if (!(&Tmp-Integer-0[0] == 0) || !(&Tmp-Integer-0[1] == 1)) {
+if (!(&NAS-Port[0] == 0) || !(&NAS-Port[1] == 1)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 13. Slice with negative start
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[-1:6]' # A single value (last eelement of the array)
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[-1:6]' # A single value (last eelement of the array)
}
-if !(&Tmp-Integer-0 == 5) {
+if !(&NAS-Port == 5) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 14. Slice with negative start and negative end
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[-1:-3]' # Start after end (should be skipped)
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[-1:-3]' # Start after end (should be skipped)
}
-if (&Tmp-Integer-0) {
+if (&NAS-Port) {
test_fail
}
# 15. Slice with start and negative end
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[1:-3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[1:-3]'
}
-if (!(&Tmp-Integer-0[0] == 1) && !(&Tmp-Integer-0[1] == 2)) {
+if (!(&NAS-Port[0] == 1) && !(&NAS-Port[1] == 2)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 16. Slice with start, end and negative step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[4:2:-1]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[4:2:-1]'
}
-if (!(&Tmp-Integer-0[0] == 4) || !(&Tmp-Integer-0[1] == 3)) {
+if (!(&NAS-Port[0] == 4) || !(&NAS-Port[1] == 3)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 17. Slice with start, end (inverted) and negative step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[2:4:-1]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[2:4:-1]'
}
-if (&Tmp-Integer-0) {
+if (&NAS-Port) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 18. Slice with start, end and positive step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[2:4:1]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[2:4:1]'
}
-if (!(&Tmp-Integer-0[0] == 2) || !(&Tmp-Integer-0[1] == 3)) {
+if (!(&NAS-Port[0] == 2) || !(&NAS-Port[1] == 3)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 19. Slice with start, end and positive step > 1
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[1:5:2]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[1:5:2]'
}
-if (!(&Tmp-Integer-0[0] == 1) && !(&Tmp-Integer-0[1] == 3)) {
+if (!(&NAS-Port[0] == 1) && !(&NAS-Port[1] == 3)) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 20. Slice with start, end and positive step > end of array
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[1:5:4]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[1:5:4]'
}
-if (!(&Tmp-Integer-0[0] == 1) || &Tmp-Integer-0[1]) {
+if (!(&NAS-Port[0] == 1) || &NAS-Port[1]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 21. Slice with start, end and positive step > end of array
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[5:1:-4]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[5:1:-4]'
}
-if (!(&Tmp-Integer-0[0] == 5) || &Tmp-Integer-0[1]) {
+if (!(&NAS-Port[0] == 5) || &NAS-Port[1]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 22. No start/end 3 step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[::3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[::3]'
}
-if (!(&Tmp-Integer-0[0] == 0) || !(&Tmp-Integer-0[1] == 3) || &Tmp-Integer-0[2]) {
+if (!(&NAS-Port[0] == 0) || !(&NAS-Port[1] == 3) || &NAS-Port[2]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 23. No start/end 3 step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[::-3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[::-3]'
}
-if (!(&Tmp-Integer-0[0] == 5) || !(&Tmp-Integer-0[1] == 2) || &Tmp-Integer-0[2]) {
+if (!(&NAS-Port[0] == 5) || !(&NAS-Port[1] == 2) || &NAS-Port[2]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 24. No end 3 step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[3::-3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[3::-3]'
}
-if (!(&Tmp-Integer-0[0] == 3) || !(&Tmp-Integer-0[1] == 0) || &Tmp-Integer-0[2]) {
+if (!(&NAS-Port[0] == 3) || !(&NAS-Port[1] == 0) || &NAS-Port[2]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 25. End 0, 3 step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[3:0:-3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[3:0:-3]'
}
-if (!(&Tmp-Integer-0[0] == 3) || &Tmp-Integer-0[1]) {
+if (!(&NAS-Port[0] == 3) || &NAS-Port[1]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 26. End 0, 3 step
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += '$.my_array[0::-3]'
+map json &Filter-Id {
+ &NAS-Port += '$.my_array[0::-3]'
}
-if (!(&Tmp-Integer-0[0] == 0) || &Tmp-Integer-0[1]) {
+if (!(&NAS-Port[0] == 0) || &NAS-Port[1]) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 27. Everything two levels deep
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$.*.*'
+map json &Filter-Id {
+ &Callback-Id += '$.*.*'
}
-if (!(&Tmp-String-1[0] == '0') || \
- !(&Tmp-String-1[1] == '1') || \
- !(&Tmp-String-1[2] == '2') || \
- !(&Tmp-String-1[3] == '3') || \
- !(&Tmp-String-1[4] == '4') || \
- !(&Tmp-String-1[5] == '5') || \
- !(&Tmp-String-1[6] == 'bar') || \
- !(&Tmp-String-1[7] == '42')) {
+if (!(&Callback-Id[0] == '0') || \
+ !(&Callback-Id[1] == '1') || \
+ !(&Callback-Id[2] == '2') || \
+ !(&Callback-Id[3] == '3') || \
+ !(&Callback-Id[4] == '4') || \
+ !(&Callback-Id[5] == '5') || \
+ !(&Callback-Id[6] == 'bar') || \
+ !(&Callback-Id[7] == '42')) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# 28. Everything three levels deep (nothing)
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$.*.*.*'
+map json &Filter-Id {
+ &Callback-Id += '$.*.*.*'
}
-if (&Tmp-String-1) {
+if (&Callback-Id) {
test_fail
}
# 29. Array access on a field (nothing)
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$.my_object[0]'
+map json &Filter-Id {
+ &Callback-Id += '$.my_object[0]'
}
-if (&Tmp-String-1) {
+if (&Callback-Id) {
test_fail
}
# 30. Non-existent field
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$.my_object.my_other_object'
+map json &Filter-Id {
+ &Callback-Id += '$.my_object.my_other_object'
}
-if (&Tmp-String-1) {
+if (&Callback-Id) {
test_fail
}
# Some big numbers in nested arrays
-&Tmp-String-0 := "\
+&Filter-Id := "\
[\
9223372036854775807, \
-9223372036854775807, \
# version/system dependent *sigh*.
redundant {
group {
- map json &Tmp-String-0 {
- &Tmp-Integer-0 := '$[3][2]'
+ map json &Filter-Id {
+ &NAS-Port := '$[3][2]'
}
}
noop
}
-if (!noop && (!(&Tmp-Integer-0 == 4294967295) && !(&Tmp-Integer-0 == 2147483647))) {
+if (!noop && (!(&NAS-Port == 4294967295) && !(&NAS-Port == 2147483647))) {
test_fail
}
# 32. Unsigned 32bit integers (are supported)
-map json &Tmp-String-0 {
- &Tmp-Integer-0 := '$[3][0]'
+map json &Filter-Id {
+ &NAS-Port := '$[3][0]'
}
-if !(&Tmp-Integer-0 == 2147483647) {
+if !(&NAS-Port == 2147483647) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 33. Signed 64bit integers
if (0) {
-map json &Tmp-String-0 {
- &Tmp-int64-0 := '$[0]'
+map json &Filter-Id {
+ &test_int64 := '$[0]'
}
-if !(&Tmp-int64-0 == (int64)9223372036854775807) {
+if !(&test_int64 == (int64)9223372036854775807) {
test_fail
}
-&request -= &Tmp-int64-0[*]
-
# 34. Signed 64bit integers
-map json &Tmp-String-0 {
- &Tmp-int64-0 := '$[1]'
+map json &Filter-Id {
+ &test_int64 := '$[1]'
}
-if !(&Tmp-int64-0 == -9223372036854775807) {
+if !(&test_int64 == -9223372036854775807) {
test_fail
}
-&request -= &Tmp-int64-0[*]
+&request -= &test_int64[*]
# 35. Unsigned 64bit integers (not allowed by json so gets truncated)
-map json &Tmp-String-0 {
- &Tmp-uint64-0 := '$[2]'
+map json &Filter-Id {
+ &Acct-Input-Octets64 := '$[2]'
}
-if !(&Tmp-uint64-0 == 9223372036854775807) {
+if !(&Acct-Input-Octets64 == 9223372036854775807) {
test_fail
}
}
-&request -= &Tmp-uint64-0[*]
+&request -= &Acct-Input-Octets64[*]
# 36. Multiple array indices
-map json &Tmp-String-0 {
- &Tmp-Signed-0 += '$[3][0,1]'
+map json &Filter-Id {
+ &Cache-TTL += '$[3][0,1]'
}
-if (!(&Tmp-Signed-0[0] == 2147483647) || !(&Tmp-signed-0[1] == -2147483647)) {
+if (!(&Cache-TTL[0] == 2147483647) || !(&Cache-TTL[1] == -2147483647)) {
test_fail
}
-&request -= &Tmp-Signed-0[*]
+&request -= &Cache-TTL[*]
# 37. Path containing dynamic expansion
-&Tmp-Integer-2 := 0
+&test_integer := 0
-map json &Tmp-String-0 {
- &Tmp-Integer-0 += "$[3][%{Tmp-Integer-2}]"
+map json &Filter-Id {
+ &NAS-Port += "$[3][%{test_integer}]"
}
-if !(&Tmp-Integer-0 == 2147483647) {
+if !(&NAS-Port == 2147483647) {
test_fail
}
-&request -= &Tmp-Integer-0[*]
+&request -= &NAS-Port[*]
# 38. An expanded field name with bad chars
-&Tmp-String-0 := "\
+&Filter-Id := "\
{\
\"foo.bar\": \"baz\" \
}"
-&Tmp-String-2 := "%taint('foo.bar')"
+&test_string := "%taint('foo.bar')"
-map json &Tmp-String-0 {
- &Tmp-String-1 := "$.%{Tmp-String-2}"
+map json &Filter-Id {
+ &Callback-Id := "$.%{test_string}"
}
-if !(&Tmp-String-1 == 'baz') {
+if !(&Callback-Id == 'baz') {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
-&Tmp-String-0 := "\
+&Filter-Id := "\
{\
\"my_array\": [0, 1, 2, 3, 4, 5], \
\"my_object\": { \
}"
# 39. Recursive descent with field match
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$..bool'
+map json &Filter-Id {
+ &Callback-Id += '$..bool'
}
-if (!("%{Tmp-String-1[#]}" == 1) || !(&Tmp-String-1 == 'yes')) {
+if (!("%{Callback-Id[#]}" == 1) || !(&Callback-Id == 'yes')) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# 40. Recursive descent with element match (2nd element in each array)
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$..[1]'
+map json &Filter-Id {
+ &Callback-Id += '$..[1]'
}
-if (!("%{Tmp-String-1[#]}" == 3) || !(&Tmp-String-1[0] == '1') || !(&Tmp-String-1[1] == 'scratchy') || !(&Tmp-String-1[2] == 'clawy')) {
+if (!("%{Callback-Id[#]}" == 3) || !(&Callback-Id[0] == '1') || !(&Callback-Id[1] == 'scratchy') || !(&Callback-Id[2] == 'clawy')) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# 41. Recursive descent with field then element match
-map json &Tmp-String-0 {
- &Tmp-String-1 += '$..my_cats[2]'
+map json &Filter-Id {
+ &Callback-Id += '$..my_cats[2]'
}
-if (!("%{Tmp-String-1[#]}" == 2) || !(&Tmp-String-1[0] == 'flat') || !(&Tmp-String-1[1] == 'woofy')) {
+if (!("%{Callback-Id[#]}" == 2) || !(&Callback-Id[0] == 'flat') || !(&Callback-Id[1] == 'woofy')) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
test_pass