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/external-system/esr-ems-list/esr-ems/ems-test1 |
| 9 | ${EMSDATA} { "ems-id": "ems-test1", "esr-system-info-list": { "esr-system-info": [{ "esr-system-info-id": "ems-esr-system-info1", "system-name": "fff", "type": "ftp", "vendor": "ZTE", "version": "v1.0", "user-name": "root", "password": "123456", "system-type": "EMS_PERFORMANCE", "ip-address": "10.74.15.28", "port": "6767", "passive": true, "remote-path": "/data/peroformance"},{ "esr-system-info-id": "ems-esr-system-info2", "system-name": "fff", "type": "ftp", "vendor": "ZTE", "version": "v1.0", "user-name": "root", "password": "123456", "system-type": "EMS_RESOUCE", "ip-address": "10.74.15.29", "port": "6666", "passive": true, "remote-path": "/opt/Gcp/data/"},{ "esr-system-info-id": "ems-esr-system-info3", "system-name": "fff", "vendor": "ZTE", "version": "v1.0", "user-name": "root", "password": "123456", "system-type": "EMS_ALARM", "ip-address": "10.74.15.30", "port": "2000"}]}} |
| 10 | |
| 11 | *** Test Cases *** |
| 12 | |
| 13 | Run AAI Put ems |
| 14 | [Documentation] Create an ems object |
| 15 | ${resp}= PutWithCert ${TARGETURL} ${EMSDATA} |
| 16 | log ${TARGETURL} |
| 17 | log ${resp.text} |
| 18 | Should Be Equal As Strings ${resp.status_code} 201 |
| 19 | |
| 20 | Run AAI Get ems |
| 21 | [Documentation] Get the ems 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 ems |
| 30 | [Documentation] Delete the ems 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 | |