blob: a2aa639499f148e76016a62e19ed3feaf96820b5 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** settings ***
2Resource ../../common.robot
3Library Collections
4Library RequestsLibrary
5Library simplejson
6Library OperatingSystem
7Library json
8Library HttpLibrary.HTTP
9
10*** Variables ***
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
14
15#json files
16${hwvnfm_createtoken_json} ${SCRIPTS}/../tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json
17
18*** Test Cases ***
19SwaggerFuncTest
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
29
30AuthTokenFuncTest
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}