Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 2 | Documentation Verify REST services Get/Put/Post/Delete. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 3 | |
George Keishing | 97651c7 | 2016-10-04 00:44:15 -0500 | [diff] [blame] | 4 | Resource ../lib/rest_client.robot |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 5 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | 7230bbc | 2016-12-14 07:02:48 -0600 | [diff] [blame] | 6 | Resource ../lib/resource.txt |
Sivas SRR | a13eb20 | 2017-11-03 10:01:56 -0500 | [diff] [blame] | 7 | Resource ../lib/utils.robot |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 8 | Library Collections |
Sivas SRR | a13eb20 | 2017-11-03 10:01:56 -0500 | [diff] [blame] | 9 | Suite Setup Run Keyword And Ignore Error Check BMC Performance |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 10 | Test Teardown FFDC On Test Case Fail |
Sivas SRR | a13eb20 | 2017-11-03 10:01:56 -0500 | [diff] [blame] | 11 | Suite Teardown Run Keyword And Ignore Error Check BMC Performance |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 13 | *** Variables *** |
| 14 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | *** Test Cases *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 16 | |
George Keishing | 89f7c1f | 2017-05-03 16:08:37 -0500 | [diff] [blame] | 17 | REST Login Session To BMC |
| 18 | [Documentation] Test REST session log-in. |
| 19 | [Tags] REST_Login_Session_To_BMC |
| 20 | |
| 21 | Initialize OpenBMC |
| 22 | # Raw GET REST operation to verify session is established. |
| 23 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 24 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 25 | |
| 26 | |
| 27 | REST Logout Session To BMC |
| 28 | [Documentation] Test REST session log-out. |
| 29 | [Tags] REST_Logout_Session_To_BMC |
| 30 | |
| 31 | Initialize OpenBMC |
| 32 | Log Out OpenBMC |
| 33 | # Raw GET REST operation to verify session is logout. |
| 34 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 35 | Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED} |
| 36 | |
| 37 | |
George Keishing | 6715f31 | 2017-05-10 03:22:40 -0500 | [diff] [blame] | 38 | REST Delete All Sessions And Expect Error |
| 39 | [Documentation] Test REST empty cache using delete operation. |
| 40 | [Tags] REST_Delete_All_Sessions_And_Expect_Error |
| 41 | |
| 42 | # Throws exception: |
| 43 | # Non-existing index or alias 'openbmc'. |
| 44 | |
| 45 | Initialize OpenBMC |
| 46 | Delete All Sessions |
| 47 | # Raw GET REST operation and expect exception error. |
| 48 | Run Keyword And Expect Error |
| 49 | ... Non-existing index or alias 'openbmc'. |
| 50 | ... Get Request openbmc /xyz/openbmc_project/ |
| 51 | |
| 52 | |
George Keishing | 3b1f277 | 2017-07-31 09:44:45 -0500 | [diff] [blame] | 53 | Multiple Requests On BMC Using Single REST Session |
| 54 | [Documentation] Trigger multiple REST operations using an active |
| 55 | ... connection session. |
| 56 | [Tags] Multiple_Requests_On_BMC_Using_Single_REST_Session |
| 57 | |
| 58 | Initialize OpenBMC |
| 59 | |
| 60 | # Session object "openbmc". |
| 61 | ${resp}= Get Request openbmc /xyz/openbmc_project/state/ |
| 62 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 63 | |
| 64 | ${resp}= Get Request openbmc /xyz/openbmc_project/software/enumerate |
| 65 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 66 | |
| 67 | |
George Keishing | 6715f31 | 2017-05-10 03:22:40 -0500 | [diff] [blame] | 68 | Verify REST JSON Data On Success |
| 69 | [Documentation] Verify JSON data success response messages. |
| 70 | [Tags] Verify_REST_JSON_Data_On_Success |
| 71 | # Example: |
| 72 | # Response code:200, Content:{ |
| 73 | # "data": [ |
| 74 | # "/xyz/openbmc_project/sensors", |
| 75 | # "/xyz/openbmc_project/inventory", |
| 76 | # "/xyz/openbmc_project/software", |
| 77 | # "/xyz/openbmc_project/object_mapper", |
| 78 | # "/xyz/openbmc_project/logging" |
| 79 | # ], |
| 80 | # "message": "200 OK", |
| 81 | # "status": "ok" |
| 82 | # } |
| 83 | |
| 84 | ${resp}= OpenBMC Get Request /xyz/openbmc_project/ |
| 85 | ${jsondata}= To JSON ${resp.content} |
| 86 | Should Not Be Empty ${jsondata["data"]} |
| 87 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 88 | Should Be Equal As Strings ${jsondata["status"]} ok |
| 89 | |
| 90 | |
| 91 | Verify REST JSON Data On Failure |
| 92 | [Documentation] Verify JSON data failure response messages. |
| 93 | [Tags] Verify_REST_JSON_Data_On_Failure |
| 94 | # Example: |
| 95 | # Response code:404, Content:{ |
| 96 | # "data": { |
| 97 | # "description": "org.freedesktop.DBus.Error.FileNotFound: path or object not found: /xyz/idont/exist" |
| 98 | # }, |
| 99 | # "message": "404 Not Found", |
| 100 | # "status": "error" |
| 101 | # } |
| 102 | |
| 103 | ${resp}= OpenBMC Get Request /xyz/idont/exist/ |
| 104 | ${jsondata}= To JSON ${resp.content} |
| 105 | Should Be Equal As Strings |
| 106 | ... ${jsondata["data"]["description"]} org.freedesktop.DBus.Error.FileNotFound: path or object not found: /xyz/idont/exist |
| 107 | Should Be Equal As Strings ${jsondata["message"]} 404 Not Found |
| 108 | Should Be Equal As Strings ${jsondata["status"]} error |
| 109 | |
| 110 | |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 111 | Verify REST Get Message JSON Compliant |
| 112 | [Documentation] Verify REST "GET" message is JSON format compliant. |
| 113 | [Tags] Verify_REST_Get_Message_JSON_Compliant |
| 114 | # For testing if the REST message is JSON format compliant using a |
| 115 | # generic BMC state path /xyz/openbmc_project/state object and path |
| 116 | # walking through to ensure the parent object, trailing slash and |
| 117 | # attribute message response are intact. |
| 118 | |
| 119 | # Object attribute data. |
| 120 | # Example: |
| 121 | # Response code:200, Content:{ |
| 122 | # "data": { |
| 123 | # "CurrentBMCState": "xyz.openbmc_project.State.BMC.BMCState.Ready", |
| 124 | # "RequestedBMCTransition": "xyz.openbmc_project.State.BMC.Transition.None" |
| 125 | # }, |
| 126 | # "message": "200 OK", |
| 127 | # "status": "ok" |
| 128 | # } |
| 129 | |
| 130 | Verify JSON Response Content |
| 131 | ... /xyz/openbmc_project/state/bmc0 DATA_NOT_EMPTY |
| 132 | |
| 133 | # Object trailing slash attribute data. |
| 134 | # Example: |
| 135 | # Response code:200, Content:{ |
| 136 | # "data": [], |
| 137 | # "message": "200 OK", |
| 138 | # "status": "ok" |
| 139 | # } |
| 140 | |
| 141 | Verify JSON Response Content /xyz/openbmc_project/state/bmc0/ |
| 142 | |
| 143 | # Attribute data. |
| 144 | # Example: |
| 145 | # Response code:200, Content:{ |
| 146 | # "data": "xyz.openbmc_project.State.BMC.BMCState.Ready", |
| 147 | # "message": "200 OK", |
| 148 | # "status": "ok" |
| 149 | # } |
| 150 | |
| 151 | Verify JSON Response Content |
| 152 | ... /xyz/openbmc_project/state/bmc0/attr/CurrentBMCState DATA_NOT_EMPTY |
| 153 | |
| 154 | |
| 155 | Verify REST Post Message JSON Compliant |
| 156 | [Documentation] Verify REST "POST" message is JSON format compliant. |
| 157 | [Tags] Verify_REST_Post_Message_JSON_Compliant |
| 158 | # Example: |
| 159 | # Response code:200, Content:{ |
| 160 | # "data": null, |
| 161 | # "message": "200 OK", |
| 162 | # "status": "ok" |
| 163 | # } |
| 164 | |
George Keishing | d580a9a | 2018-04-20 01:17:12 -0500 | [diff] [blame] | 165 | # Clear existing gard records, if any. |
| 166 | ${data}= Create Dictionary data=@{EMPTY} |
| 167 | ${resp}= Openbmc Post Request ${OPENPOWER_CONTROL}gard/action/Reset |
| 168 | ... data=${data} |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 169 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 170 | ${jsondata}= To JSON ${resp.content} |
| 171 | Should Be Equal ${jsondata["data"]} ${None} |
| 172 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 173 | Should Be Equal As Strings ${jsondata["status"]} ok |
| 174 | |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 175 | |
George Keishing | f0c1af9 | 2018-04-12 08:10:43 -0500 | [diff] [blame] | 176 | Verify REST Bad Request Post Message JSON Compliant |
| 177 | [Documentation] Verify REST "POST" message is JSON format compliant. |
| 178 | [Tags] Verify_REST_Bad_Request_Post_Message_JSON_Compliant |
| 179 | # Example: |
| 180 | # { |
| 181 | # "data": { |
| 182 | # "description": "Version already exists or failed to be extracted" |
| 183 | # }, |
| 184 | # "message": "400 Bad Request", |
| 185 | # "status": "error" |
| 186 | # } |
| 187 | |
| 188 | # Generate 1KB file size |
| 189 | Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=1KB |
| 190 | OperatingSystem.File Should Exist dummyfile |
| 191 | |
| 192 | # Get the content of the file and upload to BMC |
| 193 | ${image_data}= OperatingSystem.Get Binary File dummyfile |
| 194 | |
| 195 | # Get REST session to BMC |
| 196 | Initialize OpenBMC |
| 197 | |
| 198 | # Create the REST payload headers and data |
| 199 | ${data}= Create Dictionary data ${image_data} |
| 200 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 201 | ... Accept=application/octet-stream |
| 202 | Set To Dictionary ${data} headers ${headers} |
| 203 | |
| 204 | ${resp}= Post Request openbmc /upload/image &{data} |
| 205 | Should Be Equal As Strings ${resp.status_code} ${HTTP_BAD_REQUEST} |
| 206 | ${jsondata}= To JSON ${resp.content} |
| 207 | Should Be Equal ${jsondata["data"]["description"]} |
| 208 | ... Version already exists or failed to be extracted |
| 209 | Should Be Equal As Strings ${jsondata["message"]} 400 Bad Request |
| 210 | Should Be Equal As Strings ${jsondata["status"]} error |
| 211 | Delete All Error Logs |
| 212 | |
| 213 | |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 214 | Verify REST Put Message JSON Compliant |
| 215 | [Documentation] Verify REST "PUT" message is JSON format compliant. |
| 216 | [Tags] REST_Put_Message_JSON_Format_Compliance_Test |
| 217 | # Example: |
| 218 | # Response code:200, Content:{ |
| 219 | # "data": null, |
| 220 | # "message": "200 OK", |
| 221 | # "status": "ok" |
| 222 | # } |
| 223 | |
| 224 | ${dict_data}= Create Dictionary data=${HOST_POWEROFF_TRANS} |
| 225 | ${resp}= Openbmc Put Request |
| 226 | ... ${HOST_STATE_URI}/attr/RequestedHostTransition data=${dict_data} |
| 227 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 228 | ${jsondata}= To JSON ${resp.content} |
| 229 | Should Be Equal ${jsondata["data"]} ${None} |
| 230 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 231 | Should Be Equal As Strings ${jsondata["status"]} ok |
| 232 | # Intention is not to test poweroff but to check the REST operation |
| 233 | # sink time allowing to kick poweroff. |
| 234 | Sleep 10s |
| 235 | |
| 236 | |
George Keishing | e6594f2 | 2017-07-06 12:10:52 -0500 | [diff] [blame] | 237 | Check Response Codes HTTP_UNSUPPORTED_MEDIA_TYPE |
| 238 | [Documentation] REST "Post" response status test for |
| 239 | ... HTTP_UNSUPPORTED_MEDIA_TYPE. |
| 240 | [Tags] Check_Response_Codes_415 |
| 241 | |
| 242 | # Example: |
| 243 | # Response code:415, Content:{ |
| 244 | # "data": { |
| 245 | # "description": "Expecting content type 'application/octet-stream', got 'application/json'" |
| 246 | # }, |
| 247 | # "message": "415 Unsupported Media Type", |
| 248 | # "status": "error" |
| 249 | # } |
| 250 | |
| 251 | Initialize OpenBMC |
| 252 | |
| 253 | # Create the REST payload headers and EMPTY data |
| 254 | ${data}= Create Dictionary data ${EMPTY} |
| 255 | ${headers}= Create Dictionary Content-Type=application/json |
| 256 | Set To Dictionary ${data} headers ${headers} |
| 257 | |
| 258 | ${resp}= Post Request openbmc /upload/image &{data} |
| 259 | Should Be Equal As Strings |
| 260 | ... ${resp.status_code} ${HTTP_UNSUPPORTED_MEDIA_TYPE} |
| 261 | |
| 262 | ${jsondata}= To JSON ${resp.content} |
| 263 | Should Be Equal As Strings ${jsondata["data"]["description"]} |
| 264 | ... Expecting content type 'application/octet-stream', got 'application/json' |
| 265 | Should Be Equal As Strings |
| 266 | ... ${jsondata["message"]} 415 Unsupported Media Type |
| 267 | Should Be Equal As Strings ${jsondata["status"]} error |
| 268 | |
| 269 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 270 | Get Response Codes |
| 271 | [Documentation] REST "Get" response status test. |
| 272 | #-------------------------------------------------------------------- |
| 273 | # Expect status URL Path |
| 274 | #-------------------------------------------------------------------- |
| 275 | ${HTTP_OK} / |
| 276 | ${HTTP_OK} /xyz/ |
| 277 | ${HTTP_OK} /xyz/openbmc_project/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 278 | ${HTTP_OK} /xyz/openbmc_project/state/enumerate |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 279 | ${HTTP_NOT_FOUND} /i/dont/exist/ |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 280 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 281 | [Tags] Get_Response_Codes |
| 282 | [Template] Execute Get And Check Response |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 283 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 284 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 285 | Get Data |
| 286 | [Documentation] REST "Get" request url and expect the |
| 287 | ... response OK and data non empty. |
| 288 | #-------------------------------------------------------------------- |
| 289 | # URL Path |
| 290 | #-------------------------------------------------------------------- |
| 291 | /xyz/openbmc_project/ |
| 292 | /xyz/openbmc_project/list |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 293 | /xyz/openbmc_project/state/enumerate |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 294 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 295 | [Tags] Get_Data |
| 296 | [Template] Execute Get And Check Data |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 297 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 298 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 299 | Get Data Validation |
| 300 | [Documentation] REST "Get" request url and expect the |
| 301 | ... pre-defined string in response data. |
| 302 | #-------------------------------------------------------------------- |
| 303 | # URL Path Expect Data |
| 304 | #-------------------------------------------------------------------- |
| 305 | /xyz/openbmc_project/ /xyz/openbmc_project/logging |
| 306 | /i/dont/exist/ path or object not found: /i/dont/exist |
| 307 | |
| 308 | [Tags] Get_Data_Validation |
| 309 | [Template] Execute Get And Verify Data |
| 310 | |
| 311 | |
| 312 | Put Response Codes |
| 313 | [Documentation] REST "Put" request url and expect the REST pre-defined |
| 314 | ... codes. |
| 315 | #-------------------------------------------------------------------- |
| 316 | # Expect status URL Path |
| 317 | #-------------------------------------------------------------------- |
| 318 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 319 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 320 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 321 | |
| 322 | [Tags] Put_Response_Codes |
| 323 | [Template] Execute Put And Check Response |
| 324 | |
| 325 | |
| 326 | Put Data Validation |
| 327 | [Documentation] REST "Put" request url and expect success. |
| 328 | #-------------------------------------------------------------------- |
| 329 | # URL Path Parm Data |
| 330 | #-------------------------------------------------------------------- |
| 331 | /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off |
| 332 | |
| 333 | [Tags] Put_Data_Validation |
| 334 | [Template] Execute Put And Expect Success |
| 335 | |
| 336 | |
| 337 | Post Response Code |
| 338 | [Documentation] REST Post request url and expect the |
| 339 | ... REST response code pre define. |
| 340 | #-------------------------------------------------------------------- |
| 341 | # Expect status URL Path |
| 342 | #-------------------------------------------------------------------- |
| 343 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 344 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 345 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 346 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/login |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 347 | |
| 348 | [Tags] Post_Response_Codes |
| 349 | [Template] Execute Post And Check Response |
| 350 | |
| 351 | |
| 352 | Delete Response Code |
| 353 | [Documentation] REST "Delete" request url and expect the |
| 354 | ... REST response code pre define. |
| 355 | #-------------------------------------------------------------------- |
| 356 | # Expect status URL Path |
| 357 | #-------------------------------------------------------------------- |
| 358 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 359 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 360 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 361 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/state/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 362 | |
| 363 | [Tags] Delete_Response_Codes |
| 364 | [Template] Execute Delete And Check Response |
| 365 | |
Gunnar Mills | 56b3289 | 2016-11-14 13:56:17 -0600 | [diff] [blame] | 366 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 367 | Verify All REST Objects Are Accessible |
| 368 | [Documentation] Verify all the REST objects are accessible using "GET". |
| 369 | [Tags] Verify_All_REST_Objects_Are_Accessible |
| 370 | |
| 371 | ${uri_list}= Get Sub URI List ${OPENBMC_BASE_URI} |
| 372 | ${error_uri_list}= Create List |
| 373 | :FOR ${uri} IN @{uri_list} |
| 374 | \ ${resp}= Openbmc Get Request ${uri} quiet=${1} |
| 375 | \ Run keyword if '${resp.status_code}' != '${HTTP_OK}' |
| 376 | \ ... Append To List ${error_uri_list} ${uri} : ${resp.status_code} |
| 377 | Should Be Empty ${error_uri_list} |
| 378 | |
Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 379 | *** Keywords *** |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 380 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 381 | Get Sub URI List |
| 382 | [Documentation] Return list of sub URIs inside the URI sent by caller. |
| 383 | [Arguments] ${uri} |
| 384 | # Description of argument(s): |
| 385 | # uri The URI for which all the sub URIs are returned. |
| 386 | # Example: |
| 387 | # "/xyz/openbmc_project/" |
| 388 | ${resp}= Openbmc Get Request ${uri}list quiet=${1} |
| 389 | ${sub_uris}= Collections.Get From Dictionary ${resp.json()} data |
| 390 | [Return] ${sub_uris} |
| 391 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 392 | Execute Get And Check Response |
| 393 | [Documentation] Request "Get" url path and expect REST response code. |
| 394 | [Arguments] ${expected_response_code} ${url_path} |
| 395 | # Description of arguments: |
| 396 | # expected_response_code Expected REST status codes. |
| 397 | # url_path URL path. |
| 398 | ${resp}= Openbmc Get Request ${url_path} |
| 399 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 400 | |
| 401 | Execute Get And Check Data |
| 402 | [Documentation] Request "Get" url path and expect non empty data. |
| 403 | [Arguments] ${url_path} |
| 404 | # Description of arguments: |
| 405 | # url_path URL path. |
| 406 | ${resp}= Openbmc Get Request ${url_path} |
| 407 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 408 | ${jsondata}= To JSON ${resp.content} |
| 409 | Should Not Be Empty ${jsondata["data"]} |
| 410 | |
| 411 | Execute Get And Verify Data |
| 412 | [Documentation] Request "Get" url path and verify data. |
| 413 | [Arguments] ${url_path} ${expected_response_code} |
| 414 | # Description of arguments: |
| 415 | # expected_response_code Expected REST status codes. |
| 416 | # url_path URL path. |
| 417 | ${resp}= Openbmc Get Request ${url_path} |
| 418 | ${jsondata}= To JSON ${resp.content} |
| 419 | Run Keyword If '${resp.status_code}' == '${HTTP_OK}' |
| 420 | ... Should Contain ${jsondata["data"]} ${expected_response_code} |
| 421 | ... ELSE |
| 422 | ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code} |
| 423 | |
| 424 | Execute Put And Check Response |
| 425 | [Documentation] Request "Put" url path and expect REST response code. |
| 426 | [Arguments] ${expected_response_code} ${url_path} |
| 427 | # Description of arguments: |
| 428 | # expected_response_code Expected REST status codes. |
| 429 | # url_path URL path. |
| 430 | ${resp}= Openbmc Put Request ${url_path} |
| 431 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 432 | |
| 433 | Execute Put And Expect Success |
| 434 | [Documentation] Request "Put" on url path. |
| 435 | [Arguments] ${url_path} ${parm} |
| 436 | # Description of arguments: |
| 437 | # url_path URL path. |
| 438 | # parm Value/string to be set. |
| 439 | # expected_response_code Expected REST status codes. |
| 440 | ${parmDict}= Create Dictionary data=${parm} |
| 441 | ${resp}= Openbmc Put Request ${url_path} data=${parmDict} |
| 442 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 443 | |
| 444 | Execute Post And Check Response |
| 445 | [Documentation] Request Post url path and expect REST response code. |
| 446 | [Arguments] ${expected_response_code} ${url_path} |
| 447 | # Description of arguments: |
| 448 | # expected_response_code Expected REST status codes. |
| 449 | # url_path URL path. |
| 450 | ${resp}= Openbmc Post Request ${url_path} |
| 451 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 452 | |
| 453 | Execute Post And Check Data |
| 454 | [Arguments] ${url_path} ${parm} |
| 455 | [Documentation] Request Post on url path and expected non empty data. |
| 456 | # Description of arguments: |
| 457 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 458 | ${data}= Create Dictionary data=@{parm} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 459 | ${resp}= Openbmc Post Request ${url_path} data=${data} |
| 460 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 461 | ${jsondata}= To JSON ${resp.content} |
| 462 | Should Not Be Empty ${jsondata["data"]} |
| 463 | |
| 464 | Execute Delete And Check Response |
| 465 | [Documentation] Request "Delete" url path and expected REST response code. |
| 466 | [Arguments] ${expected_response_code} ${url_path} |
| 467 | # Description of arguments: |
| 468 | # expected_response_code Expected REST status codes. |
| 469 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 470 | ${data}= Create Dictionary data=@{EMPTY} |
| 471 | ${resp}= Openbmc Delete Request ${url_path} data=${data} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 472 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 473 | |
| 474 | Verify JSON Response Content |
| 475 | [Documentation] Verify JSON response data is intact. |
| 476 | [Arguments] ${url_path} ${data_empty}=${EMPTY} |
| 477 | |
| 478 | # Description of argument(s): |
| 479 | # url_path URL path. |
| 480 | # data_empty JSON data element. |
| 481 | |
| 482 | ${resp}= OpenBMC Get Request ${url_path} |
| 483 | ${jsondata}= To JSON ${resp.content} |
| 484 | Run Keyword If '${data_empty}' == '${EMPTY}' |
| 485 | ... Should Be Empty ${jsondata["data"]} |
| 486 | ... ELSE |
| 487 | ... Should Not Be Empty ${jsondata["data"]} |
| 488 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 489 | Should Be Equal As Strings ${jsondata["status"]} ok |