Grants.robot 10.2 KB
Newer Older
1
*** Settings ***
Giacomo Bernini's avatar
fixes    
Giacomo Bernini committed
2
Resource   environment/variables.txt 
3
Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}
4
5
6
Library    OperatingSystem
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
7
8
9
Documentation    This resource represents grants. The client can use this resource to obtain permission
...     from the NFVO to perform a particular VNF lifecycle operation.

10
11
*** Variables ***
${response}    {}
Giacomo Bernini's avatar
Giacomo Bernini committed
12
13
${retry}   2 min
${polling}    10 sec
14

15
*** Test Cases ***
AHMADABB's avatar
AHMADABB committed
16
17
Requests a grant for a particular VNF lifecycle operation - Synchronous mode
    [Documentation]    Test ID: 7.3.2.1.1
18
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Synchronous mode
root's avatar
root committed
19
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation and perform a JSON schema validation on the returned grant data structure
20
    ...    Pre-conditions: 
Michele Carignani's avatar
Michele Carignani committed
21
    ...    Reference: Clause 9.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v2.4.1
22
    ...    Config ID: Config_prod_NFVO
23
24
    ...    Applicability: The NFVO can decide immediately what to respond to a grant request
    ...    Post-Conditions: The grant information is available to the VNFM.
AHMADABB's avatar
AHMADABB committed
25
    Send Request Grant Request in Synchronous mode
26
    Check HTTP Response Status Code Is    201
27
    Check Operation Occurrence Id existence 
AHMADABB's avatar
AHMADABB committed
28
    Check HTTP Response Body Json Schema Is    grant
29
30


AHMADABB's avatar
AHMADABB committed
31
32
Requests a grant for a particular VNF lifecycle operation - Asynchronous mode
    [Documentation]    Test ID: 7.3.2.1.2
33
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Asynchronous mode
root's avatar
root committed
34
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation and perform a JSON schema validation on the returned grant data structure
35
    ...    Pre-conditions: 
Michele Carignani's avatar
Michele Carignani committed
36
    ...    Reference: Clause 9.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v2.4.1
37
    ...    Config ID: Config_prod_NFVO
38
39
    ...    Applicability: The NFVO can not decide immediately what to respond to a grant request
    ...    Post-Conditions: The grant information is available to the VNFM.
AHMADABB's avatar
AHMADABB committed
40
    Send Request Grant Request in Asynchronous mode
41
    Check HTTP Response Status Code Is    202
42
    Check Operation Occurrence Id existence 
AHMADABB's avatar
AHMADABB committed
43
    Check HTTP Response Body Json Schema Is    grant
44
    Wait for individual grant successful notification 
45

AHMADABB's avatar
AHMADABB committed
46
Requests a grant for a particular VNF lifecycle operation - Forbidden 
AHMADABB's avatar
AHMADABB committed
47
48
    [Documentation]    Test ID: 7.3.2.1.3
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Forbidden 
Najam UI Hassan's avatar
Najam UI Hassan committed
49
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation and the grant is rejected
root's avatar
root committed
50
    ...    Pre-conditions: none
Michele Carignani's avatar
Michele Carignani committed
51
    ...    Reference: Clause 9.4.2.3.1 - ETSI GS NFV-SOL 003 [1] v2.4.1
52
    ...    Config ID: Config_prod_NFVO
AHMADABB's avatar
AHMADABB committed
53
54
    ...    Applicability: none
    ...    Post-Conditions: none
Najam UI Hassan's avatar
Najam UI Hassan committed
55
    Send Request for a new Grant Forbiden Operation
AHMADABB's avatar
AHMADABB committed
56
57
    Check HTTP Response Status Code Is    403
    Check HTTP Response Body Json Schema Is    ProblemDetails
58
59

GET Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
60
61
    [Documentation]    Test ID: 7.3.2.1.4
    ...    Test title: GET Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
62
    ...    Test objective: The objective is to test that GET method is not allowed for Life cycle operation granting 
AHMADABB's avatar
AHMADABB committed
63
    ...    Pre-conditions: none
Michele Carignani's avatar
Michele Carignani committed
64
    ...    Reference: Clause 9.4.2.3.2 - ETSI GS NFV-SOL 003 [1] v2.4.1
65
    ...    Config ID: Config_prod_NFVO
AHMADABB's avatar
AHMADABB committed
66
67
68
69
    ...    Applicability: none
    ...    Post-Conditions:   none
    Get Grants
    Check HTTP Response Status Code Is    405
70
    
71
PUT Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
72
73
     [Documentation]    Test ID: 7.3.2.1.5
    ...    Test title: PUT Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
74
    ...    Test objective: The objective is to test that PUT method is not allowed for Life cycle operation granting 
AHMADABB's avatar
AHMADABB committed
75
    ...    Pre-conditions: none
Michele Carignani's avatar
Michele Carignani committed
76
    ...    Reference: Clause 9.4.2.3.3 - ETSI GS NFV-SOL 003 [1] v2.4.1
77
    ...    Config ID: Config_prod_NFVO
AHMADABB's avatar
AHMADABB committed
78
79
80
81
82
    ...    Applicability: none
    ...    Post-Conditions: none
    Put Grants
    Check HTTP Response Status Code Is    405
    
83
PATCH Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
84
85
    [Documentation]    Test ID: 7.3.2.1.6
    ...    Test title: PATCH Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
86
    ...    Test objective: The objective is to test that PATCH method is not allowed for Life cycle operation granting  
AHMADABB's avatar
AHMADABB committed
87
    ...    Pre-conditions: none
Michele Carignani's avatar
Michele Carignani committed
88
    ...    Reference: Clause 9.4.2.3.4 - ETSI GS NFV-SOL 003 [1] v2.4.1
89
    ...    Config ID: Config_prod_NFVO
AHMADABB's avatar
AHMADABB committed
90
91
92
93
    ...    Applicability: none
    ...    Post-Conditions: none 
    Patch Grants
    Check HTTP Response Status Code Is    405
94
    
AHMADABB's avatar
AHMADABB committed
95
96
97
DELETE Grants - Method not implemented
    [Documentation]    Test ID: 7.3.2.1.7
    ...    Test title: DELETE Grants - Method not implemented
AHMADABB's avatar
AHMADABB committed
98
    ...    Test objective: The objective is to test that DELETE method is not allowed for Life cycle operation granting  
AHMADABB's avatar
AHMADABB committed
99
    ...    Pre-conditions: none
Michele Carignani's avatar
Michele Carignani committed
100
    ...    Reference: Clause 9.4.2.3.5 - ETSI GS NFV-SOL 003 [1] v2.4.1
101
    ...    Config ID: Config_prod_NFVO
AHMADABB's avatar
AHMADABB committed
102
    ...    Applicability: none
root's avatar
root committed
103
    ...    Post-Conditions:  resources are not deleted
AHMADABB's avatar
AHMADABB committed
104
105
    Delete Grants
    Check HTTP Response Status Code Is    405
root's avatar
root committed
106
    Get an individual grant - Successful
107
108
    
*** Keywords ***
109
Wait for individual grant successful notification
Giacomo Bernini's avatar
Giacomo Bernini committed
110
    Wait Until Keyword Succeeds    ${retry}   ${polling}    Get an individual grant - Successful
AHMADABB's avatar
AHMADABB committed
111
112
113
Send Request Grant Request in Synchronous mode
    Log    Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
    Pass Execution If    ${SYNC_MODE} == 0    The Granting process is asynchronous mode. Skipping the test
114
115
116
    Set Headers    {"Accept": "${ACCEPT}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
117
    ${body}=    Get File    jsons/grantRequest.json
Elian Kraja's avatar
Elian Kraja committed
118
119
    Post    ${apiRoot}/${apiName}/${apiVersion}/grants    ${body}
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
120
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
121
122
123
124
125
126
127
128
129
130
    
Send Request Grant Request in Asynchronous mode
    Log    Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
    Pass Execution If    ${SYNC_MODE} == 1    The Granting process is synchronous mode. Skipping the test
    Set Headers    {"Accept": "${ACCEPT}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    ${body}=    Get File    jsons/grantRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/grants    ${body}
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
131
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
132
    
Najam UI Hassan's avatar
Najam UI Hassan committed
133
Send Request for a new Grant Forbiden Operation   
AHMADABB's avatar
AHMADABB committed
134
135
136
137
138
139
140
141
    Log    Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
    Log    The grant request should be rejected
    Set Headers    {"Accept": "${ACCEPT}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    ${body}=    Get File    jsons/grantRejectedRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/grants    ${body}
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
142
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
143
   
144
145
146
147
Send Request Grant Request
    Set Headers    {"Accept": "${ACCEPT}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
Elian Kraja's avatar
Elian Kraja committed
148
    ${body}=    Get File    jsons/grantRequest.json
149
150
151
152
153
    Post    ${apiRoot}/${apiName}/${apiVersion}/grants    ${body}    allow_redirects=false
    ${resp}    Output    response
    ${result}=    evaluate    json.loads(json.dumps(${resp}))    json
    Log  ${result}
    Set Suite Variable    ${response}    ${result}
AHMADABB's avatar
AHMADABB committed
154
    
155
156
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
157
    Should Be Equal As Strings    ${response['status']}    ${expected_status}
158
159
    Log    Status code validated

160
Check Operation Occurrence Id existence 
Elian Kraja's avatar
Elian Kraja committed
161
    ${occId}=    Get Value From Json    ${response['headers']}    $..Location
162
163
    Should Not Be Empty    ${occId}

164
165
Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
166
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
167
168
169
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
AHMADABB's avatar
AHMADABB committed
170
171
    [Arguments]    ${input}
    ${schema} =    Catenate    ${input}    .schema.json
Elian Kraja's avatar
Elian Kraja committed
172
    Validate Json    ${schema}    ${response['body']}
173
174
175
176
177
    
Get an individual grant - Successful
    log    Trying to read an individual grant
    Set Headers    {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
178
    Get    ${response['headers']['Location']}
179
180
    Log    Validate Status code
    Integer    response status    200
AHMADABB's avatar
AHMADABB committed
181
182
183
184
185
186
187
    
Get Grants
    Log    Trying to perform a GET. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/grants
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
188
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
189
190
    
Put Grants
AHMADABB's avatar
AHMADABB committed
191
    Log    Trying to perform a PUT. This method should not be implemented
AHMADABB's avatar
AHMADABB committed
192
193
194
195
    Set Headers  {"Accept":"${ACCEPT}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Put    ${apiRoot}/${apiName}/${apiVersion}/grants
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
196
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
197
198
    
Patch Grants
AHMADABB's avatar
AHMADABB committed
199
    Log    Trying to perform a PATCH. This method should not be implemented
AHMADABB's avatar
AHMADABB committed
200
201
202
203
    Set Headers  {"Accept":"${ACCEPT}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Patch    ${apiRoot}/${apiName}/${apiVersion}/grants
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
204
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
205
206
207
    
    
Delete Grants
AHMADABB's avatar
AHMADABB committed
208
    Log    Trying to perform a DELETE. This method should not be implemented
AHMADABB's avatar
AHMADABB committed
209
210
211
212
    Set Headers  {"Accept":"${ACCEPT}"} 
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Delete    ${apiRoot}/${apiName}/${apiVersion}/grants
    ${body}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
213
    Set Suite Variable    ${response}    ${body}
AHMADABB's avatar
AHMADABB committed
214
    
root's avatar
root committed
215