blob: a3121e22a90aa3ac7f8ca30da5f5cffd68044730 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite will verifiy all OpenBMC rest interfaces
3... Details of valid interfaces can be found here...
4... https://github.com/openbmc/docs/blob/master/rest-api.md
5
6Resource ../lib/rest_client.robot
7
8
9*** Variables ***
10
11
12*** Test Cases ***
13Good connection for testing
14 ${content}= Read Properties /
15 ${c}= get from List ${content} 0
16 Should Be Equal ${c} /org
17
18Get an object with no properties
19 ${content}= Read Properties /org/openbmc/inventory
20 Should Be Empty ${content}
21
22Get a Property
23 ${resp}= Read Attribute /org/openbmc/inventory/system/chassis/motherboard/cpu0 is_fru
24 Should Be Equal ${resp} ${1}
25
26Get a null Property
27 ${resp} = OpenBMC Get Request /org/openbmc/inventory/attr/is_fru
28 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
29 ${jsondata}= To Json ${resp.content}
30 Should Be Equal ${jsondata['data']['description']} The specified property cannot be found: ''is_fru''
31
32get directory listing /
33 ${resp} = openbmc get request /
34 should be equal as strings ${resp.status_code} ${HTTP_OK}
35 ${json} = to json ${resp.content}
36 list should contain value ${json['data']} /org
37 should be equal as strings ${json['status']} ok
38
39get directory listing /org/
40 ${resp} = openbmc get request /org/
41 should be equal as strings ${resp.status_code} ${HTTP_OK}
42 ${json} = to json ${resp.content}
43 list should contain value ${json['data']} /org/openbmc
44 should be equal as strings ${json['status']} ok
45
46get invalid directory listing /i/dont/exist/
47 ${resp} = openbmc get request /i/dont/exist/
48 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
49 ${json} = to json ${resp.content}
50 should be equal as strings ${json['status']} error
51
52put directory listing /
53 ${resp} = openbmc put request /
54 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
55 ${json} = to json ${resp.content}
56 should be equal as strings ${json['status']} error
57
58put directory listing /org/
59 ${resp} = openbmc put request /org/
60 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
61 ${json} = to json ${resp.content}
62 should be equal as strings ${json['status']} error
63
64put invalid directory listing /i/dont/exist/
65 ${resp} = openbmc put request /i/dont/exist/
66 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
67 ${json} = to json ${resp.content}
68 should be equal as strings ${json['status']} error
69
70post directory listing /
71 ${resp} = openbmc post request /
72 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
73 ${json} = to json ${resp.content}
74 should be equal as strings ${json['status']} error
75
76post directory listing /org/
77 ${resp} = openbmc post request /org/
78 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
79 ${json} = to json ${resp.content}
80 should be equal as strings ${json['status']} error
81
82post invalid directory listing /i/dont/exist/
83 ${resp} = openbmc post request /i/dont/exist/
84 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
85 ${json} = to json ${resp.content}
86 should be equal as strings ${json['status']} error
87
88delete directory listing /
89 ${resp} = openbmc delete request /
90 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
91 ${json} = to json ${resp.content}
92 should be equal as strings ${json['status']} error
93
94delete directory listing /org/
95 ${resp} = openbmc delete request /
96 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
97 ${json} = to json ${resp.content}
98 should be equal as strings ${json['status']} error
99
100delete invalid directory listing /org/nothere/
101 ${resp} = openbmc delete request /org/nothere/
102 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
103 ${json} = to json ${resp.content}
104 should be equal as strings ${json['status']} error
105
106get list names /
107 ${resp} = openbmc get request /list
108 should be equal as strings ${resp.status_code} ${HTTP_OK}
109 ${json} = to json ${resp.content}
110 list should contain value ${json['data']} /org/openbmc/inventory
111 should be equal as strings ${json['status']} ok
112
113get list names /org/
114 ${resp} = openbmc get request /org/list
115 should be equal as strings ${resp.status_code} ${HTTP_OK}
116 ${json} = to json ${resp.content}
117 list should contain value ${json['data']} /org/openbmc/inventory
118 should be equal as strings ${json['status']} ok
119
120get invalid list names /i/dont/exist/
121 ${resp} = openbmc get request /i/dont/exist/list
122 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
123 ${json} = to json ${resp.content}
124 should be equal as strings ${json['status']} error
125
126put list names /
127 ${resp} = openbmc put request /list
128 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
129 ${json} = to json ${resp.content}
130 should be equal as strings ${json['status']} error
131
132put list names /org/
133 ${resp} = openbmc put request /org/list
134 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
135 ${json} = to json ${resp.content}
136 should be equal as strings ${json['status']} error
137
138put invalid list names /i/dont/exist/
139 ${resp} = openbmc put request /i/dont/exist/list
140 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
141 ${json} = to json ${resp.content}
142 should be equal as strings ${json['status']} error
143
144post list names /
145 ${resp} = openbmc post request /list
146 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
147 ${json} = to json ${resp.content}
148 should be equal as strings ${json['status']} error
149
150post list names /org/
151 ${resp} = openbmc post request /org/list
152 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
153 ${json} = to json ${resp.content}
154 should be equal as strings ${json['status']} error
155
156post invalid list names /i/dont/exist/
157 ${resp} = openbmc post request /i/dont/exist/list
158 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
159 ${json} = to json ${resp.content}
160 should be equal as strings ${json['status']} error
161
162delete list names /
163 ${resp} = openbmc delete request /list
164 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
165 ${json} = to json ${resp.content}
166 should be equal as strings ${json['status']} error
167
168delete list names /org/
169 ${resp} = openbmc delete request /list
170 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
171 ${json} = to json ${resp.content}
172 should be equal as strings ${json['status']} error
173
174delete invalid list names /org/nothere/
175 ${resp} = openbmc delete request /org/nothere/list
176 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
177 ${json} = to json ${resp.content}
178 should be equal as strings ${json['status']} error
179
180get names /
181 ${resp} = openbmc get request /enumerate
182 should be equal as strings ${resp.status_code} ${HTTP_OK}
183 ${json} = to json ${resp.content}
184 list should contain value ${json['data']} /org/openbmc/inventory
185 should be equal as strings ${json['status']} ok
186
187get names /org/
188 ${resp} = openbmc get request /org/enumerate
189 should be equal as strings ${resp.status_code} ${HTTP_OK}
190 ${json} = to json ${resp.content}
191 list should contain value ${json['data']} /org/openbmc/inventory
192 should be equal as strings ${json['status']} ok
193
194get invalid names /i/dont/exist/
195 ${resp} = openbmc get request /i/dont/exist/enumerate
196 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
197 ${json} = to json ${resp.content}
198 should be equal as strings ${json['status']} error
199
200put names /
201 ${resp} = openbmc put request /enumerate
202 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
203 ${json} = to json ${resp.content}
204 should be equal as strings ${json['status']} error
205
206put names /org/
207 ${resp} = openbmc put request /org/enumerate
208 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
209 ${json} = to json ${resp.content}
210 should be equal as strings ${json['status']} error
211
212put invalid names /i/dont/exist/
213 ${resp} = openbmc put request /i/dont/exist/enumerate
214 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
215 ${json} = to json ${resp.content}
216 should be equal as strings ${json['status']} error
217
218post names /
219 ${resp} = openbmc post request /enumerate
220 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
221 ${json} = to json ${resp.content}
222 should be equal as strings ${json['status']} error
223
224post names /org/
225 ${resp} = openbmc post request /org/enumerate
226 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
227 ${json} = to json ${resp.content}
228 should be equal as strings ${json['status']} error
229
230post invalid names /i/dont/exist/
231 ${resp} = openbmc post request /i/dont/exist/enumerate
232 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
233 ${json} = to json ${resp.content}
234 should be equal as strings ${json['status']} error
235
236delete names /
237 ${resp} = openbmc delete request /enumerate
238 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
239 ${json} = to json ${resp.content}
240 should be equal as strings ${json['status']} error
241
242delete names /org/
243 ${resp} = openbmc delete request /enumerate
244 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
245 ${json} = to json ${resp.content}
246 should be equal as strings ${json['status']} error
247
248delete invalid names /org/nothere/
249 ${resp} = openbmc delete request /org/nothere/enumerate
250 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
251 ${json} = to json ${resp.content}
252 should be equal as strings ${json['status']} error
253
254get method org/openbmc/records/events/action/acceptTestMessage
255 ${resp} = openbmc get request org/openbmc/records/events/action/acceptTestMessage
256 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
257 ${json} = to json ${resp.content}
258 should be equal as strings ${json['status']} error
259
260get invalid method /i/dont/exist/
261 ${resp} = openbmc get request /i/dont/exist/action/foo
262 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
263 ${json} = to json ${resp.content}
264 should be equal as strings ${json['status']} error
265
266put method org/openbmc/records/events/action/acceptTestMessage
267 ${resp} = openbmc put request org/openbmc/records/events/action/acceptTestMessage
268 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
269 ${json} = to json ${resp.content}
270 should be equal as strings ${json['status']} error
271
272put invalid method /i/dont/exist/
273 ${resp} = openbmc put request /i/dont/exist/action/foo
274 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
275 ${json} = to json ${resp.content}
276 should be equal as strings ${json['status']} error
277
278post method power/getPowerState no args
279 ${fan_uri}= Get Power Control Interface
280 ${data} = create dictionary data=@{EMPTY}
281 ${resp} = openbmc post request ${fan_uri}/action/getPowerState data=${data}
282 should be equal as strings ${resp.status_code} ${HTTP_OK}
283 ${json} = to json ${resp.content}
284 should be equal as strings ${json['status']} ok
285
286post method org/openbmc/records/events/action/acceptTestMessage invalid args
287 ${data} = create dictionary foo=bar
288 ${resp} = openbmc post request org/openbmc/records/events/action/acceptTestMessage data=${data}
289 should be equal as strings ${resp.status_code} ${HTTP_BAD_REQUEST}
290 ${json} = to json ${resp.content}
291 should be equal as strings ${json['status']} error
292
293post method org/openbmc/sensors/host/BootCount with args
294 ${uri} = Set Variable /org/openbmc/sensors/host/BootCount
295 ${COUNT}= Set Variable ${3}
296 @{count_list} = Create List ${COUNT}
297 ${data} = create dictionary data=@{count_list}
298 ${resp} = openbmc post request ${uri}/action/setValue data=${data}
299 should be equal as strings ${resp.status_code} ${HTTP_OK}
300 ${json} = to json ${resp.content}
301 should be equal as strings ${json['status']} ok
302 ${content}= Read Attribute ${uri} value
303 Should Be Equal ${content} ${COUNT}
304
305delete method org/openbmc/records/events/action/acceptTestMessage
306 ${resp} = openbmc delete request org/openbmc/records/events/action/acceptTestMessage
307 should be equal as strings ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
308 ${json} = to json ${resp.content}
309 should be equal as strings ${json['status']} error
310
311delete invalid method /org/nothere/
312 ${resp} = openbmc delete request /org/nothere/action/foomethod
313 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
314 ${json} = to json ${resp.content}
315 should be equal as strings ${json['status']} error
316
317post method org/openbmc/records/events/action/acceptTestMessage no args
318 ${data} = create dictionary data=@{EMPTY}
319 ${resp} = openbmc post request org/openbmc/records/events/action/acceptTestMessage data=${data}
320 should be equal as strings ${resp.status_code} ${HTTP_OK}
321 ${json} = to json ${resp.content}
322 should be equal as strings ${json['status']} ok
323
324***keywords***
325Get Power Control Interface
326 ${resp}= OpenBMC Get Request /org/openbmc/control/
327 should be equal as strings ${resp.status_code} ${HTTP_OK} msg=Unable to get any controls - /org/openbmc/control/
328 ${jsondata}= To Json ${resp.content}
329 log ${jsondata}
330 : FOR ${ELEMENT} IN @{jsondata["data"]}
331 \ log ${ELEMENT}
332 \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/power*
333 \ Return From Keyword If '${found}' != '' ${found}