Add second work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / flow-operations / sendmsg_test.py
diff --git a/example/diameter/launcher/resources/rest_api/ct/flow-operations/sendmsg_test.py b/example/diameter/launcher/resources/rest_api/ct/flow-operations/sendmsg_test.py
new file mode 100644 (file)
index 0000000..f3afa4c
--- /dev/null
@@ -0,0 +1,68 @@
+import pytest
+
+def test_001_given_diameter_json_representation_i_want_to_send_message_to_diameter_entity_and_check_it_fails_for_auto_node(resources, admlc):
+
+  responseBodyRef = { "success":"true", "response":"Working node has been set to automatic" }
+
+  # Send POST
+  response = admlc.post("/node-auto")
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  requestBody = resources("aar-diameterJson-request.json")
+  responseBodyRef = { "success":"false", "response":"Internal error (check ADML traces): invalid operated host" }
+
+  # Send POST
+  response = admlc.post("/sendmsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # IT FAILS BECAUSE MESSAGE SENT HAS OCS3 AS ORIGIN HOST, AND THIS IS NOT REGISTERED, SO node-auto COULD NOT DEDUCE THE CORRECT RESOURCE
+
+@pytest.mark.xfail(reason="Server must receive client connection to be available. Component test is very fast and this could fail the first time. Wait and test again. TODO: wait for available status after 'services' loading.")
+def test_002_given_diameter_json_representation_i_want_to_send_message_to_diameter_entity_and_check_it_succeed_for_forced_node(resources, admlc):
+
+  requestBody = { "name":"afHost.afRealm.com" }
+  responseBodyRef = { "success":"true", "response":"Forced node is now 'afHost.afRealm.com'" }
+
+  # Send POST
+  response = admlc.postDict("/node", requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  requestBody = resources("aar-diameterJson-request.json")
+  responseBodyRef = { "success":"true", "response":"Operation processed" }
+
+  # Send POST
+  response = admlc.post("/sendmsg2e", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+@pytest.mark.xfail(reason="Server must receive client connection to be available. Component test is very fast and this could fail the first time. Wait and test again. TODO: wait for available status after 'services' loading.")
+def test_003_given_diameter_json_representation_i_want_to_send_message_to_diameter_client_and_check_it_succeed_for_auto_node(resources, admlc):
+
+  responseBodyRef = { "success":"true", "response":"Working node has been set to automatic" }
+
+  # Send POST
+  response = admlc.post("/node-auto")
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # NORMALLY, AAR IS NOT THE KIND OF MESSAGE TO SEND AS DIAMETER SERVER BUT RAR, etc, BUT THIS IS VALID FOR OUR TESTING
+
+  # We will use a message which origin-host and destination-host fits the real configured ones in services, and also is ready
+  #  to be sent from local diameter server to the client:
+  requestBody = resources("aar-diameterJsonFromOwnToAF-request.json")
+  responseBodyRef = { "success":"true", "response":"Operation processed" }
+
+  # Send POST
+  response = admlc.post("/sendmsg2c", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+