VNFIndicators.robot 15.4 KB
Newer Older
Elian Kraja's avatar
Elian Kraja committed
1
2
3
*** Settings ***
Documentation     This clause defines all the resources and methods provided by the VNF Indicator interface. \
Library           JSONSchemaLibrary    schemas/
Elian Kraja's avatar
Elian Kraja committed
4
Resource          environment/variables.txt    # Generic Parameters
Elian Kraja's avatar
Elian Kraja committed
5
6
Library           JSONLibrary
Resource          environment/vnfIndicators.txt
7
Library           REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false
Elian Kraja's avatar
Elian Kraja committed
8
9

*** Test Cases ***
10
Get all VNF Indicators
11
    [Documentation]    Test ID: 6.3.2.1.1
12
    ...    Test title: Get all VNF Indicators
13
14
15
    ...    Test objective: The objective is to test the retrieval of all the available VNF indicators and perform a JSON schema validation of the collected indicators data structure
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 8.4.2.3.2 - SOL002 v2.4.1
16
17
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
18
    ...    Post-Conditions: none
19
20
21
22
23
    Get all VNF indicators
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   vnfIndicators
    
Get VNF Indicators with attribute-based filter
24
    [Documentation]    Test ID: 6.3.2.1.2
25
    ...    Test title: Get VNF Indicators with attribute-based filter
26
27
28
    ...    Test objective: The objective is to test the retrieval of VNF indicators using attribute-based filter, perform a JSON schema validation of the collected indicators data structure, and verify that the retrieved information matches the issued attribute-based filters 
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 8.4.2.3.2 - SOL002 v2.4.1
29
30
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
31
    ...    Post-Conditions: none
32
33
34
    Get VNF indicators with filter
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   vnfIndicators
35
    Check HTTP Response Body vnfIndicators Matches the requested attribute-based filter
36

37
Get VNF Indicators with invalid attribute-based filter
38
    [Documentation]    Test ID: 6.3.2.1.3
39
    ...    Test title: Get VNF Indicators with invalid attribute-based filter
40
    ...    Test objective: The objective is to test that the retrieval of VNF indicators fails when using invalid attribute-based filters, and perform the JSON schema validation of the failed operation HTTP response. 
41
42
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 8.4.2.3.2 - SOL002 v2.4.1
43
44
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
45
    ...    Post-Conditions: none
46
47
48
49
    Get VNF indicators with invalid filter
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails

50
Get all VNF Indicators with malformed authorization token
51
    [Documentation]    Test ID: 6.3.2.1.4
52
53
    ...    Test title: GET all VNF Indicators with malformed authrization token.
    ...    Test objective: The objective is to test that the retrieval of VNF indicators fails when using malformed authorization token
54
55
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 4.5.3.3, 8.4.2.3.2 - SOL002 v2.4.1
56
    ...    Config ID: Config_prod_VE
57
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators. The VNF requires the usage of access tokens for authorizing the API requests.
58
    ...    Post-Conditions: none
59
60
    Get all VNF indicators with malformed authorization token
    Check HTTP Response Status Code Is    400
61
62

Get all VNF Indicators without authorization token
63
    [Documentation]    Test ID: 6.3.2.1.5
64
65
    ...    Test title: GET all VNF Indicators without authorization token
    ...    Test objective: The objective is to test that the retrieval of VNF indicators fails when omitting the authorization token
66
67
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 4.5.3.3, 8.4.2.3.2 - SOL002 v2.4.1
68
    ...    Config ID: Config_prod_VE
69
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators. The VNF requires the usage of access tokens for authorizing the API requests.
70
    ...    Post-Conditions: none
71
    Get all VNF indicators without authorization token
72
    Check HTTP Response Status Code Is    401
73

74
GET all VNF Indicators with expired or revoked authorization token
75
    [Documentation]    Test ID: 6.3.2.1.6
76
77
78
79
80
81
82
83
84
85
86
87
    ...    Test title: GET all VNF Indicators with expired or revoked authorization token
    ...    Test objective: The objective is to test that the retrieval of VNF indicators fails when using expired or revoked authorization token
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 4.5.3.3, 8.4.2.3.2 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators. The VNF requires the usage of access tokens for authorizing the API requests.
    ...    Post-Conditions: none
    Get all VNF indicators with expired or revoked authorization token
    Check HTTP Response Status Code Is    401

Get all VNF Indicators with invalid resource endpoint
    [Documentation]    Test ID: 6.3.2.1.7
88
    ...    Test title: GET all VNF Indicators with invalid resource endpoint
89
    ...    Test objective: The objective is to test that the retrieval of VNF indicators fails when using invalid resource endpoint
90
91
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF.
    ...    Reference: section 8.4.2.3.2 - SOL002 v2.4.1
92
    ...    Config ID: Config_prod_VE
93
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators. 
94
    ...    Post-Conditions: none
95
96
97
98
    Get all VNF indicators with invalid resource endpoint
    Check HTTP Response Status Code Is    404

POST all VNF Indicators - Method not implemented
99
    [Documentation]    Test ID: 6.3.2.1.8
100
101
    ...    Test title: POST all VNF Indicators - Method not implemented
    ...    Test objective: The objective is to test that POST method is not allowed to create new VNF indicators
102
103
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF
    ...    Reference: section 8.4.2.3.1 - SOL002 v2.4.1
104
105
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
106
    ...    Post-Conditions: none
107
108
109
110
    Send POST Request for all VNF indicators
    Check HTTP Response Status Code Is    405

PUT all VNF Indicators - Method not implemented
111
    [Documentation]    Test ID: 6.3.2.1.9
112
113
    ...    Test title: PUT all VNF Indicators - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify VNF indicators
114
115
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF
    ...    Reference: section 8.4.2.3.3 - SOL002 v2.4.1
116
117
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
118
    ...    Post-Conditions: none
119
120
121
122
    Send PUT Request for all VNF indicators
    Check HTTP Response Status Code Is    405

PATCH all VNF Indicators - Method not implemented
123
     [Documentation]    Test ID: 6.3.2.1.10
124
    ...    Test title: PATCH all VNF Indicators - Method not implemented
125
    ...    Test objective: The objective is to test that PATCH method is not allowed to update VNF indicators
126
127
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF
    ...    Reference: section 8.4.2.3.4 - SOL002 v2.4.1
128
129
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
130
    ...    Post-Conditions: none
131
132
133
    Send PATCH Request for all VNF indicators
    Check HTTP Response Status Code Is    405

134
DELETE all VNF Indicators - Method not implemented
135
    [Documentation]    Test ID: 6.3.2.1.11
136
    ...    Test title: DELETE all VNF Indicators - Method not implemented
137
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete VNF indicators
138
139
    ...    Pre-conditions: A VNF instance is instantiated. One or more measures of VNF performance indicators are available in the VNF
    ...    Reference: section 8.4.2.3.5 - SOL002 v2.4.1
140
141
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation and maintenance of performance indicators.
142
    ...    Post-Conditions: none
143
144
    Send DELETE Request for all VNF indicators
    Check HTTP Response Status Code Is    405
145
    Check Postcondition VNF Indicators Exist
146
147
148
    
*** Keywords ***
Get all VNF indicators
Elian Kraja's avatar
Elian Kraja committed
149
150
151
    Log    The GET method queries multiple VNF indicators
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
152
    Log    Execute Query and validate response
153
154
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
155
    Set Suite Variable    ${response}    ${output}
156
157
    
Get VNF indicators with filter
Elian Kraja's avatar
Elian Kraja committed
158
159
160
    Log    The GET method queries multiple VNF indicators using Attribute-based filtering parameters
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
161
    Log    Execute Query and validate response
162
163
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators?${POS_FIELDS}
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
164
    Set Suite Variable    ${response}    ${output}
165
166
167

Get VNF indicators with invalid filter
    Log    The GET method queries multiple VNF indicators using invalid Attribute-based filtering parameters
Elian Kraja's avatar
Elian Kraja committed
168
169
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
170
    Log    Execute Query and validate response
171
172
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators?${NEG_FIELDS}
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
173
    Set Suite Variable    ${response}    ${output}
174

175
176
177
178
179
180
181
182
183
184
185
Get all VNF indicators with malformed authorization token
    Pass Execution If    ${AUTH_USAGE} == 0    Skipping test as EM/VNF is not supporting authentication
    Log    The GET method queries multiple VNF indicators using invalid token
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Authorization": "${BAD_AUTHORIZATION}"}
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Get all VNF indicators with expired or revoked authorization token
Elian Kraja's avatar
Elian Kraja committed
186
    Pass Execution If    ${AUTH_USAGE} == 0    Skipping test as EM/VNF is not supporting authentication
187
    Log    The GET method queries multiple VNF indicators using invalid token
Elian Kraja's avatar
Elian Kraja committed
188
189
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Authorization": "${NEG_AUTHORIZATION}"}
190
    Log    Execute Query and validate response
191
192
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
193
    Set Suite Variable    ${response}    ${output}
194
195

Get all VNF indicators without authorization token
Elian Kraja's avatar
Elian Kraja committed
196
    Pass Execution If    ${AUTH_USAGE} == 0    Skipping test as EM/VNF is not supporting authentication
197
    Log    The GET method queries multiple VNF indicators omitting token
Elian Kraja's avatar
Elian Kraja committed
198
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
199
    Log    Execute Query and validate response
200
201
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
202
    Set Suite Variable    ${response}    ${output}
203
204
205
    
Get all VNF indicators with invalid resource endpoint
    Log    The GET method queries multiple VNF indicators omitting token
Elian Kraja's avatar
Elian Kraja committed
206
207
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
208
    Log    Execute Query and validate response
209
    Get    ${apiRoot}/${apiName}/${apiVersion}/indicator
210
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
211
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
212

213
214
215
216
Send POST Request for all VNF indicators
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
217
218
    Post    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
219
    Set Suite Variable    ${response}    ${output}
220
221
222
223
224
    
Send PUT Request for all VNF indicators
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
225
226
    Post    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
227
    Set Suite Variable    ${response}    ${output}
228
229
230
231
232
    
Send PATCH Request for all VNF indicators
    log    Trying to perform a PATCH. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
233
234
    Post    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
235
    Set Suite Variable    ${response}    ${output}
236
237
238
239
240
    
Send DELETE Request for all VNF indicators
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
241
242
    Post    ${apiRoot}/${apiName}/${apiVersion}/indicators
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
243
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
244

245
Check HTTP Response Status Code Is
246
247
    [Arguments]    ${expected_status}
    ${status}=    Convert To Integer    ${expected_status}    
Giacomo Bernini's avatar
Giacomo Bernini committed
248
    Should Be Equal    ${response['status']}    ${status} 
249
    Log    Status code validated
250
251
    Run Keyword If    ${status} == 401
    ...    Check HTTP Response Header Contains    "WWW-Authenticate"    
Elian Kraja's avatar
Elian Kraja committed
252

253
254
Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
Giacomo Bernini's avatar
Giacomo Bernini committed
255
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
256
257
258
259
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${schema}
Giacomo Bernini's avatar
Giacomo Bernini committed
260
    Should Contain    ${response['headers']['Content-Type']}    application/json
261
262
    ${jsonSchema}=    Catenate    SEPARATOR=    ${schema}    .schema.json
    Validate Json    ${jsonSchema}    ${response['body']}
263
264
    Log    Json Schema Validation OK

265
Check Postcondition VNF Indicators Exist
266
    Log    Check Postcondition indicators exist
267
    Get all VNF indicators
268
269
    Check HTTP Response Status Code Is    200
    
270
Check HTTP Response Body vnfIndicators Matches the requested attribute-based filter
271
272
    Log    Check Response includes VNF Indicators according to filter
    #todo