2 Resource ../../common.robot
4 Library RequestsLibrary
6 Library OperatingSystem
8 Library HttpLibrary.HTTP
11 @{return_ok_list}= 200 201 202 204
12 ${queryswagger_url} /api/huaweivnfmdriver/v1/swagger.json
13 ${createauthtoken_url} /rest/plat/smapp/v1/oauth/token
16 ${hwvnfm_createtoken_json} ${SCRIPTS}/../tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json
20 [Documentation] query swagger info rest test
21 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
22 Create Session web_session http://${SERVICE_IP}:8482 headers=${headers}
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
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
35 Create Session web_session http://${SERVICE_IP}:8482 headers=${headers}
36 Set Request Body ${json_string}
37 ${resp}= Put 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}