PMJobs.robot 10.2 KB
Newer Older
1
2
3
4
5
6
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Resource          environment/generic.txt    # Generic Parameters
Library           JSONLibrary
Library           OperatingSystem
Resource          environment/pmJobs.txt
7
Library           REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}
Elian Kraja's avatar
Elian Kraja committed
8
Library           MockServerLibrary
9
10
11

*** Test Cases ***
GET all Pm Jobs
12
    Log    Trying to get all PM Jobs present in the VNFM
13
14
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
15
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs
16
17
18
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
19
    Log    Trying to validate response
20
21
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
22
    Validate Json    PmJobs.schema.json    ${json}
23
    Log    Validation OK
24
25
26
27
    Log    Checking that reports element is missing
    ${reports}=    Get Value From Json    ${json}    $..reports
    Should Be Empty    ${reports}
    Log    Reports element is empty as expected
28
29

GET all Pm Jobs - Filter
30
    Log    Trying to get all PM Jobs present in the VNFM, using filter params
31
32
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
33
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?${POS_FILTER}
34
35
36
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
37
    Log    Trying to validate response
38
39
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
40
    Validate Json    PmJobs.schema.json    ${json}
41
42
43
    Log    Validation OK

GET all Pm Jobs - all_fields
44
    Log    Trying to get all PM Jobs present in the VNFM, using 'all_fields' filter
45
46
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
47
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?all_fields
48
49
50
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
51
    Log    Trying to validate response
52
53
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
54
    Validate Json    PmJobs.schema.json    ${json}
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    Log    Validation OK
    Log    Trying to validate criteria schema
    ${criteria}=    Get Value From Json    ${json}    $..criteria
    Validate Json    criteria.schema.json    ${criteria[0]}
    Log    Validation for criteria schema OK
    Log    Trying to validate criteria schema
    ${reports}=    Get Value From Json    ${json}    $..reports
    Validate Json    reports.schema.json    ${reports[0]}
    Log    Validation for reports schema OK
    Log    Validating _links schema
    ${links}=    Get Value From Json    ${json}    $.._links
    Validate Json    links.schema.json    ${links[0]}
    Log    Validation for _links schema OK

69
70
71
72
73
74
75
76
77
78
79
GET all Pm Jobs - exclude_default
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?exclude_default
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    Log    Trying to validate response
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
80
    Validate Json    PmJobs.schema.json    ${json}
81
82
83
84
85
86
    Log    Validation OK
    Log    Checking that reports element is missing
    ${reports}=    Get Value From Json    ${json}    $..reports
    Should Be Empty    ${reports}
    Log    Reports element is empty as expected

87
GET all Pm Jobs - fields
88
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
Giacomo Bernini's avatar
fixes    
Giacomo Bernini committed
89
    Pass Execution If    ${FIELD_USAGE} == 0    Skipping test as VNFM is not supporting 'fields'
90
91
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
92
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?fields=${fields}
93
94
95
96
97
98
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    Log    Trying to validate response
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
99
    Validate Json    PmJobs.schema.json    ${json}
100
101
102
103
104
105
106
107
108
109
    Log    Validation OK
    Log    Trying to validate criteria schema
    ${criteria}=    Get Value From Json    ${json}    $..criteria
    Validate Json    criteria.schema.json    ${criteria[0]}
    Log    Validation for criteria schema OK
    Log    Trying to validate criteria schema
    ${reports}=    Get Value From Json    ${json}    $..reports
    Validate Json    reports.schema.json    ${reports[0]}
    Log    Validation for reports schema OK

110
111
GET all Pm Jobs - exclude_fields
    Log    Trying to get all VNF Packages present in the VNFM, using filter params
Giacomo Bernini's avatar
fixes    
Giacomo Bernini committed
112
    Pass Execution If    ${FIELD_USAGE} == 0    Skipping test as VNFM is not supporting 'fields'
113
114
115
116
117
118
119
120
121
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?fields=${fields}
    Integer    response status    200
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    Log    Trying to validate response
    ${result}=    Output    response body
    ${json}=    evaluate    json.loads('''${result}''')    json
Elian Kraja's avatar
Elian Kraja committed
122
    Validate Json    PmJobs.schema.json    ${json}
123
124
125
126
127
128
129
130
131
132
    Log    Validation OK
    Log    Checking that reports element is missing
    ${reports}=    Get Value From Json    ${json}    $..reports
    Should Be Empty    ${reports}
    Log    Reports element is empty as expected
    Log    Checking that criteria element is missing
    ${criteria}=    Get Value From Json    ${json}    $..criteria
    Should Be Empty    ${criteria}
    Log    Criteria element is empty as expected

133
134
135
136
137
138
139
140
141
142
143
144
145
146
GET all Pm Jobs - Negative (wronge filter name)
    Log    Trying to get all PM Jobs present in the VNFM, using an erroneous filter param
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs?${NEG_FILTER}
    Integer    response status    400
    Log    Received 400 Bad Request as expected
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    Log    Trying to validate ProblemDetails
    ${problemDetails}=    Output    response headers Content-Type
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
    Validate Json    ProblemDetails.schema.json    ${json}
    Log    Validation OK
147
148
149

GET all Pm Jobs (Negative: Not found)
    Log    Trying to perform a GET on a erroneous URI
150
151
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
152
    GET    ${apiRoot}/${apiName}/${apiVersion}/pm_job    # wrong URI /pm_job instead of /pm_jobs
153
    Integer    response status    404
154
    Log    Received 404 Not Found as expected
155
156
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
157
    Log    Trying to validate ProblemDetails
158
159
    ${problemDetails}=    Output    response headers Content-Type
    ${json}=    evaluate    json.loads('''${problemDetails}''')    json
160
161
162
    Validate Json    ProblemDetails.schema.json    ${json}
    Log    Validation OK

163
POST all PM Jobs - Create new PM Job
164
    Log    Creating a new PM Job
165
166
167
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
168
    ${body}=    Get File    jsons/CreatePmJobRequest.json
169
170
    POST    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs    ${body}
    Integer    response status    201
171
    Log    Received 201 Created as expected
172
173
174
175
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    ${CONTENT_TYPE_JSON}
    Log    Trying to validate response
    ${result}=    Output    response body
176
177
    ${json}=    evaluate    json.loads('''${result}''')    json
    Validate Json    PmJob.schema.json    ${json}
178
    Log    Validation OK
179

180
PUT all PM Jobs - (Method not implemented)
181
    Log    Trying to perform a PUT. This method should not be implemented
182
183
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
184
    PUT    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs
185
    Integer    response status    405
186
187
    Log    Received 405 Method not implemented as expected

188
189
190
191
192
193
PATCH all Pm Jobs - (Method not implemented)
    Log    Trying to perform a PATCH. This method should not be implemented
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
    PATCH    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs
    Integer    response status    405
194
195
    Log    Received 405 Method not implemented as expected

196
197
198
199
DELETE all Pm Jobs - (Method not implemented)
    Log    Trying to perform a DELETE. This method should not be implemented
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${VNFM_AUTH_USAGE} == 1    Set Headers    {"Authorization": "${VNFM_AUTHENTICATION}"}
200
    DELETE    ${apiRoot}/${apiName}/${apiVersion}/pm_jobs
201
    Integer    response status    405
202
    Log    Received 405 Method not implemented as expected