You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tests/modules/json/encode.unlang
+55-55Lines changed: 55 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -6,152 +6,152 @@ string test_string5
6
6
#
7
7
# json.encode tests
8
8
#
9
-
request -= Packet-Type[*]
9
+
&request -= &Packet-Type[*]
10
10
11
11
#
12
12
# HACK: the edit code does not currently support deleted by parent
13
-
# when doing request -= Net[*]
14
-
# or even request -= Net.[*]
13
+
# when doing &request -= &Net[*]
14
+
# or even &request -= &Net.[*]
15
15
# which returns an error?
16
16
#
17
-
request -= Net.Src.IP
18
-
request -= Net.Src.Port
19
-
request -= Net.Dst.IP
20
-
request -= Net.Dst.Port
21
-
request -= Net.Timestamp
22
-
request -= Net[*]
17
+
&request -= &Net.Src.IP
18
+
&request -= &Net.Src.Port
19
+
&request -= &Net.Dst.IP
20
+
&request -= &Net.Dst.Port
21
+
&request -= &Net.Timestamp
22
+
&request -= &Net[*]
23
23
24
24
# 0. Check basic xlat parsing
25
-
test_string1 := %json.encode("request.[*]")
26
-
test_string2 := %json.encode("request.[*] ")
27
-
test_string3 := %json.encode(" request.[*]")
28
-
test_string4 := %json.encode(" request.[*] ")
25
+
&test_string1 := %json.encode("&request.[*]")
26
+
&test_string2 := %json.encode("&request.[*] ")
27
+
&test_string3 := %json.encode(" &request.[*]")
28
+
&test_string4 := %json.encode(" &request.[*] ")
29
29
30
-
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"}}')) {
30
+
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"}}')) {
31
31
test_fail
32
32
}
33
33
34
34
# Check xlat input formats
35
-
if (!(test_string1 == test_string2) ||
36
-
!(test_string1 == test_string3) ||
37
-
!(test_string1 == test_string4)) {
35
+
if (!(&test_string1 == &test_string2) ||
36
+
!(&test_string1 == &test_string3) ||
37
+
!(&test_string1 == &test_string4)) {
38
38
test_fail
39
39
}
40
40
41
41
# Check defaults are the same as output_mode "object":
if !(test_string1 == '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
if !(&test_string1 == '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
51
51
test_fail
52
52
}
53
53
54
-
test_string1 := %json.encode("request.[*] ! ")
55
-
if test_string1 {
54
+
&test_string1 := %json.encode("&request.[*] ! ")
55
+
if &test_string1 {
56
56
test_fail
57
57
}
58
58
59
59
# 1a. Output mode "object" tests
60
60
61
61
# These are unsorted dictionaries. Hopefully json-c doesn't suddenly
62
62
# decide that it's going to use a different ordering of the keys...
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"}}') {
66
+
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"}}') {
67
67
test_fail
68
68
}
69
69
70
70
"%{test_string2}"
71
-
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"]}}') {
71
+
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"]}}') {
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"}]') {
105
+
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"}]') {
106
106
test_fail
107
107
}
108
108
109
-
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"]}]') {
109
+
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"]}]') {
0 commit comments