Towards a1 1.0.0; implement missing GETs
[ric-plt/a1.git] / integration_tests / test_a1.tavern.yaml
1 # test_a1.tavern.yaml
2
3 test_name: test healthcheck
4
5 stages:
6   - name: test the a1 healthcheck
7     request:
8       url: http://localhost:10000/a1-p/healthcheck
9       method: GET
10     response:
11       status_code: 200
12
13 ---
14
15 test_name: test admission control
16
17 stages:
18   - name: type not there yet
19     request:
20       url: http://localhost:10000/a1-p/policytypes/20000
21       method: GET
22     response:
23       status_code: 404
24
25   - name: type list empty
26     request:
27       url: http://localhost:10000/a1-p/policytypes
28       method: GET
29     response:
30       status_code: 200
31       body: []
32
33   - name: instance list 404
34     request:
35       url: http://localhost:10000/a1-p/policytypes/20000/policies
36       method: GET
37     response:
38       status_code: 404
39
40   - name: put the type
41     request:
42       url: http://localhost:10000/a1-p/policytypes/20000
43       method: PUT
44       json:
45         name: Admission Control
46         description: various parameters to control admission of dual connection
47         policy_type_id: 20000
48         create_schema:
49           "$schema": http://json-schema.org/draft-07/schema#
50           type: object
51           properties:
52             enforce:
53               type: boolean
54               default: true
55             window_length:
56               type: integer
57               default: 1
58               minimum: 1
59               maximum: 60
60               description: Sliding window length (in minutes)
61             blocking_rate:
62               type: number
63               default: 10
64               minimum: 1
65               maximum: 100
66               description: "% Connections to block"
67             trigger_threshold:
68               type: integer
69               default: 10
70               minimum: 1
71               description: Minimum number of events in window to trigger blocking
72           required:
73             - enforce
74             - blocking_rate
75             - trigger_threshold
76             - window_length
77           additionalProperties: false
78
79   - name: type there now
80     request:
81       url: http://localhost:10000/a1-p/policytypes/20000
82       method: GET
83     response:
84       status_code: 200
85
86   - name: now in type list
87     request:
88       url: http://localhost:10000/a1-p/policytypes
89       method: GET
90     response:
91       status_code: 200
92       body: [20000]
93
94   - name: instance list 200 but empty
95     request:
96       url: http://localhost:10000/a1-p/policytypes/20000/policies
97       method: GET
98     response:
99       status_code: 200
100       body: []
101
102   - name: test the admission control policy get not there yet
103     request:
104       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
105       method: GET
106     response:
107       status_code: 404
108
109   - name: test the admission control policy status get not there yet
110     request:
111       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy/status
112       method: GET
113     response:
114       status_code: 404
115
116   - name: put the admission control policy
117     request:
118       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
119       method: PUT
120       json:
121         enforce: true
122         window_length: 10
123         blocking_rate: 20
124         trigger_threshold: 10
125       headers:
126         content-type: application/json
127     response:
128       status_code: 201
129
130   - name: test the admission control policy get
131     request:
132       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
133       method: GET
134     response:
135       status_code: 200
136       body:
137         enforce: true
138         window_length: 10
139         blocking_rate: 20
140         trigger_threshold: 10
141
142   - name: test the admission control policy status get
143     delay_before: 3 # give it a few seconds for rmr
144     request:
145       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy/status
146       method: GET
147     response:
148       status_code: 200
149       body:
150         - handler_id: test_receiver
151           status: OK
152
153   - name: instance list 200 and contains the instance
154     request:
155       url: http://localhost:10000/a1-p/policytypes/20000/policies
156       method: GET
157     response:
158       status_code: 200
159       body:
160         - admission_control_policy
161
162
163
164 ---
165
166 test_name: test the delay receiver
167
168 stages:
169
170   - name: test the delay policy type not there yet
171     request:
172       url: http://localhost:10000/a1-p/policytypes/20001
173       method: GET
174     response:
175       status_code: 404
176
177   - name: not yet in type list
178     request:
179       url: http://localhost:10000/a1-p/policytypes
180       method: GET
181     response:
182       status_code: 200
183       body: [20000]
184
185   - name: instance list 404
186     request:
187       url: http://localhost:10000/a1-p/policytypes/20001/policies
188       method: GET
189     response:
190       status_code: 404
191
192   - name: put the type
193     request:
194       url: http://localhost:10000/a1-p/policytypes/20001
195       method: PUT
196       json:
197         name: test policy
198         description: just for testing
199         policy_type_id: 20001
200         create_schema:
201           "$schema": http://json-schema.org/draft-07/schema#
202           type: object
203           properties:
204             test:
205               type: string
206           required:
207             - test
208           additionalProperties: false
209
210   - name: type there now
211     request:
212       url: http://localhost:10000/a1-p/policytypes/20001
213       method: GET
214     response:
215       status_code: 200
216       body:
217         name: test policy
218         description: just for testing
219         policy_type_id: 20001
220         create_schema:
221           "$schema": http://json-schema.org/draft-07/schema#
222           type: object
223           properties:
224             test:
225               type: string
226           required:
227             - test
228           additionalProperties: false
229
230   - name: now in type list
231     request:
232       url: http://localhost:10000/a1-p/policytypes
233       method: GET
234     response:
235       status_code: 200
236       body:
237        - 20000
238        - 20001
239
240   - name: instance list 200 but empty
241     request:
242       url: http://localhost:10000/a1-p/policytypes/20001/policies
243       method: GET
244     response:
245       status_code: 200
246       body: []
247
248   - name: test the delay policy instance get not there yet
249     request:
250       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
251       method: GET
252     response:
253       status_code: 404
254
255   - name: test the delay policy status get not there yet
256     request:
257       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
258       method: GET
259     response:
260       status_code: 404
261
262   - name: create delay policy instance
263     request:
264       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
265       method: PUT
266       json:
267         test: foo
268       headers:
269         content-type: application/json
270     response:
271       status_code: 201
272
273   - name: test the delay policy get
274     request:
275       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
276       method: GET
277     response:
278       status_code: 200
279       body:
280         test: foo
281
282   - name: test the admission control policy status get
283     max_retries: 3
284     delay_before: 5  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
285     request:
286       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
287       method: GET
288     response:
289       status_code: 200
290       body:
291         - handler_id: delay_receiver
292           status: OK
293
294   - name: instance list 200 and there
295     request:
296       url: http://localhost:10000/a1-p/policytypes/20001/policies
297       method: GET
298     response:
299       status_code: 200
300       body:
301        - delaytest
302
303 ---
304
305 test_name: test bad routing file endpoint
306
307 stages:
308
309   - name: put the type
310     request:
311       url: http://localhost:10000/a1-p/policytypes/20002
312       method: PUT
313       json:
314         name: test policy
315         description: just for testing
316         policy_type_id: 20002
317         create_schema:
318           "$schema": http://json-schema.org/draft-07/schema#
319           type: object
320           properties:
321             test:
322               type: string
323           required:
324             - test
325           additionalProperties: false
326
327   - name: create policy instance that will go to a broken routing endpoint
328     request:
329       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest
330       method: PUT
331       json:
332         test: foo
333       headers:
334         content-type: application/json
335     response:
336       status_code: 201
337
338   - name: should be no status
339     delay_before: 5  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
340     request:
341       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest/status
342       method: GET
343     response:
344       status_code: 200
345       body: []
346
347
348 ---
349
350 test_name: bad_requests
351
352 stages:
353
354   - name: bad type get
355     request:
356       url: http://localhost:10000/a1-p/policytypes/20666
357       method: GET
358     response:
359       status_code: 404
360
361
362   - name: bad instance get
363     request:
364       url: http://localhost:10000/a1-p/policytypes/20000/policies/darkness
365       method: GET
366     response:
367       status_code: 404
368
369   - name: bad int range 1
370     request:
371       url: http://localhost:10000/a1-p/policytypes/19999
372       method: PUT
373       json:
374         name: test policy
375         description: just for testing
376         policy_type_id: 19999
377         create_schema:
378           "$schema": http://json-schema.org/draft-07/schema#
379           type: object
380     response:
381       status_code: 400
382
383   - name: bad int range 2
384     request:
385       url: http://localhost:10000/a1-p/policytypes/21024
386       method: PUT
387       json:
388         name: test policy
389         description: just for testing
390         policy_type_id: 21024
391         create_schema:
392           "$schema": http://json-schema.org/draft-07/schema#
393           type: object
394     response:
395       status_code: 400
396
397
398
399
400   - name: bad body for admission control policy
401     request:
402       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
403       method: PUT
404       json:
405         not: "expected"
406       headers:
407         content-type: application/json
408     response:
409       status_code: 400
410
411   - name: not a json
412     request:
413       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
414       method: PUT
415       data: "asdf"
416     response:
417       status_code: 415
418
419   - name: bad body for delaytest
420     request:
421       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
422       method: PUT
423       json:
424         not: "welcome"
425     response:
426       status_code: 400