Debian Codegraph @

src/tests/keywords/update-remove-tag

raw
1 #
2 # PRE: update update-remove-value update-remove-index update-tag
3 #
4 # Remove all attributes in a list
5 #
6 update {
7 control:Cleartext-Password := 'hello'
8 reply:Filter-Id := 'filter'
9 }
10
11 update {
12 request:Tunnel-Server-Endpoint += '192.0.1.1'
13 request:Tunnel-Server-Endpoint += '192.0.1.2'
14 request:Tunnel-Server-Endpoint:1 += '192.0.1.1'
15 request:Tunnel-Server-Endpoint:2 += '192.0.2.1'
16 request:Tunnel-Server-Endpoint:2 += '192.0.2.2'
17 request:Tunnel-Server-Endpoint:3 += '192.0.3.1'
18 request:Tunnel-Server-Endpoint:3 += '192.0.3.2'
19 request:Tunnel-Server-Endpoint:3 += '192.0.3.3'
20 control: += request:
21 }
22
23 # Check [#] is working correctly (should probably be another set of tests)
24 if (("%{request:Tunnel-Server-Endpoint[#]}" != 8) || \
25 ("%{request:Tunnel-Server-Endpoint:0[#]}" != 2) || \
26 ("%{request:Tunnel-Server-Endpoint:1[#]}" != 1) || \
27 ("%{request:Tunnel-Server-Endpoint:2[#]}" != 2) || \
28 ("%{request:Tunnel-Server-Endpoint:3[#]}" != 3)) {
29 update reply {
30 Filter-Id += 'fail 0'
31 }
32 }
33
34 update {
35 Tunnel-Server-Endpoint !* ANY
36 }
37
38 # List should now be empty
39 if ("%{request:Tunnel-Server-Endpoint[#]}" != 0) {
40 update reply {
41 Filter-Id += 'fail 1'
42 }
43 }
44
45 # Reset the list
46 update {
47 request: += control:
48 }
49
50 # Now remove all Tunnel-Server-Endpoint attributes with :2
51 update {
52 Tunnel-Server-Endpoint:2 !* ANY
53 }
54
55 if (("%{request:Tunnel-Server-Endpoint[#]}" != 6) || \
56 ("%{request:Tunnel-Server-Endpoint:0[#]}" != 2) || \
57 ("%{request:Tunnel-Server-Endpoint:1[#]}" != 1) || \
58 ("%{request:Tunnel-Server-Endpoint:2[#]}" != 0) || \
59 ("%{request:Tunnel-Server-Endpoint:3[#]}" != 3)) {
60 update reply {
61 Filter-Id += 'fail 2'
62 }
63 }
64
65 # Now remove all Tunnel-Server-Endpoint attributes with :0 (no tags)
66 update {
67 Tunnel-Server-Endpoint:0 !* ANY
68 }
69
70 if (("%{request:Tunnel-Server-Endpoint[#]}" != 4) || \
71 ("%{request:Tunnel-Server-Endpoint:0[#]}" != 0) || \
72 ("%{request:Tunnel-Server-Endpoint:1[#]}" != 1) || \
73 ("%{request:Tunnel-Server-Endpoint:2[#]}" != 0) || \
74 ("%{request:Tunnel-Server-Endpoint:3[#]}" != 3)) {
75 update reply {
76 Filter-Id += 'fail 3'
77 }
78 }
79
80 # Now remove all Tunnel-Server-Endpoint attributes with :3
81 update {
82 Tunnel-Server-Endpoint:3 !* ANY
83 }
84
85 if (("%{request:Tunnel-Server-Endpoint[#]}" != 1) || \
86 ("%{request:Tunnel-Server-Endpoint:0[#]}" != 0) || \
87 ("%{request:Tunnel-Server-Endpoint:1[#]}" != 1) || \
88 ("%{request:Tunnel-Server-Endpoint:2[#]}" != 0) || \
89 ("%{request:Tunnel-Server-Endpoint:3[#]}" != 0)) {
90 update reply {
91 Filter-Id += 'fail 4'
92 }
93 }
94
95 # Now remove all Tunnel-Server-Endpoint attributes with :1
96 update {
97 Tunnel-Server-Endpoint:1 !* ANY
98 }
99
100 if (("%{request:Tunnel-Server-Endpoint[#]}" != 0) || \
101 ("%{request:Tunnel-Server-Endpoint:0[#]}" != 0) || \
102 ("%{request:Tunnel-Server-Endpoint:1[#]}" != 0) || \
103 ("%{request:Tunnel-Server-Endpoint:2[#]}" != 0) || \
104 ("%{request:Tunnel-Server-Endpoint:3[#]}" != 0)) {
105 update reply {
106 Filter-Id += 'fail 5'
107 }
108 }
109
110 # Reset the list
111 update {
112 request: += control:
113 }
114
115 # Remove all Tunnel-Server-Endpoint attributes at :3[0] (none)
116 update {
117 Tunnel-Server-Endpoint:1[3] !* ANY
118 }
119
120 if (Tunnel-Server-Endpoint:3[0] != '192.0.3.1') {
121 update reply {
122 Filter-Id += 'fail 6'
123 }
124 }
125
126 if (Tunnel-Server-Endpoint:3[1] != '192.0.3.2') {
127 update reply {
128 Filter-Id += 'fail 7'
129 }
130 }
131
132 if (Tunnel-Server-Endpoint:3[2] != '192.0.3.3') {
133 update reply {
134 Filter-Id += 'fail 8'
135 }
136 }
137
138 # Remove all Tunnel-Server-Endpoint attributes at :3[1]
139 update {
140 Tunnel-Server-Endpoint:3[1] !* ANY
141 }
142
143 if (Tunnel-Server-Endpoint:3[0] != '192.0.3.1') {
144 update reply {
145 Filter-Id += 'fail 9'
146 }
147 }
148
149 if (Tunnel-Server-Endpoint:3[1] != '192.0.3.3') {
150 update reply {
151 Filter-Id += 'fail 10'
152 }
153 }
154
155 # Remove any Tunnel-Server-Endpoint with a value of '192.0.1.1' (should remove both tagged and untagged versions)
156 update {
157 Tunnel-Server-Endpoint -= '192.0.1.1'
158 }
159
160 # Also checks whether presence checks for tagged attributes work correctly
161 if (request:Tunnel-Server-Endpoint:1) {
162 update reply {
163 Filter-Id += 'fail 11'
164 }
165 }
166
167 if (request:Tunnel-Server-Endpoint:0[0] != '192.0.1.2') {
168 update reply {
169 Filter-Id += 'fail 12'
170 }
171 }
172
173 # Remove any Tunnel-Server-Endpoint with a value of '192.0.3.1'
174 update {
175 Tunnel-Server-Endpoint:3 -= '192.0.3.2'
176 }
177
178 if (request:Tunnel-Server-Endpoint:3[0] != '192.0.3.1') {
179 update reply {
180 Filter-Id += 'fail 13'
181 }
182 }
183
184 if (request:Tunnel-Server-Endpoint:3[1] != '192.0.3.3') {
185 update reply {
186 Filter-Id += 'fail 14'
187 }
188 }
189
190 # Reset the list
191 update {
192 request: !* ANY
193 }
194 update {
195 request: += control:
196 }
197
198 # Remove only the tagged version of '192.0.1.1'
199 update {
200 request:Tunnel-Server-Endpoint:1 -= '192.0.1.1'
201 }
202
203 if (request:Tunnel-Server-Endpoint:0[0] != '192.0.1.1') {
204 update reply {
205 Filter-Id += 'fail 15'
206 }
207 }
208
209 # Reset the list
210 update {
211 request: !* ANY
212 }
213 update {
214 request: += control:
215 }
216
217 # Remove only the untagged version of '192.0.1.1'
218 update {
219 request:Tunnel-Server-Endpoint:0 -= '192.0.1.1'
220 }
221
222 if (request:Tunnel-Server-Endpoint:1[0] != '192.0.1.1') {
223 update reply {
224 Filter-Id += 'fail 16'
225 }
226 }
227
228 # Remove the value of Tunnel-Server-Endpoint:3 at index 1 only if it matches '192.0.3.3' (which it does)
229 update {
230 Tunnel-Server-Endpoint:3[1] -= '192.0.3.2'
231 }
232
233 if (Tunnel-Server-Endpoint:3[0] != '192.0.3.1') {
234 update reply {
235 Filter-Id += 'fail 17'
236 }
237 }
238
239 if (Tunnel-Server-Endpoint:3[1] != '192.0.3.3') {
240 update reply {
241 Filter-Id += 'fail 18'
242 }
243 }
244
245 # Reset the list
246 update {
247 request: !* ANY
248 }
249 update {
250 request: += control:
251 }
252
253 # Remove the value of Tunnel-Server-Endpoint:3 at index 1 only if it matches '192.0.3.4' (which it doesn't)
254 update {
255 Tunnel-Server-Endpoint:3[1] -= '192.0.3.4'
256 }
257
258 if (Tunnel-Server-Endpoint:3[0] != '192.0.3.1') {
259 update reply {
260 Filter-Id += 'fail 19'
261 }
262 }
263
264 if (Tunnel-Server-Endpoint:3[1] != '192.0.3.2') {
265 update reply {
266 Filter-Id += 'fail 20'
267 }
268 }
269
270 if (Tunnel-Server-Endpoint:3[2] != '192.0.3.3') {
271 update reply {
272 Filter-Id += 'fail 21'
273 }
274 }
275