blob: 55e57bccb38beb33fecfd88c362afb35ca40c794 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Library OperatingSystem
3Library RequestsLibrary
4Library requests
5Library Collections
6
7*** Variables ***
8${TARGETURL} https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/pserver-test1
9${PSERVERDATA} {"hostname": "pserver-test1"}
10
11*** Test Cases ***
12
13Run AAI Put Pserver
14 [Documentation] Create an pserver object
15 ${resp}= PutWithCert ${TARGETURL} ${PSERVERDATA}
16 log ${TARGETURL}
17 log ${resp.text}
18 Should Be Equal As Strings ${resp.status_code} 201
19
20Run AAI Get Pserver
21 [Documentation] Get the pserver object just created
22 ${resp} GetWithCert ${TARGETURL}
23 log ${resp}
24 log ${resp.json()}
25 Should Be Equal As Strings ${resp.status_code} 200
26 ${resource_version}= Evaluate $resp.json().get('resource-version')
27 Set Global Variable ${resource_version}
28
29Run AAI Delete Pserver
30 [Documentation] Delete the pserver just created
31 ${resp}= DeleteWithCert ${TARGETURL}?resource-version=${resource_version}
32 log ${resp.text}
33 Should Be Equal As Strings ${resp.status_code} 204
34
35*** Keywords ***
36PutWithCert
37 [Arguments] ${url} ${data}
38 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ==
39 ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
40 ${resp}= Evaluate requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests
41 [return] ${resp}
42
43PostWithCert
44 [Arguments] ${url} ${data}
45 ${auth}= Create List AAI AAI
46 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ==
47 ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
48 ${resp}= Evaluate requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False) requests
49 [return] ${resp}
50
51GetWithCert
52 [Arguments] ${url}
53 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ==
54 ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
55 ${resp}= Evaluate requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests
56 [return] ${resp}
57
58DeleteWithCert
59 [Arguments] ${url}
60 ${auth}= Create List AAI AAI
61 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=integration-aai X-FromAppId=integration-aai Authorization=Basic QUFJOkFBSQ==
62 ${certinfo}= Evaluate ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
63 ${resp}= Evaluate requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False) requests
64 [return] ${resp}
65