blob: b2aec0e1c0fd7827be6ba748a0ec0290fab078a8 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishing85536662017-03-03 10:49:58 -06002Documentation Verify REST services Get/Put/Post/Delete.
Chris Austenb29d2e82016-06-07 12:25:35 -05003
George Keishing97651c72016-10-04 00:44:15 -05004Resource ../lib/rest_client.robot
George Keishingd55a4be2016-08-26 03:28:17 -05005Resource ../lib/openbmc_ffdc.robot
George Keishing7230bbc2016-12-14 07:02:48 -06006Resource ../lib/resource.txt
George Keishing85536662017-03-03 10:49:58 -06007Library Collections
Gunnar Millseac1af22016-11-14 15:30:09 -06008Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -05009
Chris Austenb29d2e82016-06-07 12:25:35 -050010*** Variables ***
11
Chris Austenb29d2e82016-06-07 12:25:35 -050012*** Test Cases ***
Chris Austenb29d2e82016-06-07 12:25:35 -050013
George Keishing89f7c1f2017-05-03 16:08:37 -050014REST Login Session To BMC
15 [Documentation] Test REST session log-in.
16 [Tags] REST_Login_Session_To_BMC
17
18 Initialize OpenBMC
19 # Raw GET REST operation to verify session is established.
20 ${resp}= Get Request openbmc /xyz/openbmc_project/
21 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
22
23
24REST Logout Session To BMC
25 [Documentation] Test REST session log-out.
26 [Tags] REST_Logout_Session_To_BMC
27
28 Initialize OpenBMC
29 Log Out OpenBMC
30 # Raw GET REST operation to verify session is logout.
31 ${resp}= Get Request openbmc /xyz/openbmc_project/
32 Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED}
33
34
George Keishing6715f312017-05-10 03:22:40 -050035REST Delete All Sessions And Expect Error
36 [Documentation] Test REST empty cache using delete operation.
37 [Tags] REST_Delete_All_Sessions_And_Expect_Error
38
39 # Throws exception:
40 # Non-existing index or alias 'openbmc'.
41
42 Initialize OpenBMC
43 Delete All Sessions
44 # Raw GET REST operation and expect exception error.
45 Run Keyword And Expect Error
46 ... Non-existing index or alias 'openbmc'.
47 ... Get Request openbmc /xyz/openbmc_project/
48
49
50Verify REST JSON Data On Success
51 [Documentation] Verify JSON data success response messages.
52 [Tags] Verify_REST_JSON_Data_On_Success
53 # Example:
54 # Response code:200, Content:{
55 # "data": [
56 # "/xyz/openbmc_project/sensors",
57 # "/xyz/openbmc_project/inventory",
58 # "/xyz/openbmc_project/software",
59 # "/xyz/openbmc_project/object_mapper",
60 # "/xyz/openbmc_project/logging"
61 # ],
62 # "message": "200 OK",
63 # "status": "ok"
64 # }
65
66 ${resp}= OpenBMC Get Request /xyz/openbmc_project/
67 ${jsondata}= To JSON ${resp.content}
68 Should Not Be Empty ${jsondata["data"]}
69 Should Be Equal As Strings ${jsondata["message"]} 200 OK
70 Should Be Equal As Strings ${jsondata["status"]} ok
71
72
73Verify REST JSON Data On Failure
74 [Documentation] Verify JSON data failure response messages.
75 [Tags] Verify_REST_JSON_Data_On_Failure
76 # Example:
77 # Response code:404, Content:{
78 # "data": {
79 # "description": "org.freedesktop.DBus.Error.FileNotFound: path or object not found: /xyz/idont/exist"
80 # },
81 # "message": "404 Not Found",
82 # "status": "error"
83 # }
84
85 ${resp}= OpenBMC Get Request /xyz/idont/exist/
86 ${jsondata}= To JSON ${resp.content}
87 Should Be Equal As Strings
88 ... ${jsondata["data"]["description"]} org.freedesktop.DBus.Error.FileNotFound: path or object not found: /xyz/idont/exist
89 Should Be Equal As Strings ${jsondata["message"]} 404 Not Found
90 Should Be Equal As Strings ${jsondata["status"]} error
91
92
George Keishing85536662017-03-03 10:49:58 -060093Get Response Codes
94 [Documentation] REST "Get" response status test.
95 #--------------------------------------------------------------------
96 # Expect status URL Path
97 #--------------------------------------------------------------------
98 ${HTTP_OK} /
99 ${HTTP_OK} /xyz/
100 ${HTTP_OK} /xyz/openbmc_project/
101 ${HTTP_OK} /xyz/openbmc_project/enumerate
102 ${HTTP_NOT_FOUND} /i/dont/exist/
Chris Austenb29d2e82016-06-07 12:25:35 -0500103
George Keishing85536662017-03-03 10:49:58 -0600104 [Tags] Get_Response_Codes
105 [Template] Execute Get And Check Response
Chris Austenb29d2e82016-06-07 12:25:35 -0500106
Chris Austenb29d2e82016-06-07 12:25:35 -0500107
George Keishing85536662017-03-03 10:49:58 -0600108Get Data
109 [Documentation] REST "Get" request url and expect the
110 ... response OK and data non empty.
111 #--------------------------------------------------------------------
112 # URL Path
113 #--------------------------------------------------------------------
114 /xyz/openbmc_project/
115 /xyz/openbmc_project/list
116 /xyz/openbmc_project/enumerate
Chris Austenb29d2e82016-06-07 12:25:35 -0500117
George Keishing85536662017-03-03 10:49:58 -0600118 [Tags] Get_Data
119 [Template] Execute Get And Check Data
Chris Austenb29d2e82016-06-07 12:25:35 -0500120
Chris Austenb29d2e82016-06-07 12:25:35 -0500121
George Keishing85536662017-03-03 10:49:58 -0600122Get Data Validation
123 [Documentation] REST "Get" request url and expect the
124 ... pre-defined string in response data.
125 #--------------------------------------------------------------------
126 # URL Path Expect Data
127 #--------------------------------------------------------------------
128 /xyz/openbmc_project/ /xyz/openbmc_project/logging
129 /i/dont/exist/ path or object not found: /i/dont/exist
130
131 [Tags] Get_Data_Validation
132 [Template] Execute Get And Verify Data
133
134
135Put Response Codes
136 [Documentation] REST "Put" request url and expect the REST pre-defined
137 ... codes.
138 #--------------------------------------------------------------------
139 # Expect status URL Path
140 #--------------------------------------------------------------------
141 ${HTTP_METHOD_NOT_ALLOWED} /
142 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
143 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
144 ${HTTP_METHOD_NOT_ALLOWED} /xyz/list
145 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
146
147 [Tags] Put_Response_Codes
148 [Template] Execute Put And Check Response
149
150
151Put Data Validation
152 [Documentation] REST "Put" request url and expect success.
153 #--------------------------------------------------------------------
154 # URL Path Parm Data
155 #--------------------------------------------------------------------
156 /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off
157
158 [Tags] Put_Data_Validation
159 [Template] Execute Put And Expect Success
160
161
162Post Response Code
163 [Documentation] REST Post request url and expect the
164 ... REST response code pre define.
165 #--------------------------------------------------------------------
166 # Expect status URL Path
167 #--------------------------------------------------------------------
168 ${HTTP_METHOD_NOT_ALLOWED} /
169 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
170 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
171 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
172
173 [Tags] Post_Response_Codes
174 [Template] Execute Post And Check Response
175
176
177Delete Response Code
178 [Documentation] REST "Delete" request url and expect the
179 ... REST response code pre define.
180 #--------------------------------------------------------------------
181 # Expect status URL Path
182 #--------------------------------------------------------------------
183 ${HTTP_METHOD_NOT_ALLOWED} /
184 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
185 ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/
186 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
187 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/list
188 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/enumerate
189
190 [Tags] Delete_Response_Codes
191 [Template] Execute Delete And Check Response
192
Gunnar Mills56b32892016-11-14 13:56:17 -0600193
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600194*** Keywords ***
George Keishing85536662017-03-03 10:49:58 -0600195
196Execute Get And Check Response
197 [Documentation] Request "Get" url path and expect REST response code.
198 [Arguments] ${expected_response_code} ${url_path}
199 # Description of arguments:
200 # expected_response_code Expected REST status codes.
201 # url_path URL path.
202 ${resp}= Openbmc Get Request ${url_path}
203 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
204
205Execute Get And Check Data
206 [Documentation] Request "Get" url path and expect non empty data.
207 [Arguments] ${url_path}
208 # Description of arguments:
209 # url_path URL path.
210 ${resp}= Openbmc Get Request ${url_path}
211 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
212 ${jsondata}= To JSON ${resp.content}
213 Should Not Be Empty ${jsondata["data"]}
214
215Execute Get And Verify Data
216 [Documentation] Request "Get" url path and verify data.
217 [Arguments] ${url_path} ${expected_response_code}
218 # Description of arguments:
219 # expected_response_code Expected REST status codes.
220 # url_path URL path.
221 ${resp}= Openbmc Get Request ${url_path}
222 ${jsondata}= To JSON ${resp.content}
223 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
224 ... Should Contain ${jsondata["data"]} ${expected_response_code}
225 ... ELSE
226 ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code}
227
228Execute Put And Check Response
229 [Documentation] Request "Put" url path and expect REST response code.
230 [Arguments] ${expected_response_code} ${url_path}
231 # Description of arguments:
232 # expected_response_code Expected REST status codes.
233 # url_path URL path.
234 ${resp}= Openbmc Put Request ${url_path}
235 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
236
237Execute Put And Expect Success
238 [Documentation] Request "Put" on url path.
239 [Arguments] ${url_path} ${parm}
240 # Description of arguments:
241 # url_path URL path.
242 # parm Value/string to be set.
243 # expected_response_code Expected REST status codes.
244 ${parmDict}= Create Dictionary data=${parm}
245 ${resp}= Openbmc Put Request ${url_path} data=${parmDict}
246 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
247
248Execute Post And Check Response
249 [Documentation] Request Post url path and expect REST response code.
250 [Arguments] ${expected_response_code} ${url_path}
251 # Description of arguments:
252 # expected_response_code Expected REST status codes.
253 # url_path URL path.
254 ${resp}= Openbmc Post Request ${url_path}
255 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
256
257Execute Post And Check Data
258 [Arguments] ${url_path} ${parm}
259 [Documentation] Request Post on url path and expected non empty data.
260 # Description of arguments:
261 # url_path URL path.
George Keishing4c02e622017-04-17 07:57:10 -0500262 ${data}= Create Dictionary data=@{parm}
George Keishing85536662017-03-03 10:49:58 -0600263 ${resp}= Openbmc Post Request ${url_path} data=${data}
264 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
265 ${jsondata}= To JSON ${resp.content}
266 Should Not Be Empty ${jsondata["data"]}
267
268Execute Delete And Check Response
269 [Documentation] Request "Delete" url path and expected REST response code.
270 [Arguments] ${expected_response_code} ${url_path}
271 # Description of arguments:
272 # expected_response_code Expected REST status codes.
273 # url_path URL path.
George Keishing4c02e622017-04-17 07:57:10 -0500274 ${data}= Create Dictionary data=@{EMPTY}
275 ${resp}= Openbmc Delete Request ${url_path} data=${data}
George Keishing85536662017-03-03 10:49:58 -0600276 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}