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