Configuration.robot 10.4 KB
Newer Older
1
*** Settings ***
mengxuan.zhao's avatar
mengxuan.zhao committed
2
Resource    environment/variables.txt 
3
Library    REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false
4
5
6
7
8
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    OperatingSystem
Library    DependencyLibrary

Elian Kraja's avatar
Elian Kraja committed
9
*** Test Cases ***
10
Set new VNF Configuration
11
    [Documentation]    Test ID: 6.3.1.1.1
12
    ...    Test title: Set a new VNF Configuration
13
14
    ...    Test objective: The objective is to test the creation of a new VNF configuration and perform a JSON schema validation of the returned configuration data structure
    ...    Pre-conditions: A VNF instance is instantiated
Michele Carignani's avatar
Michele Carignani committed
15
    ...    Reference: Clause 9.4.2.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
16
17
    ...    Config ID: Config_prod_VE
    ...    Applicability: The VNF supports the generation of HTTP Etag opaque identifiers
18
    ...    Post-Conditions: The configuration is successfully set in the VNF and it matches the issued configuration
19
20
    Send VNF configuration
    Check HTTP Response Status Code Is    200
21
    Check HTTP Response Header Contains    ETag
22
    Check HTTP Response Body Json Schema Is   vnfConfigModifications
23
    Check Postcondition VNF Is Configured
24

25
26
Get information about a VNF configuration
    [Tags]    no-etag
27
    [Documentation]    Test ID: 6.3.1.1.2
28
    ...    Test title: Get information about a VNF configuration
29
30
    ...    Test objective: The objective is to test the retrieval of an existing VNF instance configuration and perform a JSON schema validation of the collected configuration data structure
    ...    Pre-conditions: A VNF instance is instantiated. The VNF instance is already configured.
Michele Carignani's avatar
Michele Carignani committed
31
    ...    Reference: Clause 9.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
32
33
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
34
    ...    Post-Conditions: none
Giacomo Bernini's avatar
Giacomo Bernini committed
35
36
    Get VNF configuration
    Check HTTP Response Status Code Is    200
37
    Check HTTP Response Body Json Schema Is   vnfConfiguration
38

39
Get information about a VNF configuration with HTTP Etag
40
    [Tags]    etag
41
    [Documentation]    Test ID: 6.3.1.1.3
42
    ...    Test title: Get information about a VNF configuration with HTTP Etag
43
44
    ...    Test objective: The objective is to test the retrieval of an existing VNF instance configuration, check the generation by the VNF of an HTTP Etag opaque identifier, and perform a JSON schema validation of the collected configuration data structure
    ...    Pre-conditions:  A VNF instance is instantiated. The VNF instance is already configured
Michele Carignani's avatar
Michele Carignani committed
45
    ...    Reference: Clause 9.4.2.3.2 - ETSI GS NFV-SOL 002 [2] v2.6.1
46
    ...    Config ID: Config_prod_VE
Giacomo Bernini's avatar
Giacomo Bernini committed
47
    ...    Applicability: The VNF supports the generation of HTTP Etag opaque identifiers
48
    ...    Post-Conditions: none
49
    Get VNF configuration
Giacomo Bernini's avatar
Giacomo Bernini committed
50
    Check HTTP Response Status Code Is    200
51
    Check HTTP Response Header Contains    ETag
52
    Check HTTP Response Body Json Schema Is   vnfConfiguration
Giacomo Bernini's avatar
Giacomo Bernini committed
53

54
Set new VNF Configuration - HTTP Etag precondition unsuccessful
55
    [Tags]    etag
56
57
58
59
    [Documentation]    Test ID: 6.3.1.1.4
    ...    Test title: Set a new VNF Configuration - HTTP Etag precondition unsuccessful
    ...    Test objective: The objective is to test the unsuccess in setting a duplication of VNF configuration identified by an already used HTTP Etag identifier. The test also checks the JSON schema of the unsuccessful operation HTTP response.
    ...    Pre-conditions:  A VNF instance is instantiated. The VNF instance is already configured (Test ID 6.3.1.1.1) with a given HTTP Etag identifier.
Michele Carignani's avatar
Michele Carignani committed
60
    ...    Reference: Clause 9.4.2.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
61
    ...    Config ID: Config_prod_VE
Giacomo Bernini's avatar
Giacomo Bernini committed
62
    ...    Applicability: The VNF supports the generation of HTTP Etag opaque identifiers
63
    ...    Post-Conditions:  The VNF configuration is not modified by the unsuccessful operation and it matches the configuration issued in Test ID 6.3.1.1.1
Giacomo Bernini's avatar
Giacomo Bernini committed
64
65
66
    Send Duplicated VNF configuration
    Check HTTP Response Status Code Is    412
    Check HTTP Response Body Json Schema Is   ProblemDetails
67
    Check Postcondition VNF Configuration Unmodified (Implicit)
Giacomo Bernini's avatar
Giacomo Bernini committed
68

69
POST VNF Configuration - Method not implemented
70
    [Documentation]    Test ID: 6.3.1.1.5
71
72
    ...    Test title: POST VNF Configuration - Method not implemented
    ...    Test objective: The objective is to test that POST method is not allowed to create a new VNF configuration
73
    ...    Pre-conditions: A VNF instance is instantiated. The VNF instance is alrseady configured
Michele Carignani's avatar
Michele Carignani committed
74
    ...    Reference: Clause 9.4.2.3.1 - ETSI GS NFV-SOL 002 [2] v2.6.1
75
76
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
77
    ...    Post-Conditions: none
78
    Send POST Request for VNF Configuration
79
    Check HTTP Response Status Code Is    405 
80
81

PUT VNF Configuration - Method not implemented
82
    [Documentation]    Test ID: 6.3.1.1.6
83
84
    ...    Test title: PUT VNF Configuration - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify an existing VNF configuration
85
    ...    Pre-conditions:  A VNF instance is instantiated. The VNF instance is already configured
Michele Carignani's avatar
Michele Carignani committed
86
    ...    Reference: Clause 9.4.2.3.3 - ETSI GS NFV-SOL 002 [2] v2.6.1
87
88
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
89
    ...    Post-Conditions: none
90
91
92
93
    Send PUT Request for VNF Configuration
    Check HTTP Response Status Code Is    405

DELETE VNF Configuration - Method not implemented
94
    [Documentation]    Test ID: 6.3.1.1.7
95
96
    ...    Test title: Delete VNF Configuration - Method not implemented
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete an existing VNF configuration
97
    ...    Pre-conditions:  A VNF instance is instantiated. The VNF instance is already configured
Michele Carignani's avatar
Michele Carignani committed
98
    ...    Reference: Clause 9.4.2.3.5 - ETSI GS NFV-SOL 002 [2] v2.6.1
99
100
    ...    Config ID: Config_prod_VE
    ...    Applicability: none
101
    ...    Post-Conditions: The VNF configuration is not deleted by the unsuccessful operation
102
103
    Send DELETE Request for VNF Configuration
    Check HTTP Response Status Code Is    405
104
    Check Postcondition VNF Configuration Exists
Giacomo Bernini's avatar
Giacomo Bernini committed
105
    
106
*** Keywords ***    
Giacomo Bernini's avatar
Giacomo Bernini committed
107
108
109
110
Get VNF configuration
    Log    Query VNF The GET method queries information about a configuration.
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
111
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Giacomo Bernini's avatar
Giacomo Bernini committed
112
    Log    Execute Query and validate response
Elian Kraja's avatar
Elian Kraja committed
113
114
    Get    ${apiRoot}/${apiName}/${apiVersion}/configuration
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
115
    Set Suite Variable    ${response}    ${output}
Giacomo Bernini's avatar
Giacomo Bernini committed
116
117
118

Send VNF configuration
    log    Trying to perform a PATCH. This method modifies the configuration    
119
120
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"} 
121
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
122
    ${body}=    Get File    jsons/vnfConfigModifications.json
Elian Kraja's avatar
Elian Kraja committed
123
124
    Patch    ${apiRoot}/${apiName}/${apiVersion}/configuration    ${body}
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
125
    Set Suite Variable    ${response}    ${output}
126

Giacomo Bernini's avatar
Giacomo Bernini committed
127
128
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
Elian Kraja's avatar
Elian Kraja committed
129
    Should Be Equal As Strings    ${response['status']}    ${expected_status}
Giacomo Bernini's avatar
Giacomo Bernini committed
130
131
132
133
    Log    Status code validated

Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
Giacomo Bernini's avatar
Giacomo Bernini committed
134
135
    Log    ${response['headers']}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
Giacomo Bernini's avatar
Giacomo Bernini committed
136
137
138
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
139
    [Arguments]    ${input}
140
141
    Run Keyword If    '${input}' == 'ProblemDetails'    Should Contain    ${response['headers']['Content-Type']}    application/problem+json
    ...    ELSE    Should Contain    ${response['headers']['Content-Type']}    application/json
142
    ${schema}=    Catenate    SEPARATOR=    ${input}    .schema.json
Giacomo Bernini's avatar
Giacomo Bernini committed
143
    Validate Json    ${schema}    ${response['body']}
Giacomo Bernini's avatar
Giacomo Bernini committed
144
    Log    Json Schema Validation OK
145
      
146
Check Postcondition VNF Configuration Unmodified (Implicit)
147
148
    Log    Check Implicit Postcondition
    Check Postcondition VNF Is Configured
149
150
151
152

Check Postcondition VNF Configuration Exists
    Log    Check Postcondition VNF exists
    Check Postcondition VNF Is Configured
Giacomo Bernini's avatar
Giacomo Bernini committed
153
154
    
Check Postcondition VNF Is Configured
155
    Log    Check Postcondition for VNF Configuration
Giacomo Bernini's avatar
Giacomo Bernini committed
156
    Get VNF configuration
Elian Kraja's avatar
Elian Kraja committed
157
158
    ${input_file}=    Get File    jsons/vnfConfigModifications.json
    ${input}=    evaluate    json.loads('''${input_file}''')    json
159
    Should Be Equal As Strings  ${response['body']}    ${input} 
160
161

Send Duplicated VNF configuration
162
    Depends On Test    Send VNF configuration    # If the previous test scceeded, it means that Etag has been modified
163
164
165
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"}
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
166
    Set Headers    {"If-Match": "${etag}"}
167
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
168
    ${body}=    Get File    jsons/vnfConfigModifications.json
Elian Kraja's avatar
Elian Kraja committed
169
170
    Patch    ${apiRoot}/${apiName}/${apiVersion}/configuration    ${body}
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
171
    Set Suite Variable    ${response}    ${output}
172
173
174
175

Send POST Request for VNF Configuration
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
176
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Elian Kraja's avatar
Elian Kraja committed
177
178
    Post    ${apiRoot}/${apiName}/${apiVersion}/configuration
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
179
    Set Suite Variable    ${response}    ${output}
180
181
182
183
    
Send PUT Request for VNF Configuration
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
184
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Elian Kraja's avatar
Elian Kraja committed
185
186
    Put    ${apiRoot}/${apiName}/${apiVersion}/configuration
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
187
    Set Suite Variable    ${response}    ${output}
188
189
190
191
    
Send DELETE Request for VNF Configuration
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
192
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Elian Kraja's avatar
Elian Kraja committed
193
194
    Delete    ${apiRoot}/${apiName}/${apiVersion}/configuration
    ${output}=    Output    response
Giacomo Bernini's avatar
Giacomo Bernini committed
195
    Set Suite Variable    ${response}    ${output}