Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / resources / api_suite / get_with_depth.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       requests
5 Library       Collections
6
7 *** Variables ***
8 ${COMPLEXKEYVALUE1}  complex-integration-test3-1
9 ${COMPLEXKEYVALUE2}  complex-integration-test3-2
10 ${COMPLEXURL1}       https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE1}
11 ${COMPLEXURL2}       https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes/complex/${COMPLEXKEYVALUE2}
12 ${ALLCOMPLEXURL}     https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/complexes
13 ${COMPLEXDATA1}  {"physical-location-id":"${COMPLEXKEYVALUE1}","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 ${COMPLEXDATA2}  {"physical-location-id":"${COMPLEXKEYVALUE2}","data-center-code":"example-data-center-code-val-7783","complex-name":"example-complex-name-val-1292","identity-url":"example-identity-url-val-7466","physical-location-type":"example-physical-location-type-val-3854","street1":"example-street1-val-2496","street2":"example-street2-val-6629","city":"example-city-val-3062","state":"example-state-val-9058","postal-code":"example-postal-code-val-4493","country":"example-country-val-9873","region":"example-region-val-1004","latitude":"example-latitude-val-4555","longitude":"example-longitude-val-7603","elevation":"example-elevation-val-6335","lata":"example-lata-val-9035"}
15
16 *** Test Cases ***
17
18 Run AAI Put complex 1
19     [Documentation]             Create an complex 1 object
20     ${resp}=                    PutWithCert              ${COMPLEXURL1}              ${COMPLEXDATA1}
21     log                         ${COMPLEXURL1}
22     log                         ${resp.text}
23     Should Be Equal As Strings  ${resp.status_code}      201
24         
25 Run AAI Put complex 2
26     [Documentation]             Create an complex 2 object
27     ${resp}=                    PutWithCert              ${COMPLEXURL2}              ${COMPLEXDATA2}
28     log                         ${COMPLEXURL2}
29     log                         ${resp.text}
30     Should Be Equal As Strings  ${resp.status_code}      201    
31
32 Run AAI Get all complex
33     [Documentation]             Get the complex object just created
34     ${resp}                     GetWithCert              ${ALLCOMPLEXURL}
35     log                         ${resp}
36     log                         ${resp.json()}
37     Should Be Equal As Strings  ${resp.status_code}      200    
38         
39 Run AAI Get complex 1 to delete
40     [Documentation]             Get the complex 1 object to delete
41     ${resp}                     GetWithCert              ${COMPLEXURL1}
42     log                         ${resp}
43     log                         ${resp.json()}
44     Should Be Equal As Strings  ${resp.status_code}      200
45     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
46     Set Global Variable                 ${resource_version}
47
48 Run AAI Delete complex 1
49     [Documentation]             Delete the complex just created
50     ${resp}=                    DeleteWithCert           ${COMPLEXURL1}?resource-version=${resource_version}
51     log                         ${resp.text}
52     Should Be Equal As Strings  ${resp.status_code}      204
53         
54 Run AAI Get complex 2 to delete
55     [Documentation]             Get the complex 2 object to delete
56     ${resp}                     GetWithCert              ${COMPLEXURL2}
57     log                         ${resp}
58     log                         ${resp.json()}
59     Should Be Equal As Strings  ${resp.status_code}      200
60     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
61     Set Global Variable                 ${resource_version}
62
63 Run AAI Delete complex 2
64     [Documentation]             Delete the complex just created
65     ${resp}=                    DeleteWithCert           ${COMPLEXURL2}?resource-version=${resource_version}
66     log                         ${resp.text}
67     Should Be Equal As Strings  ${resp.status_code}      204    
68
69 *** Keywords ***
70 PutWithCert
71     [Arguments]      ${url}      ${data}
72     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
73     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
74     ${resp}=         Evaluate    requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
75     [return]         ${resp}
76         
77 PatchWithCert
78     [Arguments]      ${url}      ${data}
79     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/merge-patch+json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
80     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
81     ${resp}=         Evaluate    requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
82     [return]         ${resp}    
83
84 PostWithCert
85     [Arguments]      ${url}      ${data}
86     ${auth}=         Create List  AAI AAI
87     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
88     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
89     ${resp}=         Evaluate    requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
90     [return]         ${resp}
91
92 GetWithCert
93     [Arguments]      ${url}
94     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
95     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
96     ${resp}=         Evaluate    requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
97     [return]         ${resp}
98
99 DeleteWithCert
100     [Arguments]      ${url}
101     ${auth}=         Create List  AAI AAI
102     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
103     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
104     ${resp}=         Evaluate    requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
105     [return]         ${resp}