Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library OperatingSystem |
| 3 | Library RequestsLibrary |
| 4 | Library requests |
| 5 | Library 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 | |
| 13 | Run 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 | |
| 20 | Run 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 | |
| 29 | Run 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 *** |
| 36 | PutWithCert |
| 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 | |
| 43 | PostWithCert |
| 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 | |
| 51 | GetWithCert |
| 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 | |
| 58 | DeleteWithCert |
| 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 | |