Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / resources / relationship_suite / pserver_complex_rel_api.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       requests
5 Library       Collections
6
7 *** Variables ***
8 ${COMPLEXKEYVALUE}  complex-integration-test3
9 ${PSERVERKEYVALUE}  pserver-integration-test3
10 ${COMPLEXURL}              https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE}
11 ${PSERVERURL}              https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE}
12 ${PSERVERRELATIONSHIPURL}  https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE}/relationship-list/relationship
13 ${COMPLEXDATA}  {"physical-location-id":"${COMPLEXKEYVALUE}","data-center-code":"example-data-center-code-val-77883","complex-name":"example-complex-name-val-12992","identity-url":"example-identity-url-val-74366","physical-location-type":"example-physical-location-type-val-32854","street1":"example-street1-val-26496","street2":"example-street2-val-6629","city":"example-city-val-30262","state":"example-state-val-9058","postal-code":"example-postal-code-val-44893","country":"example-country-val-98673","region":"example-region-val-10014","latitude":"example-latitude-val-47555","longitude":"example-longitude-val-76903","elevation":"example-elevation-val-63385","lata":"example-lata-val-90935"}
14 ${PSERVERDATA}  {"hostname":"${PSERVERKEYVALUE}"}
15 ${RELATIONSHIPDATA}  {"related-to":"complex","relationship-data":[{"relationship-key":"complex.physical-location-id","relationship-value":"${COMPLEXKEYVALUE}"}]}
16
17 *** Test Cases ***
18 Run AAI Put complex
19     [Documentation]             Create an complex object
20     ${resp}=                    PutWithCert              ${COMPLEXURL}              ${COMPLEXDATA}
21     log                         ${COMPLEXURL}
22     log                         ${resp.text}
23     Should Be Equal As Strings  ${resp.status_code}      201
24
25 Run AAI Get complex
26     [Documentation]             Get the complex object just created
27     ${resp}                     GetWithCert              ${COMPLEXURL}
28     log                         ${resp}
29     log                         ${resp.json()}
30     Should Be Equal As Strings  ${resp.status_code}      200
31         
32 Run AAI Put pserver
33     [Documentation]             Create pserver object
34     ${resp}=                    PutWithCert              ${PSERVERURL}              ${PSERVERDATA}
35     log                         ${PSERVERURL}
36     log                         ${resp.text}
37     Should Be Equal As Strings  ${resp.status_code}      201
38
39 Run AAI Get pserver
40     [Documentation]             Get the pserver
41     ${resp}                     GetWithCert              ${PSERVERURL}
42     log                         ${resp}
43     log                         ${resp.json()}
44     Should Be Equal As Strings  ${resp.status_code}      200
45
46 Run AAI Put pserver relationship with complex using relationship api
47     [Documentation]             Create relationship between pserver and complex
48     ${resp}=                    PutWithCert              ${PSERVERRELATIONSHIPURL}              ${RELATIONSHIPDATA}
49     log                         ${PSERVERRELATIONSHIPURL}
50     log                         ${resp.text}
51     Should Be Equal As Strings  ${resp.status_code}      200    
52         
53 Run AAI Get pserver to delete
54     [Documentation]             Get pserver object to delete
55     ${resp}                     GetWithCert              ${PSERVERURL}
56     log                         ${resp}
57     log                         ${resp.json()}
58     Should Be Equal As Strings  ${resp.status_code}      200
59     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
60     Set Global Variable                 ${resource_version}
61
62 Run AAI Delete pserver
63     [Documentation]             Delete the pserver
64     ${resp}=                    DeleteWithCert           ${PSERVERURL}?resource-version=${resource_version}
65     log                         ${resp.text}
66     Should Be Equal As Strings  ${resp.status_code}      204
67         
68 Run AAI Get complex to delete
69     [Documentation]             Get complex object to delete
70     ${resp}                     GetWithCert              ${COMPLEXURL}
71     log                         ${resp}
72     log                         ${resp.json()}
73     Should Be Equal As Strings  ${resp.status_code}      200
74     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
75     Set Global Variable                 ${resource_version}
76
77 Run AAI Delete complex
78     [Documentation]             Delete the complex
79     ${resp}=                    DeleteWithCert           ${COMPLEXURL}?resource-version=${resource_version}
80     log                         ${resp.text}
81     Should Be Equal As Strings  ${resp.status_code}      204
82
83 *** Keywords ***
84 PutWithCert
85     [Arguments]      ${url}      ${data}
86     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
87     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
88     ${resp}=         Evaluate    requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
89     [return]         ${resp}
90         
91 PatchWithCert
92     [Arguments]      ${url}      ${data}
93     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/merge-patch+json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
94     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
95     ${resp}=         Evaluate    requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
96     [return]         ${resp}    
97
98 PostWithCert
99     [Arguments]      ${url}      ${data}
100     ${auth}=         Create List  AAI AAI
101     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
102     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
103     ${resp}=         Evaluate    requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
104     [return]         ${resp}
105
106 GetWithCert
107     [Arguments]      ${url}
108     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
109     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
110     ${resp}=         Evaluate    requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
111     [return]         ${resp}
112
113 DeleteWithCert
114     [Arguments]      ${url}
115     ${auth}=         Create List  AAI AAI
116     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
117     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
118     ${resp}=         Evaluate    requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
119     [return]         ${resp}