luxin | d024759 | 2017-09-09 15:08:52 +0800 | [diff] [blame] | 1 | *** settings *** |
luxin | 1e0f6df | 2017-09-20 17:40:52 +0800 | [diff] [blame^] | 2 | Resource ../../common.robot |
luxin | d024759 | 2017-09-09 15:08:52 +0800 | [diff] [blame] | 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library simplejson |
| 6 | Library OperatingSystem |
| 7 | Library json |
| 8 | Library HttpLibrary.HTTP |
| 9 | |
| 10 | *** Variables *** |
luxin | 38df25a | 2017-09-20 11:27:40 +0800 | [diff] [blame] | 11 | @{return_ok_list}= 200 201 202 204 |
luxin | d024759 | 2017-09-09 15:08:52 +0800 | [diff] [blame] | 12 | ${queryswagger_url} /api/hwvnfm/v1/swagger.json |
luxin | 38df25a | 2017-09-20 11:27:40 +0800 | [diff] [blame] | 13 | ${createauthtoken_url} /rest/vnfmmed/v2/auth/tokens |
| 14 | |
| 15 | #json files |
| 16 | ${hwvnfm_createtoken_json} ${SCRIPTS}/../tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json |
luxin | d024759 | 2017-09-09 15:08:52 +0800 | [diff] [blame] | 17 | |
| 18 | *** Test Cases *** |
| 19 | SwaggerFuncTest |
| 20 | [Documentation] query swagger info rest test |
luxin | 38df25a | 2017-09-20 11:27:40 +0800 | [diff] [blame] | 21 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
luxin | 1e0f6df | 2017-09-20 17:40:52 +0800 | [diff] [blame^] | 22 | Create Session web_session http://${SERVICE_IP}:8482 headers=${headers} |
luxin | 38df25a | 2017-09-20 11:27:40 +0800 | [diff] [blame] | 23 | ${resp}= Get Request web_session ${queryswagger_url} |
| 24 | ${responese_code}= Convert To String ${resp.status_code} |
| 25 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 26 | ${response_json} json.loads ${resp.content} |
| 27 | ${swagger_version}= Convert To String ${response_json['swagger']} |
| 28 | Should Be Equal ${swagger_version} 2.0 |
| 29 | |
| 30 | AuthTokenFuncTest |
| 31 | [Documentation] create auth token rest test |
| 32 | ${json_value}= json_from_file ${hwvnfm_createtoken_json} |
| 33 | ${json_string}= string_from_json ${json_value} |
| 34 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
luxin | 1e0f6df | 2017-09-20 17:40:52 +0800 | [diff] [blame^] | 35 | Create Session web_session http://${SERVICE_IP}:8482 headers=${headers} |
luxin | 38df25a | 2017-09-20 11:27:40 +0800 | [diff] [blame] | 36 | Set Request Body ${json_string} |
| 37 | ${resp}= Post Request web_session ${createauthtoken_url} ${json_string} |
| 38 | ${responese_code}= Convert To String ${resp.status_code} |
| 39 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 40 | ${response_json} json.loads ${resp.content} |
| 41 | Dictionary Should Contain Key ${response_json} token |