Grants.robot 6.72 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
12
*** Variables ***
${response}    {}

13
*** Test Cases ***
14
Request a new Grant - Synchronous mode
15
    [Tags]    synchronous-mode
16
17
18
19
20
21
22
23
    [Documentation]    Test ID: 9.4.2.1
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Synchronous mode
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation 
    ...    Pre-conditions: 
    ...    Reference: section 9.4.2 - SOL003 v2.4.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The NFVO can decide immediately what to respond to a grant request
    ...    Post-Conditions: The grant information is available to the VNFM.
24
25
    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
26
27
28
29
    Send Request Grant Request
    Check HTTP Response Status Code Is    201
    Check HTTP Response Header Contains    Location
    Check HTTP Response Body Json Schema Is    grant.schema.json
30
    Log    Validation OK
31

32
Request a new Grant - Asynchronous mode
33
    [Tags]    no-synchronous-mode
34
35
36
37
38
39
40
41
    [Documentation]    Test ID: 9.4.2.2
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Asynchronous mode
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation 
    ...    Pre-conditions: 
    ...    Reference: section 9.4.2 - SOL003 v2.4.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: The NFVO can not decide immediately what to respond to a grant request
    ...    Post-Conditions: The grant information is available to the VNFM.
42
43
    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
44
45
46
    Send Request Grant Request
    Check HTTP Response Status Code Is    202
    Check HTTP Response Header Contains    Location
47
    #Check HTTP Response Body Json Schema Is    grant.schema.json
48
    Wait Until Keyword Succeeds    2 min   10 sec    Get an individual grant - Successful
49
    Log    Validation OK
50

51
52
53
54
55
56
57
58
59
Request a new Grant - Forbidden
    [Documentation]    Test ID: 9.4.2.3
    ...    Test title: Requests a grant for a particular VNF lifecycle operation - Forbidden
    ...    Test objective: The objective is to request a grant for a particular VNF lifecycle operation 
    ...    Pre-conditions: The grant should not be accorded
    ...    Reference: section 9.4.2 - SOL003 v2.4.1
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions: 
60
61
62
63
64
    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}"}
Elian Kraja's avatar
Elian Kraja committed
65
    ${body}=    Get File    jsons/grantRejectedRequest.json
66
67
68
    Post    ${apiRoot}/${apiName}/${apiVersion}/grants    ${body}
    Integer    response status    403
    Log    Status code validated
69
    ${problemDetails}=    Output    response body
Elian Kraja's avatar
Elian Kraja committed
70
    Validate Json    ProblemDetails.schema.json    ${problemDetails}
71
    Log    Validation OK
72
73
74
75
76
77
78
79
80

GET Grants - Method not implemented
    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
    Log    Validate Status code
    Integer    response status    405
    
81
PUT Grants - Method not implemented
82
83
84
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
85
    Put    ${apiRoot}/${apiName}/${apiVersion}/grants    
86
87
88
    Log    Validate Status code
    Integer    response status    405

89
PATCH Grants - Method not implemented
90
91
92
    log    Trying to perform a PATCH. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
93
    Patch    ${apiRoot}/${apiName}/${apiVersion}/grants    
94
95
96
97
    Log    Validate Status code
    Output    response
    Integer    response status    405

98
DELETE Grants - Method not implemented
99
100
101
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
102
    Delete    ${apiRoot}/${apiName}/${apiVersion}/grants
103
104
    Log    Validate Status code
    Integer    response status    405
105
106
107
108
109
110
111
    
    
*** Keywords ***
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
112
    ${body}=    Get File    jsons/grantRequest.json
113
114
115
116
117
    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}
118
119
120

Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
121
    Should Be Equal As Strings    ${response['status']}    ${expected_status}
122
123
124
125
    Log    Status code validated

Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
126
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
127
128
129
130
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${schema}
131
    Validate Json    ${schema}    ${response['body']}
132
133
134
135
136
137
    Log    Json Schema Validation OK
    
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}"}
138
    Get    ${response['headers']['Location']}
139
140
    Log    Validate Status code
    Integer    response status    200
141
    ${result}    Output    response body
Elian Kraja's avatar
Elian Kraja committed
142
    Validate Json    grant.schema.json    ${result}
143
    Log    Validation OK
144

145