response:
status_code: 404
+ - name: type list empty
+ request:
+ url: http://localhost:10000/a1-p/policytypes
+ method: GET
+ response:
+ status_code: 200
+ body: []
+
+ - name: instance list 404
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20000/policies
+ method: GET
+ response:
+ status_code: 404
+
- name: put the type
request:
url: http://localhost:10000/a1-p/policytypes/20000
response:
status_code: 200
+ - name: now in type list
+ request:
+ url: http://localhost:10000/a1-p/policytypes
+ method: GET
+ response:
+ status_code: 200
+ body: [20000]
+
+ - name: instance list 200 but empty
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20000/policies
+ method: GET
+ response:
+ status_code: 200
+ body: []
+
- name: test the admission control policy get not there yet
request:
url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
- handler_id: test_receiver
status: OK
+ - name: instance list 200 and contains the instance
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20000/policies
+ method: GET
+ response:
+ status_code: 200
+ body:
+ - admission_control_policy
+
+
+
---
test_name: test the delay receiver
response:
status_code: 404
+ - name: not yet in type list
+ request:
+ url: http://localhost:10000/a1-p/policytypes
+ method: GET
+ response:
+ status_code: 200
+ body: [20000]
+
+ - name: instance list 404
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20001/policies
+ method: GET
+ response:
+ status_code: 404
+
- name: put the type
request:
url: http://localhost:10000/a1-p/policytypes/20001
- test
additionalProperties: false
+ - name: now in type list
+ request:
+ url: http://localhost:10000/a1-p/policytypes
+ method: GET
+ response:
+ status_code: 200
+ body:
+ - 20000
+ - 20001
+
+ - name: instance list 200 but empty
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20001/policies
+ method: GET
+ response:
+ status_code: 200
+ body: []
+
- name: test the delay policy instance get not there yet
request:
url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
- handler_id: delay_receiver
status: OK
+ - name: instance list 200 and there
+ request:
+ url: http://localhost:10000/a1-p/policytypes/20001/policies
+ method: GET
+ response:
+ status_code: 200
+ body:
+ - delaytest
+
---
test_name: test bad routing file endpoint
ADM_CTRL = "admission_control_policy"
-ADM_CTRL_INSTANCE = "/a1-p/policytypes/20000/policies/" + ADM_CTRL
+ADM_CTRL_POLICIES = "/a1-p/policytypes/20000/policies"
+ADM_CTRL_INSTANCE = ADM_CTRL_POLICIES + "/" + ADM_CTRL
ADM_CTRL_INSTANCE_STATUS = ADM_CTRL_INSTANCE + "/status"
ADM_CTRL_TYPE = "/a1-p/policytypes/20000"
TEST_TYPE = "/a1-p/policytypes/20001"
res = client.get(ADM_CTRL_TYPE)
assert res.status_code == 404
+ # no types at all
+ res = client.get("/a1-p/policytypes")
+ assert res.status_code == 200
+ assert res.json == []
+
+ # instance 404 because type not there yet
+ res = client.get(ADM_CTRL_POLICIES)
+ assert res.status_code == 404
+
# put the type
res = client.put(ADM_CTRL_TYPE, json=adm_type_good)
assert res.status_code == 201
- # there now
+ # type there now
res = client.get(ADM_CTRL_TYPE)
assert res.status_code == 200
assert res.json == adm_type_good
+ res = client.get("/a1-p/policytypes")
+ assert res.status_code == 200
+ assert res.json == [20000]
+
+ # instance 200 but empty list
+ res = client.get(ADM_CTRL_POLICIES)
+ assert res.status_code == 200
+ assert res.json == []
# no instance there yet
res = client.get(ADM_CTRL_INSTANCE)
res = client.put(ADM_CTRL_INSTANCE, json=adm_instance_good)
assert res.status_code == 201
+ # instance 200 and in list
+ res = client.get(ADM_CTRL_POLICIES)
+ assert res.status_code == 200
+ assert res.json == [ADM_CTRL]
+
# get the instance
res = client.get(ADM_CTRL_INSTANCE)
assert res.status_code == 200
assert res.status_code == 201
-# def test_xapp_put_bad(client, monkeypatch):
-# """Test policy put fails"""
-# _test_put_patch(monkeypatch)
-# # return from policy handler has a status indicating FAIL
-# monkeypatch.setattr(
-# "a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload={"status": "FAIL", "foo": "bar"})
-# )
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "BAD STATUS"
-# assert res.json["return_payload"] == {"status": "FAIL", "foo": "bar"}
-#
-# # return from policy handler has no status field
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload={"foo": "bar"}))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "NO STATUS"
-# assert res.json["return_payload"] == {"foo": "bar"}
-#
-# # return from policy handler not a json
-# monkeypatch.setattr(
-# "a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload="booger", jsonb=False)
-# )
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "NOT JSON"
-# assert res.json["return_payload"] == "booger"
-#
-# # bad type
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_type=666))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 504
-# assert res.data == b"\"A1 was expecting an ACK back but it didn't receive one or didn't recieve the expected ACK\"\n"
-#
-# # bad state
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_state=666))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 504
-# assert res.data == b"\"A1 was expecting an ACK back but it didn't receive one or didn't recieve the expected ACK\"\n"
-
-
def test_bad_instances(client, monkeypatch, adm_type_good):
"""
Test bad send failures