3 Library RequestsLibrary
4 Library OperatingSystem
6 Documentation Test cases that tests subscription functionality for VNF package onboarding/change notifications
7 ... Tests include subscribing for notifications, and querying that the subscriptions have been created
8 ... Note: creates ACCESS_TOKEN and SUBSCRIPTION_ID variables used in later etsi_vnf_notification_tests
11 ${SLEEP_INTERVAL_SEC}= 5
12 ${MAXIMUM_ATTEMPTS_BEFORE_TIMEOUT}= 48 # Represents the maximum number of attempts that will be made before a timeout. It sleeps for SLEEP_INTERVAL_SEC seconds before retry.
13 ${PACKAGE_MANAGEMENT_BASE_URL}= /so/vnfm-adapter/v1/vnfpkgm/v1
14 ${BASIC_AUTH}= Basic dm5mbTpwYXNzd29yZDEk
16 ${SUBSCRIPTION_ID}= ""
19 Subscribe for Notifications
20 Create Session vnfm_simulator_session http://${REPO_IP}:9093
21 &{headers1}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
22 Log To Console \nGetting Access Token
23 ${response}= Post On Session vnfm_simulator_session url=/oauth/token?grant_type=client_credentials headers=${headers1}
24 Log To Console \nResponse:${response}
25 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
26 Should Be Equal As Strings '${response.status_code}' '200'
27 Log To Console \nResponse Content:\n${response.content}
28 ${json_response} Evaluate json.loads(r"""${response.content}""", strict=False) json
29 Set Global Variable ${ACCESS_TOKEN} ${json_response}[access_token]
30 ${data}= Get Binary File ${CURDIR}${/}data${/}subscriptionRequest.json
31 &{headers2}= Create Dictionary Authorization=Bearer ${ACCESS_TOKEN} Content-Type=application/json Accept=application/json
32 Log To Console \nSubscribing For VNF Package Notifications
33 ${response2}= Post On Session vnfm_simulator_session /vnfpkgm/v1/subscribe data=${data} headers=${headers2}
34 Log To Console \nResponse:\n${response2}
35 Log To Console \nResponse Content:\n${response2.content}
36 Run Keyword If '${response2.status_code}' == '200' Log To Console \nexecuted with expected result
37 Should Be Equal As Strings '${response2.status_code}' '200'
38 ${json_response2}= Evaluate json.loads(r"""${response2.content}""", strict=False) json
39 Dictionary Should Contain Key ${json_response2} id
40 Set Global Variable ${SUBSCRIPTION_ID} ${json_response2}[id]
41 Log To Console \nid: ${SUBSCRIPTION_ID}
42 Dictionary Should Contain Key ${json_response2} filter
43 ${filter}= Set Variable ${json_response2}[filter]
44 Dictionary Should Contain Key ${filter} notificationTypes
45 Dictionary Should Contain Key ${filter} vnfdId
46 Dictionary Should Contain Key ${filter} operationalState
47 Dictionary Should Contain Key ${json_response2} callbackUri
48 Dictionary Should Contain Key ${json_response2} _links
49 Log To Console \nexecuted with expected result
52 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
53 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
54 Log To Console \nGetting Subscriptions from so-vnfm-adapter
55 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/subscriptions headers=${headers}
56 Log To Console \nResponse:${response}
57 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
58 Should Be Equal As Strings '${response.status_code}' '200'
59 Log To Console \nResponse Content:\n${response.content}
60 ${json_response} Evaluate json.loads(r"""${response.content}""", strict=False) json
61 ${subscription}= Set Variable ${json_response}[0]
62 Dictionary Should Contain Key ${subscription} id
63 ${sub_id}= Set Variable ${subscription}[id]
64 Should Be Equal As Strings '${sub_id}' '${SUBSCRIPTION_ID}'
65 Dictionary Should Contain Key ${subscription} filter
66 ${filter}= Set Variable ${subscription}[filter]
67 Dictionary Should Contain Key ${filter} notificationTypes
68 Dictionary Should Contain Key ${filter} vnfdId
69 Dictionary Should Contain Key ${filter} operationalState
70 Dictionary Should Contain Key ${subscription} callbackUri
71 Log To Console \nexecuted with expected result
73 Get Subscription By Subscription Id
74 Create Session so_vnfm_adapter_session http://${REPO_IP}:9092
75 &{headers}= Create Dictionary Authorization=${BASIC_AUTH} Content-Type=application/json Accept=application/json
76 Log To Console \nGetting Subscription with id ${SUBSCRIPTION_ID} from so-vnfm-adapter
77 ${response}= Get On Session so_vnfm_adapter_session ${PACKAGE_MANAGEMENT_BASE_URL}/subscriptions/${SUBSCRIPTION_ID} headers=${headers}
78 Log To Console \nResponse:${response}
79 Run Keyword If '${response.status_code}' == '200' Log To Console \nexecuted with expected result
80 Should Be Equal As Strings '${response.status_code}' '200'
81 Log To Console \nResponse Content:\n${response.content}
82 ${json_response} Evaluate json.loads(r"""${response.content}""", strict=False) json
83 Dictionary Should Contain Key ${json_response} id
84 ${sub_id}= Set Variable ${json_response}[id]
85 Should Be Equal As Strings '${sub_id}' '${SUBSCRIPTION_ID}'
86 Dictionary Should Contain Key ${json_response} filter
87 ${filter}= Set Variable ${json_response}[filter]
88 Dictionary Should Contain Key ${filter} notificationTypes
89 Dictionary Should Contain Key ${filter} vnfdId
90 Dictionary Should Contain Key ${filter} operationalState
91 Dictionary Should Contain Key ${json_response} callbackUri
92 Log To Console \nexecuted with expected result