Olivia.Zhan | 67a402e | 2019-07-17 10:06:58 +0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../../common.robot |
| 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library OperatingSystem |
| 6 | Library json |
| 7 | Library HttpLibrary.HTTP |
| 8 | |
| 9 | *** Variables *** |
| 10 | @{return_ok_list}= 200 201 202 204 |
| 11 | ${catalog_port} 8806 |
| 12 | ${subscriptions_url} /api/nsd/v1/subscriptions |
| 13 | |
| 14 | #json files |
| 15 | ${nsdm_subscription_json} ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/nsdm_subscription.json |
| 16 | |
| 17 | #global variables |
| 18 | ${subscriptionId} |
| 19 | |
| 20 | *** Test Cases *** |
| 21 | Create new NSD management subscription |
| 22 | Log Create new NSD management subscription |
| 23 | [Documentation] The objective is to test the creation of a new NSD management subscription |
| 24 | ${json_value}= json_from_file ${nsdm_subscription_json} |
| 25 | ${json_string}= string_from_json ${json_value} |
| 26 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 27 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 28 | Set Request Body ${json_string} |
| 29 | ${resp}= Post Request web_session ${subscriptions_url} ${json_string} |
| 30 | ${responese_code}= Convert To String ${resp.status_code} |
| 31 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 32 | ${response_json} json.loads ${resp.content} |
| 33 | ${callback_uri}= Convert To String ${response_json['callbackUri']} |
| 34 | Should Be Equal ${callback_uri} http://127.0.0.1:${catalog_port}/api/catalog/v1/callback_sample |
| 35 | ${subscriptionId}= Convert To String ${response_json['id']} |
| 36 | Set Global Variable ${subscriptionId} |
| 37 | |
| 38 | Create duplicated NSD management subscription |
| 39 | Log Create duplicated NSD management subscription |
| 40 | [Documentation] The objective is to test the attempt of a creation of a duplicated NSD management subscription |
| 41 | ${json_value}= json_from_file ${nsdm_subscription_json} |
| 42 | ${json_string}= string_from_json ${json_value} |
| 43 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 44 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 45 | Set Request Body ${json_string} |
| 46 | ${resp}= Post Request web_session ${subscriptions_url} ${json_string} |
| 47 | Should Be Equal As Strings 303 ${resp.status_code} |
| 48 | |
| 49 | GET All NSD management Subscriptions |
| 50 | Log GET All NSD management Subscriptions |
| 51 | [Documentation] The objective is to test the retrieval of all NSD management subscriptions |
| 52 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 53 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 54 | ${resp}= Get Request web_session ${subscriptions_url} |
| 55 | Should Be Equal As Strings 200 ${resp.status_code} |
| 56 | |
| 57 | PUT NSD management Subscriptions - Method not implemented |
| 58 | Log PUT NSD management Subscriptions - Method not implemented |
| 59 | [Documentation] The objective is to test that PUT method is not allowed to modify NSD management subscriptions |
| 60 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 61 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 62 | ${resp}= Put Request web_session ${subscriptions_url} |
| 63 | Should Be Equal As Strings 405 ${resp.status_code} |
| 64 | |
| 65 | PATCH NSD management Subscriptions - Method not implemented |
| 66 | Log PATCH NSD management Subscriptions - Method not implemented |
| 67 | [Documentation] The objective is to test that PATCH method is not allowed to update NSD management subscriptions |
| 68 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 69 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 70 | ${resp}= Patch Request web_session ${subscriptions_url} |
| 71 | Should Be Equal As Strings 405 ${resp.status_code} |
| 72 | |
| 73 | DELETE NSD management Subscriptions - Method not implemented |
| 74 | Log DELETE NSD management Subscriptions - Method not implemented |
| 75 | [Documentation] The objective is to test that DELETE method is not allowed to delete NSD management subscriptions |
| 76 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 77 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 78 | ${resp}= Delete Request web_session ${subscriptions_url} |
| 79 | Should Be Equal As Strings 405 ${resp.status_code} |
| 80 | |
| 81 | DELETE NSD management Subscription |
| 82 | Log DELETE NSD management Subscription |
| 83 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 84 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 85 | ${resp}= Delete Request web_session ${subscriptions_url}/${subscriptionId} |
| 86 | ${responese_code}= Convert To String ${resp.status_code} |
| 87 | List Should Contain Value ${return_ok_list} ${responese_code} |