Repository navigation
Expand file tree
/
Copy pathfields.feature
More file actions
371 lines (240 loc) · 13 KB
/
Copy pathfields.feature
File metadata and controls
371 lines (240 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
@conformance
Feature: fields
Tests for field access in maps.
# map_fields -- select an element in a map
Scenario: map_fields/map_key_int64
When CEL expression '{0:1,2:2,5:true}[5]' is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: map_fields/map_key_uint64
When CEL expression "{0u:1u,2u:'happy',5u:3u}[2u]" is evaluated
Then value is celpy.celtypes.StringType(source='happy')
Scenario: map_fields/map_key_string
When CEL expression "{'name':100u}['name']" is evaluated
Then value is celpy.celtypes.UintType(source=100)
Scenario: map_fields/map_key_bool
When CEL expression '{true:5}[true]' is evaluated
Then value is celpy.celtypes.IntType(source=5)
Scenario: map_fields/map_key_mixed_type
When CEL expression '{true:1,2:2,5u:3}[true]' is evaluated
Then value is celpy.celtypes.IntType(source=1)
@wip
Scenario: map_fields/map_key_mixed_numbers_double_key
When CEL expression '{1u: 1.0, 2: 2.0, 3u: 3.0}[3.0]' is evaluated
Then value is celpy.celtypes.DoubleType(source=3.0)
Scenario: map_fields/map_key_mixed_numbers_lossy_double_key
When CEL expression '{1u: 1.0, 2: 2.0, 3u: 3.0}[3.1]' is evaluated
Then eval_error is 'no such key'
@wip
Scenario: map_fields/map_key_mixed_numbers_uint_key
When CEL expression '{1u: 1.0, 2: 2.0, 3u: 3.0}[2u]' is evaluated
Then value is celpy.celtypes.DoubleType(source=2.0)
@wip
Scenario: map_fields/map_key_mixed_numbers_int_key
When CEL expression '{1u: 1.0, 2: 2.0, 3u: 3.0}[1]' is evaluated
Then value is celpy.celtypes.DoubleType(source=1.0)
Scenario: map_fields/map_field_access
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'name': celpy.celtypes.IntType(source=1024)})
When CEL expression 'x.name' is evaluated
Then value is celpy.celtypes.IntType(source=1024)
Scenario: map_fields/map_no_such_key
When CEL expression '{0:1,2:2,5:3}[1]' is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_no_such_key_or_false
When CEL expression 'dyn({0:1,2:2,5:3}[1]) || false' is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_no_such_key_or_true
When CEL expression 'dyn({0:1,2:2,5:3}[1]) || true' is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: map_fields/map_no_such_key_and_false
When CEL expression 'dyn({0:1,2:2,5:3}[1]) && false' is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: map_fields/map_no_such_key_and_true
When CEL expression 'dyn({0:1,2:2,5:3}[1]) && true' is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_bad_key_type
When CEL expression "{0:1,2:2,5:3}[dyn(b'')]" is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_bad_key_type_or_false
When CEL expression "dyn({0:1,2:2,5:3}[dyn(b'')]) || false" is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_bad_key_type_or_true
When CEL expression "dyn({0:1,2:2,5:3}[dyn(b'')]) || true" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: map_fields/map_bad_key_type_and_false
When CEL expression "dyn({0:1,2:2,5:3}[dyn(b'')]) && false" is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: map_fields/map_bad_key_type_and_true
When CEL expression "dyn({0:1,2:2,5:3}[dyn(b'')]) && true" is evaluated
Then eval_error is 'no such key'
Scenario: map_fields/map_field_select_no_such_key
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'holiday': celpy.celtypes.StringType(source='field')})
When CEL expression 'x.name' is evaluated
Then eval_error is "no such key: 'name'"
Scenario: map_fields/map_field_select_no_such_key_or_false
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'holiday': celpy.celtypes.StringType(source='field')})
When CEL expression 'dyn(x.name) || false' is evaluated
Then eval_error is "no such key: 'name'"
Scenario: map_fields/map_field_select_no_such_key_or_true
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'holiday': celpy.celtypes.StringType(source='field')})
When CEL expression 'dyn(x.name) || true' is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: map_fields/map_field_select_no_such_key_and_false
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'holiday': celpy.celtypes.StringType(source='field')})
When CEL expression 'dyn(x.name) && false' is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: map_fields/map_field_select_no_such_key_and_true
Given type_env parameter "x" is celpy.celtypes.MapType
and bindings parameter "x" is celpy.celtypes.MapType({'holiday': celpy.celtypes.StringType(source='field')})
When CEL expression 'dyn(x.name) && true' is evaluated
Then eval_error is "no such key: 'name'"
Scenario: map_fields/map_value_null
When CEL expression '{true:null}[true]' is evaluated
Then value is None
Scenario: map_fields/map_value_bool
When CEL expression '{27:false}[27]' is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: map_fields/map_value_string
When CEL expression "{'n':'x'}['n']" is evaluated
Then value is celpy.celtypes.StringType(source='x')
Scenario: map_fields/map_value_float
When CEL expression '{3:15.15}[3]' is evaluated
Then value is celpy.celtypes.DoubleType(source=15.15)
Scenario: map_fields/map_value_uint64
When CEL expression '{0u:1u,2u:2u,5u:3u}[0u]' is evaluated
Then value is celpy.celtypes.UintType(source=1)
Scenario: map_fields/map_value_int64
When CEL expression '{true:1,false:2}[true]' is evaluated
Then value is celpy.celtypes.IntType(source=1)
Scenario: map_fields/map_value_bytes
When CEL expression "{0:b''}[0]" is evaluated
Then value is celpy.celtypes.BytesType(source=b'')
Scenario: map_fields/map_value_list
When CEL expression '{0u:[1]}[0u]' is evaluated
Then value is [celpy.celtypes.IntType(source=1)]
Scenario: map_fields/map_value_map
When CEL expression "{'map': {'k': 'v'}}['map']" is evaluated
Then value is celpy.celtypes.MapType({'k': celpy.celtypes.StringType(source='v')})
Scenario: map_fields/map_value_mix_type
When CEL expression "{'map': {'k': 'v'}, 'list': [1]}['map']" is evaluated
Then value is celpy.celtypes.MapType({'k': celpy.celtypes.StringType(source='v')})
# map_has -- Has macro for map entries.
Scenario: map_has/has
When CEL expression "has({'a': 1, 'b': 2}.a)" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: map_has/has_not
When CEL expression "has({'a': 1, 'b': 2}.c)" is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: map_has/has_empty
When CEL expression 'has({}.a)' is evaluated
Then value is celpy.celtypes.BoolType(source=False)
# quoted_map_fields -- Field accesses using the quote syntax
@wip
Scenario: quoted_map_fields/field_access_slash
When CEL expression "{'/api/v1': true, '/api/v2': false}.`/api/v1`" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
@wip
Scenario: quoted_map_fields/field_access_dash
When CEL expression "{'content-type': 'application/json', 'content-length': 145}.`content-type` == 'application/json'" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
@wip
Scenario: quoted_map_fields/field_access_dot
When CEL expression "{'foo.txt': 32, 'bar.csv': 1024}.`foo.txt`" is evaluated
Then value is celpy.celtypes.IntType(source=32)
@wip
Scenario: quoted_map_fields/has_field_slash
When CEL expression "has({'/api/v1': true, '/api/v2': false}.`/api/v3`)" is evaluated
Then value is celpy.celtypes.BoolType(source=False)
@wip
Scenario: quoted_map_fields/has_field_dash
When CEL expression "has({'content-type': 'application/json', 'content-length': 145}.`content-type`)" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
@wip
Scenario: quoted_map_fields/has_field_dot
When CEL expression "has({'foo.txt': 32, 'bar.csv': 1024}.`foo.txt`)" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
# qualified_identifier_resolution -- Tests for qualified identifier resolution.
Scenario: qualified_identifier_resolution/qualified_ident
Given type_env parameter "a.b.c" is celpy.celtypes.StringType
and bindings parameter "a.b.c" is celpy.celtypes.StringType(source='yeah')
When CEL expression 'a.b.c' is evaluated
Then value is celpy.celtypes.StringType(source='yeah')
Scenario: qualified_identifier_resolution/map_field_select
Given type_env parameter "a.b" is celpy.celtypes.MapType
and bindings parameter "a.b" is celpy.celtypes.MapType({'c': celpy.celtypes.StringType(source='yeah')})
When CEL expression 'a.b.c' is evaluated
Then value is celpy.celtypes.StringType(source='yeah')
Scenario: qualified_identifier_resolution/qualified_identifier_resolution_unchecked
namespace resolution should try to find the longest prefix for the
evaluator.
Given disable_check parameter is True
and type_env parameter "a.b.c" is celpy.celtypes.StringType
and type_env parameter "a.b" is celpy.celtypes.MapType
and bindings parameter "a.b" is celpy.celtypes.MapType({'c': celpy.celtypes.StringType(source='oops')})
and bindings parameter "a.b.c" is celpy.celtypes.StringType(source='yeah')
When CEL expression 'a.b.c' is evaluated
Then value is celpy.celtypes.StringType(source='yeah')
Scenario: qualified_identifier_resolution/list_field_select_unsupported
Given disable_check parameter is True
and type_env parameter "a.b" is celpy.celtypes.ListType
and bindings parameter "a.b" is [celpy.celtypes.StringType(source='pancakes')]
When CEL expression 'a.b.pancakes' is evaluated
Then eval_error is "type 'list_type:<elem_type:<primitive:STRING > > ' does not support field selection"
Scenario: qualified_identifier_resolution/int64_field_select_unsupported
Given disable_check parameter is True
and type_env parameter "a" is celpy.celtypes.IntType
and bindings parameter "a" is celpy.celtypes.IntType(source=15)
When CEL expression 'a.pancakes' is evaluated
Then eval_error is "type 'int64_type' does not support field selection"
Scenario: qualified_identifier_resolution/ident_with_longest_prefix_check
namespace resolution should try to find the longest prefix for the
checker.
Given type_env parameter "a.b.c" is celpy.celtypes.StringType
and type_env parameter "a.b" is celpy.celtypes.MapType
and bindings parameter "a.b" is celpy.celtypes.MapType({'c': celpy.celtypes.StringType(source='oops')})
and bindings parameter "a.b.c" is celpy.celtypes.StringType(source='yeah')
When CEL expression 'a.b.c' is evaluated
Then value is celpy.celtypes.StringType(source='yeah')
Scenario: qualified_identifier_resolution/map_key_float
map should not support float as the key.
Given disable_check parameter is True
When CEL expression '{3.3:15.15, 1.0: 5}[1.0]' is evaluated
Then eval_error is 'unsupported key type'
Scenario: qualified_identifier_resolution/map_key_null
map should not support null as the key.
Given disable_check parameter is True
When CEL expression '{null:false}[null]' is evaluated
Then eval_error is 'unsupported key type'
Scenario: qualified_identifier_resolution/map_value_repeat_key
map should not support repeated key.
When CEL expression '{true:1,false:2,true:3}[true]' is evaluated
Then eval_error is 'Failed with repeated key'
Scenario: qualified_identifier_resolution/map_value_repeat_key_heterogeneous
map should not support repeated key.
When CEL expression '{0: 1, 0u: 2}[0.0]' is evaluated
Then eval_error is 'Failed with repeated key'
# in -- Tests for 'in' operator for maps.
Scenario: in/empty
When CEL expression '7 in {}' is evaluated
Then value is celpy.celtypes.BoolType(source=False)
Scenario: in/singleton
When CEL expression 'true in {true: 1}' is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: in/present
When CEL expression "'George' in {'John': 'smart', 'Paul': 'cute', 'George': 'quiet', 'Ringo': 'funny'}" is evaluated
Then value is celpy.celtypes.BoolType(source=True)
Scenario: in/absent
When CEL expression "'spider' in {'ant': 6, 'fly': 6, 'centipede': 100}" is evaluated
Then value is celpy.celtypes.BoolType(source=False)
@wip
Scenario: in/mixed_numbers_and_keys_present
When CEL expression '3.0 in {1: 1, 2: 2, 3u: 3} && 2u in {1u: 1, 2: 2} && 1 in {1u: 1, 2: 2}' is evaluated
Then value is celpy.celtypes.BoolType(source=True)
@wip
Scenario: in/mixed_numbers_and_keys_absent
When CEL expression '3.1 in {1: 1, 2: 2, 3u: 3}' is evaluated
Then value is celpy.celtypes.BoolType(source=False)