IndividualAlarm.robot 8.92 KB
Newer Older
1
2
*** Settings ***
# Suite setup     Expect spec    SOL003-VNFLifecycleManagement-API.yaml
3
Resource    environment/variables.txt  
4
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}     ssl_verify=false
5
6
7
8
9
10
Library    OperatingSystem
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    DependencyLibrary


11
12
13
14
*** Variables **
${original_etag}    1234


Elian Kraja's avatar
Elian Kraja committed
15
*** Test Cases ***
16
POST Alarm - Method not implemented
17
    [Documentation]    Test ID: 6.3.4.2.1
18
    ...    Test title: POST Alarm - Method not implemented
19
20
    ...    Test objective: The objective is to test that the method is not implemented
    ...    Pre-conditions: 
Michele Carignani's avatar
Michele Carignani committed
21
    ...    Reference: Clause 7.4.3.3.1 - ETSI GS NFV-SOL 002 [2] v2.6.1
22
23
24
25
26
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions: none
    POST Alarm Task
    Check HTTP Response Status Code Is    405
27

28

29
GET information about an individual alarm
30
    [Documentation]    Test ID: 6.3.4.2.2
31
    ...    Test title: GET information about an individual alarm
32
33
    ...    Test objective: The objective is to read an individual alarm.
    ...    Pre-conditions: The related alarm exists
Michele Carignani's avatar
Michele Carignani committed
34
    ...    Reference: Clause 7.4.3.3.2  - ETSI GS NFV-SOL 002 [2] v2.6.1
35
36
37
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions:   
38
39
40
41
    GET Alarm Task
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    alarm
    
42

43

root's avatar
root committed
44
PUT Individual Alarm - Method not implemented
45
     [Documentation]    Test ID: 6.3.4.2.3
root's avatar
root committed
46
    ...    Test title: PUT Individual Alarm - Method not implemented
47
48
    ...    Test objective: The objective is to test that the method is not implemented
    ...    Pre-conditions: 
Michele Carignani's avatar
Michele Carignani committed
49
    ...    Reference: Clause 7.4.3.3.3 - ETSI GS NFV-SOL 002 [2] v2.6.1
50
51
52
53
54
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions: none
    PUT Alarm Task
    Check HTTP Response Status Code Is    405
55

56

root's avatar
root committed
57
PATCH Individual Alarm
58
    [Documentation]    Test ID: 6.3.4.2.4
root's avatar
root committed
59
    ...    Test title: PATCH Individual Alarm
60
61
    ...    Test objective: The objective is to Modify an individual alarm resource
    ...    Pre-conditions: The related alarm exists
Michele Carignani's avatar
Michele Carignani committed
62
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
63
64
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
65
    ...    Post-Conditions: none
Giacomo Bernini's avatar
Giacomo Bernini committed
66
    PATCH Alarm Task
67
68
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is     alarmModifications
69
    
root's avatar
root committed
70
PATCH Individual Alarm - Precondition failed
71
    [Documentation]    Test ID: 6.3.4.2.5
root's avatar
root committed
72
    ...    Test title: PATCH Individual Alarm - Precondition failed
root's avatar
root committed
73
    ...    Test objective: The objective is to attempt to Modify an individual alarm resource, where the precondition was not met
74
    ...    Pre-conditions: The related alarm exists
Michele Carignani's avatar
Michele Carignani committed
75
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
76
77
78
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions: The alarm resource is not modified
79
    PATCH Alarm Task with wrong precondition
80
81
82
    Check HTTP Response Status Code Is    412
    Check HTTP Response Body Json Schema Is     ProblemDetails
    
root's avatar
root committed
83
PATCH Individual Alarm - Conflict
84
    [Documentation]    Test ID: 6.3.4.2.6
root's avatar
root committed
85
    ...    Test title: PATCH Individual Alarm - Conflict
86
87
    ...    Test objective: The objective is to Modify an individual alarm resource
    ...    Pre-conditions: The related alarm exists
Michele Carignani's avatar
Michele Carignani committed
88
    ...    Reference: Clause 7.4.3.3.4 - ETSI GS NFV-SOL 002 [2] v2.6.1
89
90
91
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
    ...    Post-Conditions: The alarm resource is not modified
92
    PATCH Alarm Task
93
94
95
96
    Check HTTP Response Status Code Is    409
    Check HTTP Response Body Json Schema Is     ProblemDetails
    

root's avatar
root committed
97
DELETE Individual Alarm - Method not implemented
98
    [Documentation]    Test ID: 6.3.4.2.7
root's avatar
root committed
99
    ...    Test title: DELETE Individual Alarm - Method not implemented
100
101
    ...    Test objective: The objective is to test that the method is not implemented
    ...    Pre-conditions: 
Michele Carignani's avatar
Michele Carignani committed
102
    ...    Reference: Clause 7.4.3.3.5 - ETSI GS NFV-SOL 002 [2] v2.6.1
103
104
    ...    Config ID: Config_prod_VNFM
    ...    Applicability: 
105
    ...    Post-Conditions: alarm not deleted
106
107
108
109
110
111
112
    DELETE Alarm Task
    Check HTTP Response Status Code Is    405

*** Keywords ***
POST Alarm Task
    log    Trying to perform a POST. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
113
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
114
115
    Post    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
116
	Set Global Variable    ${response}    ${outputResponse}
117
118
119
PUT Alarm Task
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
120
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Giacomo Bernini's avatar
Giacomo Bernini committed
121
    ${body}=    Get File    jsons/alarmModifications.json
122
123
    Put    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}     ${body}
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
124
	Set Global Variable    ${response}    ${outputResponse}
125
PATCH Alarm Task
126
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
127
128
129
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"}
    Set Headers  {"If-Match": "${original_etag[0]}"}
130
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
Elian Kraja's avatar
Elian Kraja committed
131
    ${body}=    Get File    jsons/alarmModifications.json
132
    Patch    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}    ${body}
133
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
134
	Set Global Variable    ${response}    ${outputResponse}
135
136
137
138
PATCH Alarm Task with wrong precondition
    log    Trying to perform a PATCH. This method modifies an individual alarm resource
    Set Headers  {"Accept":"${ACCEPT}"} 
    Set Headers  {"Content-Type": "${CONTENT_TYPE_PATCH}"}
139
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
140
141
142
    ${body}=    Get File    jsons/alarmModifications.json
    Patch    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}    ${body}
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
143
	Set Global Variable    ${response}    ${outputResponse}	
144
DELETE Alarm Task
145
146
    log    Trying to perform a DELETE. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
147
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
148
    Delete    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}
149
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
150
	Set Global Variable    ${response}    ${outputResponse}			
151
152
153
GET Alarm Task	
	Log    Query VNF The GET method queries information about individual alarm.
    Set Headers  {"Accept":"${ACCEPT}"}  
154
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
155
156
157
158
159
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/alarms/${alarmId}
    ${etag}    Output    response headers ETag
    Set Suite Variable    &{original_etag}    ${etag}
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
160
	Set Global Variable    ${response}    ${outputResponse}
161
162
163
GET Alarm Task with filter
	Log    Query VNF The GET method queries information about individual alarm with filters.
    Set Headers  {"Accept":"${ACCEPT}"}  
164
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
165
166
167
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/alarms?${alarm_filter}=${managedObjectId} 
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
168
	Set Global Variable    ${response}    ${outputResponse}	
169
170
171
GET Alarm Task with invalid filter
	Log    Query VNF The GET method queries information about individual alarm with filters.
    Set Headers  {"Accept":"${ACCEPT}"}  
172
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
173
174
175
    Log    Execute Query and validate response
    Get    ${apiRoot}/${apiName}/${apiVersion}/alarms?${invalid_alarm_filter}=${managedObjectId} 
    ${outputResponse}=    Output    response
Elian Kraja's avatar
Elian Kraja committed
176
	Set Global Variable    ${response}    ${outputResponse}	
Giacomo Bernini's avatar
Giacomo Bernini committed
177
178
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}    
Elian Kraja's avatar
Elian Kraja committed
179
    Should Be Equal As Strings    ${response['status']}    ${expected_status}
Giacomo Bernini's avatar
Giacomo Bernini committed
180
181
182
183
    Log    Status code validated 
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
184
185
    Run Keyword If    '${input}' == 'ProblemDetails'    Should Contain    ${response['headers']['Content-Type']}    application/problem+json
    ...    ELSE    Should Contain    ${response['headers']['Content-Type']}    application/json
Giacomo Bernini's avatar
Giacomo Bernini committed
186
187
    ${schema} =    Catenate    SEPARATOR=    ${input}	.schema.json
    Validate Json    ${schema}    ${response['body']}
root's avatar
root committed
188
    Log    Json Schema Validation OK