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