Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / resources / db_edge_rule / prevent_delete.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       requests
5 Library       Collections
6
7 *** Variables ***
8 ${CRKEYVALUE7}       cr-integration-test7
9 ${CRKEYVALUE8}       cr-integration-test8
10 ${TENANTKEYVALUE}    tenant-integration-test7
11 ${VSERVERKEYVALUE}   vserver-integration-test7
12
13 ${CRURL}             https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/${CRKEYVALUE7}/${CRKEYVALUE8}
14 ${TENANTURL}         https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/${CRKEYVALUE7}/${CRKEYVALUE8}/tenants/tenant/${TENANTKEYVALUE}
15 ${VSERVERURL}        https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/${CRKEYVALUE7}/${CRKEYVALUE8}/tenants/tenant/${TENANTKEYVALUE}/vservers/vserver/${VSERVERKEYVALUE}
16 ${CRDATA}  {"cloud-owner":"${CRKEYVALUE7}","cloud-region-id":"${CRKEYVALUE8}","owner-defined-type":"example-owner-defined-type-98787654321-09","cloud-region-version":"example-cloud-region-version-98765784321-09","identity-url":"example-identity-url-98765437821-09","cloud-zone":"example-cloud-zone-98765784321-09","complex-name":"example-complex-name-98765874321-09"}
17 ${TENANTDATA}  {"tenant-id":"${TENANTKEYVALUE}","tenant-name":"example-tenant-name-val-143742","vservers":{"vserver":[{"vserver-id":"${VSERVERKEYVALUE}","vserver-name":"example-vserver-name-val-357201","vserver-name2":"example-vserver-name2-val-672821","prov-status":"example-prov-status-val-137711","vserver-selflink":"example-vserver-selflink-val-58731","in-maint":true,"is-closed-loop-disabled":true}]}}
18
19
20 *** Test Cases ***
21 Run AAI Put cloud-region
22     [Documentation]             Create an cloud-region object
23     ${resp}=                    PutWithCert              ${CRURL}              ${CRDATA}
24     log                         ${CRURL}
25     log                         ${resp.text}
26     Should Be Equal As Strings  ${resp.status_code}      201
27         
28 Run AAI Put tenant
29     [Documentation]             Create an tenant object
30     ${resp}=                    PutWithCert              ${TENANTURL}              ${TENANTDATA}
31     log                         ${TENANTURL}
32     log                         ${resp.text}
33     Should Be Equal As Strings  ${resp.status_code}      201
34
35 Run AAI Get tenant to delete
36     [Documentation]             Get tenant object to delete
37     ${resp}                     GetWithCert              ${TENANTURL}
38     log                         ${resp}
39     log                         ${resp.json()}
40     Should Be Equal As Strings  ${resp.status_code}      200
41     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
42     Set Global Variable                 ${resource_version}
43
44 Run AAI Delete tenant
45     [Documentation]             Delete the tenant
46     ${resp}=                    DeleteWithCert           ${TENANTURL}?resource-version=${resource_version}
47     log                         ${resp.text}
48     Should Be Equal As Strings  ${resp.status_code}      400
49         
50 Run AAI Get vserver to delete
51     [Documentation]             Get vserver object to delete
52     ${resp}                     GetWithCert              ${VSERVERURL}
53     log                         ${resp}
54     log                         ${resp.json()}
55     Should Be Equal As Strings  ${resp.status_code}      200
56     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
57     Set Global Variable                 ${resource_version}
58
59 Run AAI Delete vserver
60     [Documentation]             Delete the vserver
61     ${resp}=                    DeleteWithCert           ${VSERVERURL}?resource-version=${resource_version}
62     log                         ${resp.text}
63     Should Be Equal As Strings  ${resp.status_code}      204
64                 
65 Run AAI Get tenant to delete
66     [Documentation]             Get tenant object to delete
67     ${resp}                     GetWithCert              ${TENANTURL}
68     log                         ${resp}
69     log                         ${resp.json()}
70     Should Be Equal As Strings  ${resp.status_code}      200
71     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
72     Set Global Variable                 ${resource_version}
73
74 Run AAI Delete tenant
75     [Documentation]             Delete the tenant
76     ${resp}=                    DeleteWithCert           ${TENANTURL}?resource-version=${resource_version}
77     log                         ${resp.text}
78     Should Be Equal As Strings  ${resp.status_code}      204    
79         
80 Run AAI Get cr to delete
81     [Documentation]             Get cr object to delete
82     ${resp}                     GetWithCert              ${CRURL}
83     log                         ${resp}
84     log                         ${resp.json()}
85     Should Be Equal As Strings  ${resp.status_code}      200
86     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
87     Set Global Variable                 ${resource_version}
88
89 Run AAI Delete cr
90     [Documentation]             Delete the cr
91     ${resp}=                    DeleteWithCert           ${CRURL}?resource-version=${resource_version}
92     log                         ${resp.text}
93     Should Be Equal As Strings  ${resp.status_code}      204    
94         
95 *** Keywords ***
96 PutWithCert
97     [Arguments]      ${url}      ${data}
98     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
99     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
100     ${resp}=         Evaluate    requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
101     [return]         ${resp}
102         
103 PatchWithCert
104     [Arguments]      ${url}      ${data}
105     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/merge-patch+json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
106     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
107     ${resp}=         Evaluate    requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
108     [return]         ${resp}    
109
110 PostWithCert
111     [Arguments]      ${url}      ${data}
112     ${auth}=         Create List  AAI AAI
113     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
114     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
115     ${resp}=         Evaluate    requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
116     [return]         ${resp}
117
118 GetWithCert
119     [Arguments]      ${url}
120     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
121     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
122     ${resp}=         Evaluate    requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
123     [return]         ${resp}
124
125 DeleteWithCert
126     [Arguments]      ${url}
127     ${auth}=         Create List  AAI AAI
128     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
129     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
130     ${resp}=         Evaluate    requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
131     [return]         ${resp}