Subscriptions.robot 13.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
8
9
10
11
Library           Process
Library           MockServerLibrary    
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
12
13

*** Test Cases ***
Elian Kraja's avatar
Elian Kraja committed
14
GET VNF Indicators Subscriptions
15
    [Documentation]    Test ID: 6.3.2.4.1
16
17
    ...    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
18
19
20
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference:  section 8.4.5.3.2 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
21
    ...    Applicability: The VNF supports the generation and maintenance of indicators
22
    ...    Post-Conditions: none
Elian Kraja's avatar
Elian Kraja committed
23
    Get VNF Indicators Subscriptions
24
25
26
27
28
    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
29
30
    ...    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
31
32
33
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference:  section 8.4.5.3.2 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
34
    ...    Applicability: The VNF supports the generation and maintenance of indicators
35
36
37
38
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with filter
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is   VnfIndicatorSubscriptions
39
    Check HTTP Response Body Subscriptions Match the requested Attribute-Based Filter
40
41
42

GET VNF Indicators Subscriptions with invalid attribute-based filter
    [Documentation]    Test ID: 6.3.2.4.3
43
44
    ...    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.
45
46
47
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
    ...    Reference:  section 8.4.5.3.2 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
48
    ...    Applicability: The VNF supports the generation and maintenance of indicators
49
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
    [Documentation]    Test ID 6.3.2.4.4
56
57
58
    ...    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.
59
60
    ...    Reference: section 8.4.5.3.2 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
61
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
62
63
64
65
    ...    Post-Conditions: none
    Get VNF Indicators Subscriptions with invalid resource endpoint
    Check HTTP Response Status Code Is    404

66
Create new VNF indicator subscription
67
    [Documentation]    Test ID 6.3.2.4.5
68
69
70
    ...    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.
71
72
    ...    Reference: section 8.4.5.3.1 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
73
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
74
75
76
77
78
    ...    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
79
    Check Postcondition VNF Indicator Subscription Is Set
80
81
82

PUT VNF Indicator Subscriptions - Method not implemented
    [Documentation]    Test ID 6.3.2.4.6
83
84
85
    ...    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.
86
87
    ...    Reference: section 8.4.5.3.3 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
88
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
89
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
    [Documentation]    Test ID 6.3.2.4.7
95
96
97
    ...    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.
98
99
    ...    Reference: section 8.4.5.3.4 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
100
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
101
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
    [Documentation]    Test ID 6.3.2.4.8
107
    ...    Test title: DELETE VNF Indicator Subscriptions - Method not implemented
Giacomo Bernini's avatar
upd    
Giacomo Bernini committed
108
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete VNF indicator subscriptions
109
    ...    Pre-conditions: A VNF instance is instantiated. At least one VNF indicator subscription is available in the VNF.
110
111
    ...    Reference: section 8.4.5.3.5 - SOL002 v2.4.1
    ...    Config ID: Config_prod_VE
112
    ...    Applicability: The VNF supports the generation and maintenance of indicators.
113
114
115
116
117
    ...    Post-Conditions: none
    Send Delete Request for VNF Indicator Subscriptions
    Check HTTP Response Status Code Is    405
    
 *** Keywords ***
Elian Kraja's avatar
Elian Kraja committed
118
Get VNF Indicators Subscriptions
Elian Kraja's avatar
Elian Kraja committed
119
120
    Log    Trying to get the list of subscriptions
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
121
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
122
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
123
    ${output}=    Output    response
124
    Set Suite Variable    ${response}    ${output}
125
126

Get VNF Indicators Subscriptions with filter
Elian Kraja's avatar
Elian Kraja committed
127
128
    Log    Trying to get the list of subscriptions using filters
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
129
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
130
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${POS_FILTER}
131
    ${output}=    Output    response
132
    Set Suite Variable    ${response}    ${output}
133
134
    
Get VNF Indicators Subscriptions with invalid filter   
Elian Kraja's avatar
Elian Kraja committed
135
136
    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
137
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
138
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions?${NEG_FILTER}
139
    ${output}=    Output    response
140
    Set Suite Variable    ${response}    ${output}   
141
142
143
    
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
144
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Elian Kraja's avatar
Elian Kraja committed
145
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
146
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscription
147
    ${output}=    Output    response
148
    Set Suite Variable    ${response}    ${output}   
149
150

Send Post Request for VNF Indicator Subscription
Elian Kraja's avatar
Elian Kraja committed
151
152
153
    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
154
    ${body}=    Get File    jsons/subscriptions.json
Elian Kraja's avatar
Elian Kraja committed
155
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
156
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
157
    ${output}=    Output    response
158
159
160
    Set Suite Variable    ${response}    ${output}  
    Run Keyword If    ${VNFM_CHECKS_NOTIF_ENDPOINT} == 1
    ...       Check Notification Endpoint 
161
162
163
164

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
165
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
166
    PUT    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
167
    ${output}=    Output    response
168
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
169

170
171
172
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
173
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
174
    PATCH    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
175
    ${output}=    Output    response
176
    Set Suite Variable    ${response}    ${output}
Elian Kraja's avatar
Elian Kraja committed
177

178
179
180
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
181
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
182
    DELETE    ${apiRoot}/${apiName}/${apiVersion}/subscriptions
183
    ${output}=    Output    response
184
    Set Suite Variable    ${response}    ${output}
185
186
187
188

Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
    ${status}=    Convert To Integer    ${expected_status}    
189
    Should Be Equal    ${response['status']}    ${status}
190
191
192
193
    Log    Status code validated

Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
194
195
    Log    ${response['headers']}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
196
197
198
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
199
    [Arguments]    ${input}
200
    Should Contain    ${response['headers']['Content-Type']}    application/json
201
    ${schema} =    Catenate    SEPARATOR=    ${input}	.schema.json
202
    Validate Json    ${schema}    ${response['body']}
203
204
205
206
207
208
    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
209
    Should Be Equal    ${response['body']['callbackUri']}    ${subscription['callbackUri']}
210

211
Check Postcondition VNF Indicator Subscription Is Set
212
213
214
215
    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}"}
216
    GET    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${response['body']['id']}
217
    ${output}=    Output    response
218
    Set Suite Variable    ${response}    ${output}
219
220
    Check HTTP Response Status Code Is    200
    
221
Check HTTP Response Body Subscriptions Match the requested Attribute-Based Filter
222
223
    Log    Check Response includes VNF Indicators according to filter
    #todo
224
225
226
227
228
229
230
231
232
233
234
235
236
237


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}
    Clear Requests  ${callback_endpoint}