FaultManagement-APIKeyword.robot 26.8 KB
Newer Older
aureliano sinatra's avatar
aureliano sinatra committed
1
*** Settings ***
2
3
Library    String
Resource   environment/variables.txt
4
Library    REST     ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false
aureliano sinatra's avatar
aureliano sinatra committed
5
6
7
8
9
10
11
12
13
14
15
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    OperatingSystem
#Suite Teardown    Terminate All Processes    kill=true

Library    Process

*** Variables ***
${original_etag}    1234

*** Keywords ***
Najam UI Hassan's avatar
Najam UI Hassan committed
16
Check created Subscription existence
root's avatar
root committed
17
    Set Headers    {"Accept":"${ACCEPT}"}
18
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
19
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${response['body']['id']}
root's avatar
root committed
20
21
22
23
    Integer    response status    200  
Check Postcondition FaultManagement Subscription Is Set
    Log    Check Postcondition subscription exist
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
24
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${response['body']['id']}
root's avatar
root committed
25
26
27
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Check HTTP Response Status Code Is    200
aureliano sinatra's avatar
aureliano sinatra committed
28
Check Operation Occurrence Id
29
    ${opOccId}=    Get Value From Json    ${response['headers']}    $..Location
aureliano sinatra's avatar
aureliano sinatra committed
30
    Should Not Be Empty    ${opOccId}
aureliano sinatra's avatar
aureliano sinatra committed
31

32
Check Precondition VNF fault management individual alarm Exists
aureliano sinatra's avatar
aureliano sinatra committed
33
34
35
36
37
    Log    Checking that individual alarm exists
    GET Fault Management Individual Alarm
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    alarm  
      
38
Check Individual Subscription existence
aureliano sinatra's avatar
aureliano sinatra committed
39
    Set Headers    {"Accept":"${ACCEPT}"}
40
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
41
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId} 
aureliano sinatra's avatar
aureliano sinatra committed
42
43
44
45
    Integer    response status    200
    
Check Individual Subscription deleted
    Set Headers    {"Accept":"${ACCEPT}"}
46
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
47
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId} 
aureliano sinatra's avatar
aureliano sinatra committed
48
49
50
51
52
    Integer    response status    404
    
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    Log    Validate Status code    
53
    Should Be Equal As Strings    ${response['status']}    ${expected_status}
aureliano sinatra's avatar
aureliano sinatra committed
54
55
56
57
    Log    Status code validated 
    
Check HTTP Response Header Contains
    [Arguments]    ${HEADER_TOCHECK}
58
    Should Contain     ${response['headers']}    ${HEADER_TOCHECK}
aureliano sinatra's avatar
aureliano sinatra committed
59
60
61
62
    Log    Header is present    
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
Elian Kraja's avatar
Elian Kraja committed
63
    ${schema} =    Catenate    SEPARATOR=    ${input}    .schema.json
64
    Validate Json    ${schema}    ${response['body']}
aureliano sinatra's avatar
aureliano sinatra committed
65
66
67
68
69
    Log    Json Schema Validation OK
    
Check HTTP Response Header ContentType is 
    [Arguments]    ${expected_contentType}
    Log    Validate content type
70
    Should Be Equal    ${response['headers']['Content-Type']}    ${expected_contentType}
aureliano sinatra's avatar
aureliano sinatra committed
71
72
    Log    Content Type validated 
    
root's avatar
root committed
73
74
Check Postcondition Subscription Resource Returned in Location Header Is Available
    Log    Going to check postcondition
75
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
root's avatar
root committed
76
77
78
79
80
81
82
83
84
    GET    ${response['headers']['Location']}
    Integer    response status    200
    Log    Received a 200 OK as expected
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    application/json
    ${result}=    Output    response body
    Validate Json    FMSubscription.schema.json    ${result}
    Log    Validated FMSubscription schema
    
aureliano sinatra's avatar
aureliano sinatra committed
85
86
87
Send POST request for fault management Alarms
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
88
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
89
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
aureliano sinatra's avatar
aureliano sinatra committed
90
    ${outputResponse}=    Output    response 
91
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
92
93
94
95
    
PATCH Fault management Alarms
    log    Trying to perform a PATCH. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
96
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
97
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
aureliano sinatra's avatar
aureliano sinatra committed
98
    ${outputResponse} =    Output    response 
99
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
100
101
102
103
    
PUT Fault management Alarms
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
104
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
105
    Put    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
aureliano sinatra's avatar
aureliano sinatra committed
106
    ${outputResponse}=    Output    response 
107
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
108
109
110
111
    
DELETE Fault management Alarms
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
112
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
113
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
aureliano sinatra's avatar
aureliano sinatra committed
114
    ${outputResponse}=    Output    response
115
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
116
117
118
119
    
GET Fault Management Alarms
    Log    Query NFVO The GET method queries information about multiple alarms.
    Set Headers  {"Accept":"${ACCEPT}"}  
120
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
121
    Log    Execute Query
Najam UI Hassan's avatar
Najam UI Hassan committed
122
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms
aureliano sinatra's avatar
aureliano sinatra committed
123
    ${outputResponse}=    Output    response
124
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
125
126
127
128
    
GET Fault Management Alarms With Filters
	Log    Query NFVO The GET method queries information about multiple alarms with filters.
	Set Headers  {"Accept":"${ACCEPT}"}  
129
	Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
130
	Log    Execute Query
Najam UI Hassan's avatar
Najam UI Hassan committed
131
	Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?${alarm_filter}=${nsInstanceId}
aureliano sinatra's avatar
aureliano sinatra committed
132
	${outputResponse}=    Output    response
133
	Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
134
135
136
137
	
GET Fault Management Alarms With Invalid Filters
	Log    Query NFVO The GET method queries information about multiple alarms with filters.
	Set Headers  {"Accept":"${ACCEPT}"}  
138
	Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
139
	Log    Execute Query
Najam UI Hassan's avatar
Najam UI Hassan committed
140
	Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?${invalid_alarm_filter}=${nsInstanceId}
aureliano sinatra's avatar
aureliano sinatra committed
141
	${outputResponse}=    Output    response
142
	Set Global Variable    ${response}    ${outputResponse} 
aureliano sinatra's avatar
aureliano sinatra committed
143
144
145
146
GET Alarms Task with all_fields attribute selector
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using fields
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use fields parameter
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
147
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
148
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?exclude_default
aureliano sinatra's avatar
aureliano sinatra committed
149
150
151
152
153
154
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
GET Alarms Task with exclude_default attribute selector
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using fields
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use fields parameter
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
155
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
156
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?exclude_default
aureliano sinatra's avatar
aureliano sinatra committed
157
158
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Giacomo Bernini's avatar
Giacomo Bernini committed
159
160
GET Alarms Task with fields attribute selector
    Log    Trying to get all alarms present in the NFVO Catalogue, using fields
aureliano sinatra's avatar
aureliano sinatra committed
161
162
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use fields parameter
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
163
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
164
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?fields=${fields}
aureliano sinatra's avatar
aureliano sinatra committed
165
166
167
168
169
170
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}	
GET Alarms Task with exclude_fields attribute selector
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using fields
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use fields parameter
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
171
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
172
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms?exclude_fields=${fields}
aureliano sinatra's avatar
aureliano sinatra committed
173
174
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 	
aureliano sinatra's avatar
aureliano sinatra committed
175
176
177
Send POST request for fault management Individual Alarm
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
178
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
179
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}
aureliano sinatra's avatar
aureliano sinatra committed
180
    ${outputResponse}=    Output    response 
181
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
182
183
184
185
    
DELETE Fault Management Individual Alarm
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
186
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
187
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}
aureliano sinatra's avatar
aureliano sinatra committed
188
    ${outputResponse}=    Output    response
189
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
190
191
192
193
    
PUT Fault Management Individual Alarm
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
194
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
195
    Put    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}
aureliano sinatra's avatar
aureliano sinatra committed
196
    ${outputResponse}=    Output    response
197
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
198
199
200
201
202

GET Fault Management Individual Alarm
    Log    Query VNF The GET method queries information about an alarm.
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
203
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
204
    Log    Execute Query and validate response
Najam UI Hassan's avatar
Najam UI Hassan committed
205
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}
aureliano sinatra's avatar
aureliano sinatra committed
206
207
208
    ${etag}    Output    response headers ETag
    Set Suite Variable    &{original_etag}    ${etag}
    ${outputResponse}=    Output    response
209
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
210
211
212
213
214
    
GET Fault Management Individual Alarm with invalid id
    Log    Query NFVO The GET method queries information about an invalid alarm. Should return does not exist
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
215
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
216
    Log    Execute Query 
Najam UI Hassan's avatar
Najam UI Hassan committed
217
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${invalidAlarmId}
aureliano sinatra's avatar
aureliano sinatra committed
218
    ${outputResponse}=    Output    response
219
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
220
221
222
223
224
   
PATCH Fault Management Individual Alarm
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"} 
225
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
226
    ${body}=    Get File    jsons/alarmModifications.json
Najam UI Hassan's avatar
Najam UI Hassan committed
227
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
228
    ${outputResponse}=    Output    response
229
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
230
231
232
233
234
235
    
PATCH Fault Management Individual Alarm - precondition failed
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"} 
    Set Headers    {"If-Match": "${original_etag[0]}"}
236
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
237
    ${body}=    Get File    jsons/alarmModifications.json
Najam UI Hassan's avatar
Najam UI Hassan committed
238
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
239
    ${outputResponse}=    Output    response
240
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
241
242
243
244
245
246
   
PATCH Fault Management Individual Alarm Conflict
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"} 
    Set Headers    {"If-Match": "${Etag}"} 
247
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
248
    ${body}=    Get File    jsons/alarmModifications.json
Najam UI Hassan's avatar
Najam UI Hassan committed
249
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
250
    ${outputResponse}=    Output    response
251
    Set Global Variable    ${response}    ${outputResponse}
252
       
aureliano sinatra's avatar
aureliano sinatra committed
253
POST Subscription
Najam UI Hassan's avatar
Najam UI Hassan committed
254
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
aureliano sinatra's avatar
aureliano sinatra committed
255
256
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
257
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
258
    ${template}=    Get File    jsons/fmSubscriptionRequest.json
Elian Kraja's avatar
Elian Kraja committed
259
    ${body}=        Format String   ${template}    vnfdIds=${vnfdIds}      callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}
Najam UI Hassan's avatar
Najam UI Hassan committed
260
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
261
    ${outputResponse}=    Output    response
262
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
263
    
Najam UI Hassan's avatar
Najam UI Hassan committed
264
Send POST Request for duplicated subscription
Najam UI Hassan's avatar
Najam UI Hassan committed
265
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
aureliano sinatra's avatar
aureliano sinatra committed
266
267
268
    Pass Execution If    ${VNFM_DUPLICATION} == 0    NVFO is not permitting duplication. Skipping the test
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
269
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
270
    ${template}=    Get File    jsons/fmSubscriptionRequest.json
Elian Kraja's avatar
Elian Kraja committed
271
    ${body}=        Format String   ${template}    vnfdIds=${vnfdIds}     callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}
Najam UI Hassan's avatar
Najam UI Hassan committed
272
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
273
    ${outputResponse}=    Output    response
274
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
275

Najam UI Hassan's avatar
Najam UI Hassan committed
276
Send POST Request for duplicated subscription not permitted
Najam UI Hassan's avatar
Najam UI Hassan committed
277
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
aureliano sinatra's avatar
aureliano sinatra committed
278
279
280
    Pass Execution If    ${VNFM_DUPLICATION} == 1    NVFO is not permitting duplication. Skipping the test
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
281
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
282
    ${template}=    Get File    jsons/fmSubscriptionRequest.json
Elian Kraja's avatar
Elian Kraja committed
283
    ${body}=        Format String   ${template}    vnfdIds=${vnfdIds}     callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}
Najam UI Hassan's avatar
Najam UI Hassan committed
284
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}
aureliano sinatra's avatar
aureliano sinatra committed
285
    ${outputResponse}=    Output    response
286
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
287
288
289
290

GET Subscriptions
    Log    Get the list of active subscriptions
    Set Headers    {"Accept": "${ACCEPT}"}
291
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
292
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
aureliano sinatra's avatar
aureliano sinatra committed
293
    ${outputResponse}=    Output    response
294
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
295
296
297
298
        
GET Subscriptions with filter
    Log    Get the list of active subscriptions using a filter
    Set Headers    {"Accept": "${ACCEPT}"}
299
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
300
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?${sub_filter}
aureliano sinatra's avatar
aureliano sinatra committed
301
    ${outputResponse}=    Output    response
302
    Set Global Variable    ${response}    ${outputResponse}    
aureliano sinatra's avatar
aureliano sinatra committed
303
304
305
306
    
GET Subscriptions with Invalid filter   
    Log    Get the list of active subscriptions using an invalid filter
    Set Headers    {"Accept": "${ACCEPT}"}
307
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
308
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?${sub_filter_invalid}
aureliano sinatra's avatar
aureliano sinatra committed
309
    ${outputResponse}=    Output    response
310
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
311
312
313
Get subscriptions with all_fields attribute selector
    Log    Get the list of active subscriptions, using fields
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
314
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
315
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?exclude_default
aureliano sinatra's avatar
aureliano sinatra committed
316
317
318
319
320
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Get subscriptions with exclude_default attribute selector
    Log    Get the list of active subscriptions, using fields
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
321
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
322
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?exclude_default
aureliano sinatra's avatar
aureliano sinatra committed
323
324
325
326
327
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
Get subscriptions with fields attribute selector
    Log    Get the list of active subscriptions, using fields
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
328
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
329
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?fields=${fields}
aureliano sinatra's avatar
aureliano sinatra committed
330
331
332
333
334
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}	
Get subscriptions with exclude_fields attribute selector
    Log    Get the list of active subscriptions, using fields
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
335
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
336
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?exclude_fields=${fields}
aureliano sinatra's avatar
aureliano sinatra committed
337
338
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}     
aureliano sinatra's avatar
aureliano sinatra committed
339
340
341
PUT Subscriptions
    log    Trying to perform a PUT Subscriptions. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
342
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
343
    Put    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    
aureliano sinatra's avatar
aureliano sinatra committed
344
    ${outputResponse}=    Output    response
345
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
346
347
348
349
    
PATCH Subscriptions
    log    Trying to perform a PATCH Subscriptions. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
350
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
351
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    
aureliano sinatra's avatar
aureliano sinatra committed
352
    ${outputResponse}=    Output    response
353
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
354
355
356
357
    
DELETE Subscriptions
    log    Trying to perform a DELETE Subscriptions. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
358
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
359
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    
aureliano sinatra's avatar
aureliano sinatra committed
360
    ${outputResponse}=    Output    response
361
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
362
363
364
365
    
POST Individual Subscription
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}
366
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
367
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}  
aureliano sinatra's avatar
aureliano sinatra committed
368
    ${outputResponse}=    Output    response
369
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
370
371
372
373
    
GET Individual Subscription
    log    Trying to get information about an individual subscription
    Set Headers    {"Accept":"${ACCEPT}"}  
374
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
375
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
aureliano sinatra's avatar
aureliano sinatra committed
376
    ${outputResponse}=    Output    response
377
    Set Global Variable    ${response}    ${outputResponse}   
aureliano sinatra's avatar
aureliano sinatra committed
378
379
380
381
    
PUT Individual Subscription
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}
382
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
383
    Put    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}  
aureliano sinatra's avatar
aureliano sinatra committed
384
    ${outputResponse}=    Output    response
385
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
386
387
388
389
    
PATCH Individual Subscription
    log    Trying to perform a PATCH. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}
390
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
391
    Patch    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}  
aureliano sinatra's avatar
aureliano sinatra committed
392
    ${outputResponse}=    Output    response
393
    Set Global Variable    ${response}    ${outputResponse}
aureliano sinatra's avatar
aureliano sinatra committed
394
395
396
397

DELETE Individual Subscription
    log    Trying to perform a DELETE.
    Set Headers  {"Accept":"${ACCEPT}"}
398
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
399
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}  
aureliano sinatra's avatar
aureliano sinatra committed
400
    ${outputResponse}=    Output    response
401
    Set Global Variable    ${response}    ${outputResponse}
402
    
403
Check HTTP Response Header Contain Link
404
    ${linkURL}=    Get Value From Json    ${response['headers']}    $..Link
405
406
407
408
409
    Should Not Be Empty    ${linkURL}
    
Get subscriptions with filter "id"
    Log    Get the list of active subscriptions using a filter "id"
    Set Headers    {"Accept": "${ACCEPT}"}
410
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
411
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?id=${subscription_id}
412
    ${outputResponse}=    Output    response
413
	Set Global Variable    ${response}    ${outputResponse}
414
415
416
417
418
419
420
	
Check PostCondition HTTP Response Body Subscription Matches the requested attribute-based filter "id"
    Should Be Equal As Strings    ${response['body']['id']}    ${subscription_id}
	
Get subscriptions with filter "filter_notificationTypes"
    Log    Get the list of active subscriptions using a filter "filter.notificationTypes"
    Set Headers    {"Accept": "${ACCEPT}"}
421
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
422
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?filter.notificationTypes=${notification_type}
423
    ${outputResponse}=    Output    response
424
	Set Global Variable    ${response}    ${outputResponse}
425
426
	
Check PostCondition HTTP Response Body Subscriptions Matches the requested attribute-based filter "filter_notificationTypes"
427
	:FOR   ${item}   IN  ${response['body']}
428
429
430
431
432
433
    Should Be Equal As Strings    ${item['filter']['notificationTypes']}   ${probableCause}
    END

Get subscriptions with filter "filter_faultyResourceTypes"
    Log    Get the list of active subscriptions using a filter "filter.faultyResourceTypes"
    Set Headers    {"Accept": "${ACCEPT}"}
434
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
435
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?filter.faultyResourceTypes=${faultyResourceType}
436
    ${outputResponse}=    Output    response
437
	Set Global Variable    ${response}    ${outputResponse}
438
439
	
Check PostCondition HTTP Response Body Subscriptions Matches the requested attribute-based filter "filter_faultyResourceTypes"
440
    :FOR   ${item}   IN  ${response['body']}
441
442
443
444
445
446
    Should Be Equal As Strings    ${item['filter']['faultyResourceTypes']}   ${faultyResourceType}
    END
	
Get subscriptions with filter "filter_perceivedSeverities"
    Log    Get the list of active subscriptions using a filter "filter.perceivedSeverities"
    Set Headers    {"Accept": "${ACCEPT}"}
447
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
448
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?filter.perceivedSeverities=${perceivedSeverity}
449
    ${outputResponse}=    Output    response
450
	Set Global Variable    ${response}    ${outputResponse}
451
452
	
Check PostCondition HTTP Response Body Subscriptions Matches the requested attribute-based filter "filter_perceivedSeverities"
453
	:FOR   ${item}   IN  ${response['body']}
454
455
456
457
458
459
    Should Be Equal As Strings    ${item['filter']['perceivedSeverities']}   ${perceivedSeverity}
    END
    
Get subscriptions with filter "filter_eventTypes"
    Log    Get the list of active subscriptions using a filter "filter.eventTypes"
    Set Headers    {"Accept": "${ACCEPT}"}
460
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
461
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?filter.eventTypes=${eventType}
462
    ${outputResponse}=    Output    response
463
	Set Global Variable    ${response}    ${outputResponse}
464
465
	
Check PostCondition HTTP Response Body Subscriptions Matches the requested attribute-based filter "filter_eventTypes"
466
    :FOR   ${item}   IN  ${response['body']}
467
468
469
470
471
472
    Should Be Equal As Strings    ${item['filter']['eventTypes']}   ${eventType}
    END
	
Get subscriptions with filter "filter_probableCauses"
    Log    Get the list of active subscriptions using a filter "filter.probableCauses"
    Set Headers    {"Accept": "${ACCEPT}"}
473
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Najam UI Hassan's avatar
Najam UI Hassan committed
474
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?filter.probableCauses=${probableCause}
475
    ${outputResponse}=    Output    response
476
	Set Global Variable    ${response}    ${outputResponse}
477
478
	
Check PostCondition HTTP Response Body Subscriptions Matches the requested attribute-based filter "filter_probableCauses"
479
    :FOR   ${item}   IN  ${response['body']}
480
481
    Should Be Equal As Strings    ${item['filter']['probableCauses']}   ${probableCause}
    END