Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / traversal / suite1 / custom_query_all_formats.robot
1 *** Settings ***
2 Library           OperatingSystem
3 Library           RequestsLibrary
4 Library           requests
5 Library           Collections
6
7 *** Variables ***
8 ${GENERICVNFKEYVALUE}    generic-vnf-integration-test1
9 ${PSERVERKEYVALUE}    pserver-integration-test1
10 ${GENERICVNFURL}    https://${HOST_IP}:8443/aai/v11/network/generic-vnfs/generic-vnf/${GENERICVNFKEYVALUE}
11 ${PSERVERURL}     https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE}
12 ${RELATIONSHIPURL}    https://${HOST_IP}:8443/aai/v11/network/generic-vnfs/generic-vnf/${GENERICVNFKEYVALUE}/relationship-list/relationship
13 ${CUSTOMQUERYURL}    https://${HOST_IP}:8443/aai/v11/query?format=simple
14 ${CUSTOMQUERYURL_GRAPHSON}    https://${HOST_IP}:8443/aai/v11/query?format=graphson
15 ${CUSTOMQUERYURL_ID}    https://${HOST_IP}:8443/aai/v11/query?format=id
16 ${CUSTOMQUERYURL_PATHED}    https://${HOST_IP}:8443/aai/v11/query?format=pathed
17 ${CUSTOMQUERYURL_RESOURCE}    https://${HOST_IP}:8443/aai/v11/query?format=resource
18 ${CUSTOMQUERYURL_RESOURCE_URL}    https://${HOST_IP}:8443/aai/v11/query?format=resource_and_url
19 ${CUSTOMQUERYURL_RAW}    https://${HOST_IP}:8443/aai/v11/query?format=raw
20 ${GENERICVNFDATA}    {"vnf-id":"${GENERICVNFKEYVALUE}","vnf-name":"example-vnf-name-val-51663","vnf-name2":"example-vnf-name2-val-15450","vnf-type":"example-vnf-type-val-32726"}
21 ${PSERVERDATA}    { "hostname": "${PSERVERKEYVALUE}", "ptnii-equip-name": "example-ptnii-equip-name-val-91724", "number-of-cpus": 56461, "disk-in-gigabytes": 13534, "ram-in-megabytes": 66589, "equip-type": "example-equip-type-val-94149", "equip-vendor": "example-equip-vendor-val-91811", "equip-model": "example-equip-model-val-26157", "fqdn": "example-fqdn-val-19743", "pserver-selflink": "example-pserver-selflink-val-67676", "ipv4-oam-address": "example-ipv4-oam-address-val-12819", "serial-number": "example-serial-number-val-33384", "ipaddress-v4-loopback-0": "example-ipaddress-v4-loopback0-val-63311", "ipaddress-v6-loopback-0": "example-ipaddress-v6-loopback0-val-70485", "ipaddress-v4-aim": "example-ipaddress-v4-aim-val-23497", "ipaddress-v6-aim": "example-ipaddress-v6-aim-val-24473", "ipaddress-v6-oam": "example-ipaddress-v6-oam-val-38196", "inv-status": "example-inv-status-val-10016", "pserver-id": "example-pserver-id-val-90123", "internet-topology": "example-internet-topology-val-17042", "in-maint": true, "pserver-name2": "example-pserver-name2-val-12304", "purpose": "example-purpose-val-86719", "prov-status": "example-prov-status-val-68126", "management-option": "example-management-option-val-86521", "host-profile": "example-host-profile-val-48679" }
22 ${CUSTOMQUERYDATA}    {"gremlin":"g.V().has(\\'hostname\\', \\'${PSERVERKEYVALUE}\\')"}
23 ${PSERVER_GENERIC_VNF_RELATIONSHIPDATA}    {"related-to":"pserver","relationship-data":[{"relationship-key":"pserver.hostname","relationship-value":"${PSERVERKEYVALUE}"}]}
24
25 *** Test Cases ***
26 Run AAI Put generic-vnf
27     [Documentation]    Create an generic-vnf object
28     ${resp}=    PutWithCert    ${GENERICVNFURL}    ${GENERICVNFDATA}
29     log    ${GENERICVNFURL}
30     log    ${resp.text}
31     Should Be Equal As Strings    ${resp.status_code}    201
32
33 Run AAI Put pserver
34     [Documentation]    Create an pserver object
35     ${resp}=    PutWithCert    ${PSERVERURL}    ${PSERVERDATA}
36     log    ${PSERVERURL}
37     log    ${resp.text}
38     Should Be Equal As Strings    ${resp.status_code}    201
39
40 Run AAI Put relationship of pserver and generic-vnf
41     [Documentation]    Create relationship of pserver and generic-vnf
42     ${resp}=    PutWithCert    ${RELATIONSHIPURL}    ${PSERVER_GENERIC_VNF_RELATIONSHIPDATA}
43     log    ${RELATIONSHIPURL}
44     log    ${resp.text}
45     Should Be Equal As Strings    ${resp.status_code}    200
46
47 Run AAI Get pserver
48     [Documentation]    Get the pserver object just relationship
49     ${resp}    GetWithCert    ${PSERVERURL}
50     log    ${resp}
51     log    ${resp.json()}
52     Should Be Equal As Strings    ${resp.status_code}    200
53
54 Run AAI Get generic-vnf
55     [Documentation]    Get the generic-vnf object just relationship
56     ${resp}    GetWithCert    ${GENERICVNFURL}
57     log    ${resp}
58     log    ${resp.json()}
59     Should Be Equal As Strings    ${resp.status_code}    200
60
61 Run AAI Put custom query simple format
62     [Documentation]    custom query simple format
63     log    ${CUSTOMQUERYDATA}
64     ${resp}=    PutWithCert    ${CUSTOMQUERYURL}    ${CUSTOMQUERYDATA}
65     log    ${CUSTOMQUERYURL}
66     log    ${resp.text}
67     log    ${resp.json()}
68     Should Be Equal As Strings    ${resp.status_code}    200
69
70 Run AAI Put custom query graphson format
71     [Documentation]    custom query graphson format
72     log    ${CUSTOMQUERYDATA}
73     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_GRAPHSON}    ${CUSTOMQUERYDATA}
74     log    ${CUSTOMQUERYURL_GRAPHSON}
75     log    ${resp.text}
76     log    ${resp.json()}
77     Should Be Equal As Strings    ${resp.status_code}    200
78
79 Run AAI Put custom query id format
80     [Documentation]    custom query id format
81     log    ${CUSTOMQUERYDATA}
82     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_ID}    ${CUSTOMQUERYDATA}
83     log    ${CUSTOMQUERYURL_ID}
84     log    ${resp.text}
85     log    ${resp.json()}
86     Should Be Equal As Strings    ${resp.status_code}    200
87
88 Run AAI Put custom query pathed format
89     [Documentation]    custom query pathed format
90     log    ${CUSTOMQUERYDATA}
91     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_PATHED}    ${CUSTOMQUERYDATA}
92     log    ${CUSTOMQUERYURL_PATHED}
93     log    ${resp.text}
94     log    ${resp.json()}
95     Should Be Equal As Strings    ${resp.status_code}    200
96
97 Run AAI Put custom query resource format
98     [Documentation]    custom query resource format
99     log    ${CUSTOMQUERYDATA}
100     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_RESOURCE}    ${CUSTOMQUERYDATA}
101     log    ${CUSTOMQUERYURL_RESOURCE}
102     log    ${resp.text}
103     log    ${resp.json()}
104     Should Be Equal As Strings    ${resp.status_code}    200
105
106 Run AAI Put custom query resource url format
107     [Documentation]    custom query resource url format
108     log    ${CUSTOMQUERYDATA}
109     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_RESOURCE_URL}    ${CUSTOMQUERYDATA}
110     log    ${CUSTOMQUERYURL_RESOURCE_URL}
111     log    ${resp.text}
112     log    ${resp.json()}
113     Should Be Equal As Strings    ${resp.status_code}    200
114
115 Run AAI Put custom query raw format
116     [Documentation]    custom query raw format
117     log    ${CUSTOMQUERYDATA}
118     ${resp}=    PutWithCert    ${CUSTOMQUERYURL_RAW}    ${CUSTOMQUERYDATA}
119     log    ${CUSTOMQUERYURL_RAW}
120     log    ${resp.text}
121     log    ${resp.json()}
122     Should Be Equal As Strings    ${resp.status_code}    200
123
124 Run AAI Get generic-vnf to delete
125     [Documentation]    Get the generic-vnf object to delete
126     ${resp}    GetWithCert    ${GENERICVNFURL}
127     log    ${resp}
128     log    ${resp.json()}
129     Should Be Equal As Strings    ${resp.status_code}    200
130     ${resource_version}=    Evaluate    $resp.json().get('resource-version')
131     Set Global Variable    ${resource_version}
132
133 Run AAI Delete generic-vnf
134     [Documentation]    Delete the generic-vnf
135     ${resp}=    DeleteWithCert    ${GENERICVNFURL}?resource-version=${resource_version}
136     log    ${resp.text}
137     Should Be Equal As Strings    ${resp.status_code}    204
138
139 Run AAI Get pserver to delete
140     [Documentation]    Get the pserver object to delete
141     ${resp}    GetWithCert    ${PSERVERURL}
142     log    ${resp}
143     log    ${resp.json()}
144     Should Be Equal As Strings    ${resp.status_code}    200
145     ${resource_version}=    Evaluate    $resp.json().get('resource-version')
146     Set Global Variable    ${resource_version}
147
148 Run AAI Delete pserver
149     [Documentation]    Delete the pserver
150     ${resp}=    DeleteWithCert    ${PSERVERURL}?resource-version=${resource_version}
151     log    ${resp.text}
152     Should Be Equal As Strings    ${resp.status_code}    204
153
154 *** Keywords ***
155 PutWithCert
156     [Arguments]    ${url}    ${data}
157     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai    Authorization=Basic QUFJOkFBSQ==
158     ${certinfo}=    Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
159     ${resp}=    Evaluate    requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
160     [Return]    ${resp}
161
162 PatchWithCert
163     [Arguments]    ${url}    ${data}
164     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/merge-patch+json    X-TransactionId=integration-aai    X-FromAppId=integration-aai    Authorization=Basic QUFJOkFBSQ==
165     ${certinfo}=    Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
166     ${resp}=    Evaluate    requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
167     [Return]    ${resp}
168
169 PostWithCert
170     [Arguments]    ${url}    ${data}
171     ${auth}=    Create List    AAI AAI
172     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai    Authorization=Basic QUFJOkFBSQ==
173     ${certinfo}=    Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
174     ${resp}=    Evaluate    requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
175     [Return]    ${resp}
176
177 GetWithCert
178     [Arguments]    ${url}
179     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai    Authorization=Basic QUFJOkFBSQ==
180     ${certinfo}=    Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
181     ${resp}=    Evaluate    requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
182     [Return]    ${resp}
183
184 DeleteWithCert
185     [Arguments]    ${url}
186     ${auth}=    Create List    AAI AAI
187     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai    Authorization=Basic QUFJOkFBSQ==
188     ${certinfo}=    Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
189     ${resp}=    Evaluate    requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
190     [Return]    ${resp}