Merge "Fix issues in apex policy for O-RU and O-DU usecase"
[nonrtric.git] / test / mrstub / app / main.py
index db13fc0..90924b1 100644 (file)
@@ -54,6 +54,8 @@ cntr_msg_responses_submitted=0
 cntr_msg_responses_fetched=0
 
 # Request and response constants
+ORU_WRITE_URL="/events/unauthenticated.SEC_FAULT_OUTPUT"
+ORU_READ_URL="/events/unauthenticated.SEC_FAULT_OUTPUT/users/test/"
 AGENT_WRITE_URL="/events/A1-POLICY-AGENT-WRITE"
 AGENT_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent"
 APP_WRITE_URL="/send-request"
@@ -168,7 +170,7 @@ def create_message(operation, correlation_id, payload, url):
 ### MR-stub interface, for MR control
 
 # Send a message to MR
-# URI and parameters (GET): /send-request?operation=<GET|PUT|POST|DELETE>&url=<url>
+# URI and parameters (PUT or POST): /send-request?operation=<GET|PUT|POST|DELETE>&url=<url>
 # response: <correlation-id> (http 200) o4 400 for parameter error or 500 for other errors
 @app.route(APP_WRITE_URL,
     methods=['PUT','POST'])
@@ -344,6 +346,24 @@ def events_write():
 
         return Response('{}', status=200, mimetype=MIME_JSON)
 
+@app.route(ORU_WRITE_URL,
+    methods=['PUT','POST'])
+def oru_write():
+    global msg_requests
+    msg=json.dumps(request.json)
+    msg_requests.append(msg)
+    return Response('{}', status=200, mimetype=MIME_JSON)
+
+@app.route(ORU_READ_URL,
+    methods=['GET'])
+def oru_read():
+    global msg_requests
+    if(len(msg_requests)>0):
+        rsp=msg_requests.pop(0)
+        res=[]
+        res.append(rsp)
+        return Response(json.dumps(res), status=200, mimetype=MIME_JSON)
+    return Response("[]", status=200, mimetype=MIME_JSON)
 
 ### Functions for metrics read out ###
 
@@ -421,4 +441,4 @@ else:
     print("No env variables - OK")
 
 if __name__ == "__main__":
-    app.run(port=HOST_PORT, host=HOST_IP)
\ No newline at end of file
+    app.run(port=HOST_PORT, host=HOST_IP)