blob: a2aa639499f148e76016a62e19ed3feaf96820b5 [file] [log] [blame]
luxind0247592017-09-09 15:08:52 +08001*** settings ***
luxin1e0f6df2017-09-20 17:40:52 +08002Resource ../../common.robot
luxind0247592017-09-09 15:08:52 +08003Library Collections
4Library RequestsLibrary
5Library simplejson
6Library OperatingSystem
7Library json
8Library HttpLibrary.HTTP
9
10*** Variables ***
luxin38df25a2017-09-20 11:27:40 +080011@{return_ok_list}= 200 201 202 204
luxinea847c92017-10-23 09:59:41 +080012${queryswagger_url} /api/huaweivnfmdriver/v1/swagger.json
luxin8d9da262017-09-21 14:14:12 +080013${createauthtoken_url} /rest/plat/smapp/v1/oauth/token
luxin38df25a2017-09-20 11:27:40 +080014
15#json files
16${hwvnfm_createtoken_json} ${SCRIPTS}/../tests/vfc/nfvo-driver-svnfm/jsoninput/hwvnfm_createtoken.json
luxind0247592017-09-09 15:08:52 +080017
18*** Test Cases ***
19SwaggerFuncTest
20 [Documentation] query swagger info rest test
luxin38df25a2017-09-20 11:27:40 +080021 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
luxin1e0f6df2017-09-20 17:40:52 +080022 Create Session web_session http://${SERVICE_IP}:8482 headers=${headers}
luxin38df25a2017-09-20 11:27:40 +080023 ${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
luxin1e0f6df2017-09-20 17:40:52 +080035 Create Session web_session http://${SERVICE_IP}:8482 headers=${headers}
luxin38df25a2017-09-20 11:27:40 +080036 Set Request Body ${json_string}
luxin8d9da262017-09-21 14:14:12 +080037 ${resp}= Put Request web_session ${createauthtoken_url} ${json_string}
luxin38df25a2017-09-20 11:27:40 +080038 ${responese_code}= Convert To String ${resp.status_code}
luxin8d9da262017-09-21 14:14:12 +080039 List Should Contain Value ${return_ok_list} ${responese_code}