Fix missing 400 impl, update test manifest

Issue-ID: RICPLT-1638
Change-Id: Iff6de7b64a0dd94c6653eff5312ec84c1cf2bced
Signed-off-by: Tommy Carpenter <tommy@research.att.com>
diff --git a/tests/fixtures/ricmanifest.json b/tests/fixtures/ricmanifest.json
index 211a115..300d7e5 100644
--- a/tests/fixtures/ricmanifest.json
+++ b/tests/fixtures/ricmanifest.json
@@ -1,28 +1,43 @@
 {
   "controls":[
     {
-      "name":"control_admission_time",
-      "description":"time period to allow dual connection",
-      "message_receives_rmr_type":"DC_ADMISSION_INTERVAL_CONTROL",
+      "name":"admission_control_policy",
+      "description":"various parameters to control admission of dual connection",
+      "control_state_request_rmr_type":"DC_ADM_GET_POLICY",
+      "control_state_request_reply_rmr_type":"DC_ADM_GET_POLICY_ACK",
+      "message_receives_rmr_type":"DC_ADM_INT_CONTROL",
       "message_receives_payload_schema":{
         "$schema":"http://json-schema.org/draft-07/schema#",
         "type":"object",
         "properties":{
-          "dc_admission_start_time":{
-            "type":"string",
-            "pattern":"^[0-9]{2}:[0-9]{2}:[0-9]{2}$"
+          "enforce":{
+            "type":"boolean",
+            "default":true
           },
-          "dc_admission_end_time":{
-            "type":"string",
-            "pattern":"^[0-9]{2}:[0-9]{2}:[0-9]{2}$"
+          "window_length":{
+            "type":"integer",
+            "default":1,
+            "minimum":1,
+            "maximum":60,
+            "description":"Sliding window length (in minutes)"
+          },
+          "blocking_rate":{
+            "type":"number",
+            "default":10,
+            "minimum":1,
+            "maximum":100,
+            "description":"% Connections to block"
+          },
+          "trigger_threshold":{
+            "type":"integer",
+            "default":10,
+            "minimum":1,
+            "description":"Minimum number of events in window to trigger blocking"
           }
         },
-        "required":[
-          "dc_admission_start_time",
-          "dc_admission_end_time"
-        ]
+        "additionalProperties":false
       },
-      "message_sends_rmr_type":"DC_ADMISSION_INTERVAL_CONTROL_ACK",
+      "message_sends_rmr_type":"DC_ADM_INT_CONTROL_ACK",
       "message_sends_payload_schema":{
         "$schema":"http://json-schema.org/draft-07/schema#",
         "type":"object",
@@ -37,7 +52,11 @@
           "message":{
             "type":"string"
           }
-        }
+        },
+        "required":[
+          "status"
+        ],
+        "additionalProperties":false
       }
     },
     {
diff --git a/tests/fixtures/rmr_string_int_mapping.txt b/tests/fixtures/rmr_string_int_mapping.txt
index ff1479d..1f194b8 100644
--- a/tests/fixtures/rmr_string_int_mapping.txt
+++ b/tests/fixtures/rmr_string_int_mapping.txt
@@ -1,4 +1,4 @@
-DC_ADMISSION_INTERVAL_CONTROL:20000
-DC_ADMISSION_INTERVAL_CONTROL_ACK:20001
+DC_ADM_INT_CONTROL:20000
+DC_ADM_INT_CONTROL_ACK:20001
 TEST_REQ:10000
 TEST_ACK:10001
diff --git a/tests/test_controller.py b/tests/test_controller.py
index 680f586..5370207 100644
--- a/tests/test_controller.py
+++ b/tests/test_controller.py
@@ -90,6 +90,15 @@
     monkeypatch.setattr("rmr.rmr.generate_and_set_transaction_id", fake_set_transactionid)
 
 
+def test_xapp_put_good(client, monkeypatch):
+    """ test policy put good"""
+    _test_put_patch(monkeypatch)
+    monkeypatch.setattr("a1.a1rmr._dequeue_all_waiting_messages", _fake_dequeue(monkeypatch))
+    res = client.put("/ric/policies/admission_control_policy", json=testing_helpers.good_payload())
+    assert res.status_code == 200
+    assert res.json == {"status": "SUCCESS", "foo": "bar"}
+
+
 def test_xapp_put_bad(client, monkeypatch):
     """Test policy put fails"""
     _test_put_patch(monkeypatch)
@@ -97,14 +106,14 @@
     monkeypatch.setattr(
         "a1.a1rmr._dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload={"status": "FAIL", "foo": "bar"})
     )
-    res = client.put("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/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("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/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"}
@@ -113,48 +122,41 @@
     monkeypatch.setattr(
         "a1.a1rmr._dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload="booger", jsonb=False)
     )
-    res = client.put("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/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("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/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("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/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_xapp_put_good(client, monkeypatch):
-    """ test policy put good"""
-    _test_put_patch(monkeypatch)
-
-    # do a good one
-    monkeypatch.setattr("a1.a1rmr._dequeue_all_waiting_messages", _fake_dequeue(monkeypatch))
-    res = client.put("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
-    assert res.status_code == 200
-    assert res.json == {"status": "SUCCESS", "foo": "bar"}
-
-
 def test_xapp_put_bad_send(client, monkeypatch):
     """
     Test bad send failures
     """
     testing_helpers.patch_all(monkeypatch)
 
+    monkeypatch.setattr("a1.a1rmr._dequeue_all_waiting_messages", _fake_dequeue(monkeypatch))
+    res = client.put("/ric/policies/admission_control_policy", json={"not": "expected"})
+    assert res.status_code == 400
+
     monkeypatch.setattr("rmr.rmr.rmr_send_msg", rmr_mocks.send_mock_generator(10))
-    res = client.put("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/policies/admission_control_policy", json=testing_helpers.good_payload())
     assert res.status_code == 504
     assert res.data == b'"A1 was unable to send a needed message to a downstream subscriber"\n'
 
     monkeypatch.setattr("rmr.rmr.rmr_send_msg", rmr_mocks.send_mock_generator(5))
-    res = client.put("/ric/policies/control_admission_time", json=testing_helpers.good_payload())
+    res = client.put("/ric/policies/admission_control_policy", json=testing_helpers.good_payload())
     assert res.status_code == 504
     assert res.data == b'"A1 was unable to send a needed message to a downstream subscriber"\n'
 
@@ -168,7 +170,7 @@
     assert res.status_code == 404
 
     # bad media type
-    res = client.put("/ric/policies/control_admission_time", data="notajson")
+    res = client.put("/ric/policies/admission_control_policy", data="notajson")
     assert res.status_code == 415
 
     # test a PUT body against a poliucy not expecting one
@@ -187,9 +189,7 @@
 
     monkeypatch.setattr("a1.utils.get_ric_manifest", f)
 
-    res = client.put(
-        "/ric/policies/control_admission_time", json=testing_helpers.good_payload(), headers={"Content-Type": "text/plain"}
-    )
+    res = client.put("/ric/policies/admission_control_policy", json=testing_helpers.good_payload())
     assert res.status_code == 500
     assert res.data == b'"A1 was unable to find the required RIC manifest. report this!"\n'
 
@@ -199,8 +199,6 @@
     test that we get a 500 with an approrpiate message on a missing rmr rmr_string
     """
     testing_helpers.patch_all(monkeypatch, nonexisting_rmr=True)
-    res = client.put(
-        "/ric/policies/control_admission_time", json=testing_helpers.good_payload(), headers={"Content-Type": "text/plain"}
-    )
+    res = client.put("/ric/policies/admission_control_policy", json=testing_helpers.good_payload())
     assert res.status_code == 500
     assert res.data == b'"A1 does not have a mapping for the desired rmr string. report this!"\n'
diff --git a/tests/testing_helpers.py b/tests/testing_helpers.py
index 3cf94e2..b258a85 100644
--- a/tests/testing_helpers.py
+++ b/tests/testing_helpers.py
@@ -39,4 +39,4 @@
 
 
 def good_payload():
-    return {"dc_admission_start_time": "10:00:00", "dc_admission_end_time": "11:00:00"}
+    return {"enforce": True, "window_length": 10, "blocking_rate": 20, "trigger_threshold": 10}