Subscriptions.robot 15.1 KB
Newer Older
Elian Kraja's avatar
Elian Kraja committed
1
2
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Elian Kraja's avatar
Elian Kraja committed
3
Resource          environment/variables.txt    # Generic Parameters
Elian Kraja's avatar
Elian Kraja committed
4
5
6
Resource          environment/subscriptions.txt
Library           OperatingSystem
Library           JSONLibrary
7
Library           Process
8
9
Library           MockServerLibrary
Library           String 
10
11
12
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Elian Kraja's avatar
Elian Kraja committed
13
14

*** Test Cases ***
Elian Kraja's avatar
Elian Kraja committed
15
GET VNF Indicators Subscriptions
16
    [Documentation]    Test ID: 6.3.2.4.1
17
18
    ...    Test title: GET VNF Indicators Subscriptions
    ...    Test objective: The objective is to test the retrieval of all VNF indicators subscriptions and perform a JSON schema validation of the returned subscriptions data structure
19
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
20
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
21
    ...    Config ID: Config_prod_VE
22
    ...    Applicability: The VNF supports the generation and maintenance of indicators
23
    ...    Post-Conditions: none
Elian Kraja's avatar
Elian Kraja committed
24
    Get VNF Indicators Subscriptions
25
26
27
28
29
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   VnfIndicatorSubscriptions

GET VNF Indicators Subscriptions with attribute-based filter
    [Documentation]    Test ID: 6.3.2.4.2
30
31
    ...    Test title: GET VNF Indicators Subscriptions with attribute-based filter
    ...    Test objective: The objective is to test the retrieval of all VNF indicators subscriptions using attribute-based filter and perform a JSON schema and content validation of the returned subscriptions data structure
32
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
33
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
34
    ...    Config ID: Config_prod_VE
35
    ...    Applicability: The VNF supports the generation and maintenance of indicators
36
37
38
39
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with filter
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   VnfIndicatorSubscriptions
40
    Check HTTP Response Body Subscriptions Match the requested Attribute-Based Filter
41
42
43

GET VNF Indicators Subscriptions with invalid attribute-based filter
    [Documentation]    Test ID: 6.3.2.4.3
44
45
    ...    Test title: GET VNF Indicators Subscriptions with invalid attribute-based filter
    ...    Test objective: The objective is to test that the retrieval of all VNF indicators subscriptions fails when using invalid attribute-based filter. The test also checks the JSON schema of the unsuccessful operation HTTP response.
46
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
47
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
48
    ...    Config ID: Config_prod_VE
49
    ...    Applicability: The VNF supports the generation and maintenance of indicators
50
51
52
53
54
55
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with invalid filter
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails    

GET VNF Indicators Subscriptions with invalid resource endpoint
Michele Carignani's avatar
Michele Carignani committed
56
    [Documentation]    Test ID: 6.3.2.4.4
57
58
59
    ...    Test title: GET VNF Indicators Subscriptions with invalid resource endpoint
    ...    Test objective: The objective is to test that the retrieval of all VNF indicators subscriptions fails when using invalid resource endpoint.
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
60
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
61
    ...    Config ID: Config_prod_VE
62
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
63
64
65
66
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with invalid resource endpoint
    Check HTTP Response Status Code Is    404

67
Create new VNF indicator subscription
Michele Carignani's avatar
Michele Carignani committed
68
    [Documentation]    Test ID: 6.3.2.4.5
69
70
71
    ...    Test title: Create new VNF indicator subscription
    ...    Test objective: The objective is to test the creation of a new VNF indicator subscription perform a JSON schema and content validation of the returned subscriptions data structure
    ...    Pre-conditions: A VNF instance is instantiated.
Michele Carignani's avatar
Michele Carignani committed
72
    ...    Reference: Clause 8.4.5.3.1 - ETSI GS NFV-SOL 002 [2] v2.6.1
73
    ...    Config ID: Config_prod_VE
74
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
75
76
77
78
79
    ...    Post-Conditions: The VNF indicator subscription is successfully set and it matches the issued subscription
    Send Post Request for VNF Indicator Subscription
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    VnfIndicatorSubscription
    Check HTTP Response Body Matches the Subscription
80
    Check Postcondition VNF Indicator Subscription Is Set
81
82

PUT VNF Indicator Subscriptions - Method not implemented
Michele Carignani's avatar
Michele Carignani committed
83
    [Documentation]    Test ID: 6.3.2.4.6
84
85
86
    ...    Test title: PUT VNF Indicator Subscriptions - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify VNF indicator subscriptions
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
87
    ...    Reference: Clause 8.4.5.3.3 - ETSI GS NFV-SOL 002 [2] v2.6.1
88
    ...    Config ID: Config_prod_VE
89
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
90
91
92
93
94
    ...    Post-Conditions: none
    Send Put Request for VNF Indicator Subscriptions
    Check HTTP Response Status Code Is    405

PATCH VNF Indicator Subscriptions - Method not implemented
Michele Carignani's avatar
Michele Carignani committed
95
    [Documentation]    Test ID: 6.3.2.4.7
96
97
98
    ...    Test title: PATCH VNF Indicator Subscriptions - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not allowed to update VNF indicator subscriptions
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
99
    ...    Reference: Clause 8.4.5.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
100
    ...    Config ID: Config_prod_VE
101
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
102
103
104
105
106
    ...    Post-Conditions: none
    Send Patch Request for VNF Indicator Subscriptions
    Check HTTP Response Status Code Is    405

DELETE VNF Indicator Subscriptions - Method not implemented
Michele Carignani's avatar
Michele Carignani committed
107
    [Documentation]    Test ID: 6.3.2.4.8
108
    ...    Test title: DELETE VNF Indicator Subscriptions - Method not implemented
Giacomo Bernini's avatar
upd    
Giacomo Bernini committed
109
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete VNF indicator subscriptions
110
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
111
    ...    Reference: Clause 8.4.5.3.5 - ETSI GS NFV-SOL 002 [2] v2.6.1
112
    ...    Config ID: Config_prod_VE
113
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
114
115
116
117
    ...    Post-Conditions: none
    Send Delete Request for VNF Indicator Subscriptions
    Check HTTP Response Status Code Is    405
    
118
119
120
121
122
GET VNF Indicators Subscriptions to get Paged Response
    [Documentation]    Test ID: 6.3.2.4.9
    ...    Test title: GET VNF Indicators Subscriptions to get Paged Response
    ...    Test objective: The objective is to test the retrieval of all VNF indicators subscriptions to get Paged Response.
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
123
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
124
125
126
127
128
129
130
131
132
133
134
135
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of indicators
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions
    Check HTTP Response Status Code Is    200
    Check LINK in Header
 
GET VNF Indicators Subscriptions - Bad Request Response too Big
    [Documentation]    Test ID: 6.3.2.4.10
    ...    Test title: GET VNF Indicators Subscriptions - Bad Request Response too Big
    ...    Test objective: The objective is to test that the retrieval of all VNF indicators subscriptions fails because response is too big. The test also checks the JSON schema of the unsuccessful operation HTTP response.
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
Michele Carignani's avatar
Michele Carignani committed
136
    ...    Reference: Clause 8.4.5.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
137
138
139
140
141
142
143
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of indicators
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails    

144
 *** Keywords ***
Elian Kraja's avatar
Elian Kraja committed
145
Get VNF Indicators Subscriptions
Elian Kraja's avatar
Elian Kraja committed
146
147
    Log    Trying to get the list of subscriptions
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
148
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
149
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
150
    ${output}=    Output    response
151
    Set Suite Variable    ${response}    ${output}
152
153

Get VNF Indicators Subscriptions with filter
Elian Kraja's avatar
Elian Kraja committed
154
155
    Log    Trying to get the list of subscriptions using filters
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
156
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
157
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${POS_FILTER}
158
    ${output}=    Output    response
159
    Set Suite Variable    ${response}    ${output}
160
161
    
Get VNF Indicators Subscriptions with invalid filter   
Elian Kraja's avatar
Elian Kraja committed
162
163
    Log    Trying to get the list of subscriptions using filters with wrong attribute name
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
164
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
165
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${NEG_FILTER}
166
    ${output}=    Output    response
167
    Set Suite Variable    ${response}    ${output}   
168
169
170
    
Get VNF Indicators Subscriptions with invalid resource endpoint
        Log    Trying to perform a request on a Uri which doesn't exist
Elian Kraja's avatar
Elian Kraja committed
171
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
172
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
173
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscription
174
    ${output}=    Output    response
175
    Set Suite Variable    ${response}    ${output}   
176
177

Send Post Request for VNF Indicator Subscription
Elian Kraja's avatar
Elian Kraja committed
178
179
180
    Log    Trying to create a new subscription
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
181
    ${body}=    Get File    jsons/subscriptions.json
Elian Kraja's avatar
Elian Kraja committed
182
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
183
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
184
    ${output}=    Output    response
185
186
187
    Set Suite Variable    ${response}    ${output}  
    Run Keyword If    ${VNFM_CHECKS_NOTIF_ENDPOINT} == 1
    ...       Check Notification Endpoint 
188
189
190
191

Send Put Request for VNF Indicator Subscriptions
    Log    Trying to create a new subscription
    ${body}=    Get File    jsons/subscriptions.json
Elian Kraja's avatar
Elian Kraja committed
192
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
193
    PUT    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
194
    ${output}=    Output    response
195
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
196

197
198
199
Send Patch Request for VNF Indicator Subscriptions
    Log    Trying to create a new subscription
    ${body}=    Get File    jsons/subscriptions.json
Elian Kraja's avatar
Elian Kraja committed
200
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
201
    PATCH    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
202
    ${output}=    Output    response
203
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
204

205
206
207
Send Delete Request for VNF Indicator Subscriptions
    Log    Trying to create a new subscription
    ${body}=    Get File    jsons/subscriptions.json
Elian Kraja's avatar
Elian Kraja committed
208
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
209
    DELETE    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
210
    ${output}=    Output    response
211
    Set Suite Variable    ${response}    ${output}
212
213
214
215

Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
    ${status}=    Convert To Integer    ${expected_status}    
216
    Should Be Equal    ${response['status']}    ${status}
217
218
219
220
    Log    Status code validated

Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
221
222
    Log    ${response['headers']}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
223
224
225
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
226
    [Arguments]    ${input}
227
    Should Contain    ${response['headers']['Content-Type']}    application/json
228
    ${schema} =    Catenate    SEPARATOR=    ${input}	.schema.json
229
    Validate Json    ${schema}    ${response['body']}
230
231
232
233
234
235
    Log    Json Schema Validation OK

Check HTTP Response Body Matches the Subscription
    Log    Check Response matches subscription
    ${body}=    Get File    jsons/subscriptions.json
    ${subscription}=    evaluate    json.loads('''${body}''')    json
236
    Should Be Equal    ${response['body']['callbackUri']}    ${subscription['callbackUri']}
237

238
Check Postcondition VNF Indicator Subscription Is Set
239
240
241
242
    Log    Check Postcondition subscription exist
    Log    Trying to get the subscription
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
243
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${response['body']['id']}
244
    ${output}=    Output    response
245
    Set Suite Variable    ${response}    ${output}
246
247
    Check HTTP Response Status Code Is    200
    
248
Check HTTP Response Body Subscriptions Match the requested Attribute-Based Filter
249
    Log    Check Response includes VNF Indicators according to filter
Najam UI Hassan's avatar
Najam UI Hassan committed
250
251
252
    @{words} =  Split String    ${POS_FILTER}       ,${SEPERATOR} 
    Should Be Equal As Strings    ${response['body'][0]['callbackUri']}    @{words}[1]
    
253
254
255
256
257
258
259
260
261
262
263
Create Sessions
    Pass Execution If    ${VNFM_CHECKS_NOTIF_ENDPOINT} == 0   MockServer not necessary to run    
    Start Process  java  -jar  ${MOCK_SERVER_JAR}    -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}
    
Check Notification Endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}    
    &{notification_response}=  Create Mock Response	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Wait Until Keyword Succeeds    ${total_polling_time}   ${polling_interval}   Verify Mock Expectation    ${notification_request}
264
265
266
    Clear Requests  ${callback_endpoint}
    
Check LINK in Header
Elian Kraja's avatar
Elian Kraja committed
267
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
268
    Should Not Be Empty    ${linkURL}