Add second work package for REST API implementation
[anna.git] / example / diameter / launcher / resources / rest_api / ct / flow-operations / sendmsg_test.py
1 import pytest
2
3 def test_001_given_diameter_json_representation_i_want_to_send_message_to_diameter_entity_and_check_it_fails_for_auto_node(resources, admlc):
4
5   responseBodyRef = { "success":"true", "response":"Working node has been set to automatic" }
6
7   # Send POST
8   response = admlc.post("/node-auto")
9
10   # Verify response
11   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
12
13   requestBody = resources("aar-diameterJson-request.json")
14   responseBodyRef = { "success":"false", "response":"Internal error (check ADML traces): invalid operated host" }
15
16   # Send POST
17   response = admlc.post("/sendmsg2e", requestBody)
18
19   ### Verify response
20   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
21
22   # IT FAILS BECAUSE MESSAGE SENT HAS OCS3 AS ORIGIN HOST, AND THIS IS NOT REGISTERED, SO node-auto COULD NOT DEDUCE THE CORRECT RESOURCE
23
24 @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.")
25 def test_002_given_diameter_json_representation_i_want_to_send_message_to_diameter_entity_and_check_it_succeed_for_forced_node(resources, admlc):
26
27   requestBody = { "name":"afHost.afRealm.com" }
28   responseBodyRef = { "success":"true", "response":"Forced node is now 'afHost.afRealm.com'" }
29
30   # Send POST
31   response = admlc.postDict("/node", requestBody)
32
33   # Verify response
34   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
35
36   requestBody = resources("aar-diameterJson-request.json")
37   responseBodyRef = { "success":"true", "response":"Operation processed" }
38
39   # Send POST
40   response = admlc.post("/sendmsg2e", requestBody)
41
42   ### Verify response
43   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
44
45 @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.")
46 def test_003_given_diameter_json_representation_i_want_to_send_message_to_diameter_client_and_check_it_succeed_for_auto_node(resources, admlc):
47
48   responseBodyRef = { "success":"true", "response":"Working node has been set to automatic" }
49
50   # Send POST
51   response = admlc.post("/node-auto")
52
53   # Verify response
54   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
55
56   # NORMALLY, AAR IS NOT THE KIND OF MESSAGE TO SEND AS DIAMETER SERVER BUT RAR, etc, BUT THIS IS VALID FOR OUR TESTING
57
58   # We will use a message which origin-host and destination-host fits the real configured ones in services, and also is ready
59   #  to be sent from local diameter server to the client:
60   requestBody = resources("aar-diameterJsonFromOwnToAF-request.json")
61   responseBodyRef = { "success":"true", "response":"Operation processed" }
62
63   # Send POST
64   response = admlc.post("/sendmsg2c", requestBody)
65
66   ### Verify response
67   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
68