VNFPackages.robot 12.7 KB
Newer Older
1
2
3
4
5
*** Settings ***
Resource          environment/vnfPackages.txt    # VNF Packages specific parameters
Library           JSONSchemaLibrary    schemas/
Resource          environment/generic.txt    # Generic Parameters
Library           JSONLibrary
6
Library           REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}
7
8
9
10

*** Test Cases ***
GET all Packages
    Log    Trying to get all VNF Packages present in the NFVO Catalogue
11
12
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
13
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
14
15
16
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
17
    Log    Trying to validate response
18
19
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
20
    Validate Json    vnfPkgInfo.schema.json    ${json}
21
    Log    Validation OK
22
23
24
25
26
27
28
29
30
31
32
33
    Log    Checking missing information for softwareImages element
    ${softwareImages}=    Get Value From Json    ${json}    $..softwareImages
    Should Be Empty    ${softwareImages}
    Log    softwareImages element is missing as excepted
    Log    Checking missing information for additionalArtifact element
    ${additional_artifacts}=    Get Value From Json    ${json}    $..additionalArtifacts
    Should Be Empty    ${additional_artifacts}
    Log    additionalArtifact element is missing as excepted
    Log    Checking missing information for _links element
    ${links}=    Get Value From Json    ${json}    $.._links
    Should Be Empty    ${links}
    Log    _links element is missing as excepted
34
35
36

GET all Packages - Filter
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using filter params
37
38
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
39
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?${POS_FIELDS}
40
41
42
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
43
    Log    Trying to validate response
44
45
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
46
    Validate Json    vnfPkgInfo.schema.json    ${json}
47
48
49
50
    Log    Validation OK

GET all Packages - Negative (wronge filter name)
    Log    Trying to perform a negative get, filtering by the inexistent field 'nfvId'
51
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
Giacomo Bernini's avatar
fixes    
Giacomo Bernini committed
52
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
53
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?${NEG_FIELDS}
54
    Integer    response status    400
55
    Log    Received 400 Bad Request as expected
56
57
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
58
    Log    Trying to validate ProblemDetails
59
60
    ${problemDetails}=    Output    response body
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
Elian Kraja's avatar
Elian Kraja committed
61
    Validate Json    ProblemDetails.schema.json    ${json}
62
63
64
65
66
    Log    Validation OK

GET all Packages - Negative (Unauthorized: Wrong Token)
    Log    Trying to perform a negative get, using wrong authorization bearer
    Pass Execution If    ${AUTH_USAGE} == 0    Skipping test as NFVO is not supporting authentication
67
68
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Authorization": "${NEG_AUTHORIZATION}"}
69
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
70
    Integer    response status    401
71
    Log    Received 401 Unauthorized as expected
72
73
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
74
    Log    Trying to validate ProblemDetails
75
76
    ${problemDetails}=    Output    response body
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
Elian Kraja's avatar
Elian Kraja committed
77
    Validate Json    ProblemDetails.schema.json    ${json}
78
79
80
81
82
    Log    Validation OK

GET all Packages - Negative (Unauthorized: No Token)
    Log    Trying to perform a negative get, using wrong authorization bearer
    Pass Execution If    ${AUTH_USAGE} == 0    Skipping test as NFVO is not supporting authentication
83
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
84
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
85
    Integer    response status    401
86
    Log    Received 401 Unauthorized as expected
87
88
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
89
    Log    Trying to validate ProblemDetails
90
91
    ${problemDetails}=    Output    response body
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
Elian Kraja's avatar
Elian Kraja committed
92
    Validate Json    ProblemDetails.schema.json    ${json}
93
94
95
96
    Log    Validation OK

GET all Packages - all_fields
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using filter params
97
98
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
99
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?all_fields
100
101
102
103
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${vnfPkgInfos}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
104
    ${json}=    evaluate    json.loads('''${vnfPkgInfos}''')    json
105
    Log    Trying to validate response
Elian Kraja's avatar
Elian Kraja committed
106
    Validate Json    vnfPkgInfo.schema.json    ${json}
107
108
    Log    Validation OK
    Log    Trying to validate softwareImages schema
Elian Kraja's avatar
Elian Kraja committed
109
110
    ${softwareImages}=    Get Value From Json    ${json}    $..softwareImages
    Validate Json    softwareImage.schema.json    ${softwareImages[0]}
111
112
    Log    Validation for softwareImage schema OK
    Log    Trying to validate additionalArtifacts schema
Elian Kraja's avatar
Elian Kraja committed
113
114
    ${additional_artifacts}=    Get Value From Json    ${json}    $..additionalArtifacts
    Validate Json    additionalArtifacts.schema.json    ${additional_artifacts[0]}
115
    Log    Validation for additionalArtifacts schema OK
Elian Kraja's avatar
Elian Kraja committed
116
117
    ${links}=    Get Value From Json    ${json}    $.._links
    Validate Json    links.schema.json    ${links[0]}
118
119
    Log    Validation for _links schema OK

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
GET all Packages - exclude_default
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using exclude_default filter.
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?exclude_default
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${vnfPkgInfos}=    Output    response body
    ${json}=    evaluate    json.loads('''${vnfPkgInfos}''')    json
    Log    Trying to validate response
    Validate Json    vnfPkgInfo.schema.json    ${json}
    Log    Validation OK
    Log    Checking missing information for softwareImages element
    ${softwareImages}=    Get Value From Json    ${json}    $..softwareImages
    Should Be Empty    ${softwareImages}
    Log    softwareImages element is missing as excepted
    Log    Checking missing information for additionalArtifact element
    ${additional_artifacts}=    Get Value From Json    ${json}    $..additionalArtifacts
    Should Be Empty    ${additional_artifacts}
    Log    additionalArtifact element is missing as excepted
    Log    Checking missing information for _links element
    ${links}=    Get Value From Json    ${json}    $.._links
    Should Be Empty    ${links}
    Log    _links element is missing as excepted

146
147
GET all Packages - fields
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using filter params
148
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use fields parameter
149
150
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
151
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?fields=${fields}
152
153
154
155
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${vnfPkgInfos}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
156
    ${json}=    evaluate    json.loads('''${vnfPkgInfos}''')    json
157
    Log    Trying to validate response, checking vnfPkgInfo and other complex attributes included in the vnfPkgInfo
Elian Kraja's avatar
Elian Kraja committed
158
    Validate Json    vnfPkgInfo.schema.json    ${json}
159
160
    Log    Validation for vnfPkgInfo OK
    Log    Trying to validate softwareImages schema
Elian Kraja's avatar
Elian Kraja committed
161
162
    ${softwareImages}=    Get Value From Json    ${json}    $..softwareImages
    Validate Json    softwareImage.schema.json    ${softwareImages[0]}
163
164
    Log    Validation for softwareImage schema OK
    Log    Trying to validate additionalArtifacts schema
Elian Kraja's avatar
Elian Kraja committed
165
166
    ${additional_artifacts}=    Get Value From Json    ${json}    $..additionalArtifacts
    Validate Json    additionalArtifacts.schema.json    ${additional_artifacts[0]}
167
168
    Log    Validation for additionalArtifacts schema OK

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
GET all Packages - exclude_fields
    Log    Trying to get all VNF Packages present in the NFVO Catalogue, using filter params
    Pass Execution If    ${NFVO_FIELDS} == 0    The NFVO is not able to use exclude_fields option
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages?exlude_fields=${fields}
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    ${vnfPkgInfos}=    Output    response body
    ${json}=    evaluate    json.loads('''${vnfPkgInfos}''')    json
    Log    Checking missing information for softwareImages element
    ${softwareImages}=    Get Value From Json    ${json}    $..softwareImages
    Should Be Empty    ${softwareImages}
    Log    softwareImages element is missing as excepted
    Log    Checking missing information for additionalArtifact element
    ${additional_artifacts}=    Get Value From Json    ${json}    $..additionalArtifacts
    Should Be Empty    ${additional_artifacts}
    Log    additionalArtifact element is missing as excepted

189
190
GET all PACKAGE (Negative: Not found)
    Log    Trying to perform a GET on a erroneous URI
191
192
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
193
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_package
194
    Integer    response status    404
195
    Log    Received 404 Not Found as expected
196
197
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
198
    Log    Trying to validate ProblemDetails
199
200
    ${problemDetails}=    Output    response body
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
201
    Validate Json    ProblemDetails.schema.json    ${json}
202
203
204
205
    Log    Validation OK

POST all PACKAGE (Method not implemented)
    Log    Trying to perform a POST (method should not be implemented)
206
207
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
208
    POST    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
209
    Integer    response status    405
210
211
212
213
    Log    Received 405 Method not implemented as expected

PUT all PACKAGE (Method not implemented)
    Log    Trying to perform a PUT. This method should not be implemented
214
215
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
216
    PUT    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
217
    Integer    response status    405
218
219
220
    Log    Received 405 Method not implemented as expected

PATCH all PACKAGE (Method not implemented)
221
222
223
224
225
    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}"}
    PATCH    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
    Integer    response status    405
226
227
228
    Log    Received 405 Method not implemented as expected

DELETE all PACKAGE (Method not implemented)
229
230
231
    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}"}
232
    DELETE    ${apiRoot}/${apiName}/${apiVersion}/vnf_packages
233
    Integer    response status    405
234
    Log    Received 405 Method not implemented as expected