Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** settings *** |
| 2 | Resource ../../common.robot |
| 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library OperatingSystem |
| 6 | Library json |
| 7 | Library HttpLibrary.HTTP |
| 8 | |
| 9 | |
| 10 | *** Variables *** |
| 11 | @{return_ok_list}= 200 201 202 |
| 12 | @{delete_ok_list}= 200 204 |
| 13 | ${get_token_url} /api/multicloud-vio/v0/vmware_fake/identity/v3/auth/tokens |
| 14 | ${get_project_url} /api/multicloud-vio/v0/vmware_fake/identity/projects |
| 15 | |
| 16 | #json files |
| 17 | ${auth_info_json} ${SCRIPTS}/../tests/multicloud-vmware/provision/jsoninput/auth_info.json |
| 18 | |
| 19 | #global vars |
| 20 | ${TOKEN} |
| 21 | ${TENANTID} |
| 22 | |
| 23 | *** Test Cases *** |
| 24 | |
| 25 | GetAuthToken |
| 26 | [Documentation] Sanity test - Get Auth Token |
| 27 | ${json_value}= json_from_file ${auth_info_json} |
| 28 | ${json_string}= string_from_json ${json_value} |
| 29 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 30 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 31 | ${resp}= POST Request web_session ${get_token_url} ${json_string} |
| 32 | ${responese_code}= Convert To String ${resp.status_code} |
| 33 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 34 | ${response_json} json.loads ${resp.content} |
| 35 | ${TOKEN}= Convert To String ${response_json['token']['value']} |
| 36 | ${TENANTID}= Convert To String ${response_json['token']['project']['id']} |
| 37 | Set Global Variable ${TOKEN} |
| 38 | Set Global Variable ${TENANTID} |
| 39 | |
| 40 | |
| 41 | TestCaseListTenants |
| 42 | [Documentation] Sanity test - List Tenants |
| 43 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 44 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 45 | ${resp}= Get Request web_session ${get_project_url} |
| 46 | ${responese_code}= Convert To String ${resp.status_code} |
| 47 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 48 | ${response_json} json.loads ${resp.content} |
| 49 | |
| 50 | |
| 51 | |
| 52 | TestCaseShowTenants |
| 53 | [Documentation] Sanity test - Show Tenant |
| 54 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 55 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 56 | ${resp}= Get Request web_session ${get_project_url}/${TENANTID} |
| 57 | ${responese_code}= Convert To String ${resp.status_code} |
| 58 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 59 | ${response_json} json.loads ${resp.content} |