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 | 5cd6d04 | 2018-05-03 14:52:32 -0500 | [diff] [blame] | 277 | ${HTTP_OK} /org/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 278 | ${HTTP_OK} /xyz/ |
| 279 | ${HTTP_OK} /xyz/openbmc_project/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 280 | ${HTTP_OK} /xyz/openbmc_project/state/enumerate |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 281 | ${HTTP_NOT_FOUND} /i/dont/exist/ |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 282 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 283 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 284 | Get Data |
| 285 | [Documentation] REST "Get" request url and expect the |
| 286 | ... response OK and data non empty. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 287 | [Tags] Get_Data |
| 288 | [Template] Execute Get And Check Data |
| 289 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 290 | # URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 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 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 295 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 296 | Get Data Validation |
| 297 | [Documentation] REST "Get" request url and expect the |
| 298 | ... pre-defined string in response data. |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 299 | [Tags] Get_Data_Validation |
| 300 | [Template] Execute Get And Verify Data |
| 301 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 302 | # URL Path Expect Data |
| 303 | /xyz/openbmc_project/ /xyz/openbmc_project/logging |
| 304 | /i/dont/exist/ path or object not found: /i/dont/exist |
| 305 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 306 | |
| 307 | Put Response Codes |
| 308 | [Documentation] REST "Put" request url and expect the REST pre-defined |
| 309 | ... codes. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 310 | [Tags] Put_Response_Codes |
| 311 | [Template] Execute Put And Check Response |
| 312 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 313 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 314 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 315 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 316 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 317 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 318 | |
| 319 | Put Data Validation |
| 320 | [Documentation] REST "Put" request url and expect success. |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 321 | [Tags] Put_Data_Validation |
| 322 | [Template] Execute Put And Expect Success |
| 323 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 324 | # URL Path Parm Data |
| 325 | /xyz/openbmc_project/state/host0/attr/RequestedHostTransition |
| 326 | ... xyz.openbmc_project.State.Host.Transition.Off |
| 327 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 328 | |
| 329 | Post Response Code |
| 330 | [Documentation] REST Post request url and expect the |
| 331 | ... REST response code pre define. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 332 | [Tags] Post_Response_Codes |
| 333 | [Template] Execute Post And Check Response |
| 334 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 335 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 336 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 337 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 338 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 339 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/login |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 340 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 341 | |
| 342 | Delete Response Code |
| 343 | [Documentation] REST "Delete" request url and expect the |
| 344 | ... REST response code pre define. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 345 | [Tags] Delete_Response_Codes |
| 346 | [Template] Execute Delete And Check Response |
| 347 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 348 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 349 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 350 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 351 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 352 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/state/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 353 | |
Gunnar Mills | 56b3289 | 2016-11-14 13:56:17 -0600 | [diff] [blame] | 354 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 355 | Verify All REST Objects Are Accessible |
| 356 | [Documentation] Verify all the REST objects are accessible using "GET". |
| 357 | [Tags] Verify_All_REST_Objects_Are_Accessible |
| 358 | |
| 359 | ${uri_list}= Get Sub URI List ${OPENBMC_BASE_URI} |
| 360 | ${error_uri_list}= Create List |
| 361 | :FOR ${uri} IN @{uri_list} |
| 362 | \ ${resp}= Openbmc Get Request ${uri} quiet=${1} |
| 363 | \ Run keyword if '${resp.status_code}' != '${HTTP_OK}' |
| 364 | \ ... Append To List ${error_uri_list} ${uri} : ${resp.status_code} |
| 365 | Should Be Empty ${error_uri_list} |
| 366 | |
Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 367 | *** Keywords *** |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 368 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 369 | Get Sub URI List |
| 370 | [Documentation] Return list of sub URIs inside the URI sent by caller. |
| 371 | [Arguments] ${uri} |
| 372 | # Description of argument(s): |
| 373 | # uri The URI for which all the sub URIs are returned. |
| 374 | # Example: |
| 375 | # "/xyz/openbmc_project/" |
| 376 | ${resp}= Openbmc Get Request ${uri}list quiet=${1} |
| 377 | ${sub_uris}= Collections.Get From Dictionary ${resp.json()} data |
| 378 | [Return] ${sub_uris} |
| 379 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 380 | Execute Get And Check Response |
| 381 | [Documentation] Request "Get" url path and expect REST response code. |
| 382 | [Arguments] ${expected_response_code} ${url_path} |
| 383 | # Description of arguments: |
| 384 | # expected_response_code Expected REST status codes. |
| 385 | # url_path URL path. |
| 386 | ${resp}= Openbmc Get Request ${url_path} |
| 387 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 388 | |
| 389 | Execute Get And Check Data |
| 390 | [Documentation] Request "Get" url path and expect non empty data. |
| 391 | [Arguments] ${url_path} |
| 392 | # Description of arguments: |
| 393 | # url_path URL path. |
| 394 | ${resp}= Openbmc Get Request ${url_path} |
| 395 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 396 | ${jsondata}= To JSON ${resp.content} |
| 397 | Should Not Be Empty ${jsondata["data"]} |
| 398 | |
| 399 | Execute Get And Verify Data |
| 400 | [Documentation] Request "Get" url path and verify data. |
| 401 | [Arguments] ${url_path} ${expected_response_code} |
| 402 | # Description of arguments: |
| 403 | # expected_response_code Expected REST status codes. |
| 404 | # url_path URL path. |
| 405 | ${resp}= Openbmc Get Request ${url_path} |
| 406 | ${jsondata}= To JSON ${resp.content} |
| 407 | Run Keyword If '${resp.status_code}' == '${HTTP_OK}' |
| 408 | ... Should Contain ${jsondata["data"]} ${expected_response_code} |
| 409 | ... ELSE |
| 410 | ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code} |
| 411 | |
| 412 | Execute Put And Check Response |
| 413 | [Documentation] Request "Put" url path and expect REST response code. |
| 414 | [Arguments] ${expected_response_code} ${url_path} |
| 415 | # Description of arguments: |
| 416 | # expected_response_code Expected REST status codes. |
| 417 | # url_path URL path. |
| 418 | ${resp}= Openbmc Put Request ${url_path} |
| 419 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 420 | |
| 421 | Execute Put And Expect Success |
| 422 | [Documentation] Request "Put" on url path. |
| 423 | [Arguments] ${url_path} ${parm} |
| 424 | # Description of arguments: |
| 425 | # url_path URL path. |
| 426 | # parm Value/string to be set. |
| 427 | # expected_response_code Expected REST status codes. |
| 428 | ${parmDict}= Create Dictionary data=${parm} |
| 429 | ${resp}= Openbmc Put Request ${url_path} data=${parmDict} |
| 430 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 431 | |
| 432 | Execute Post And Check Response |
| 433 | [Documentation] Request Post url path and expect REST response code. |
| 434 | [Arguments] ${expected_response_code} ${url_path} |
| 435 | # Description of arguments: |
| 436 | # expected_response_code Expected REST status codes. |
| 437 | # url_path URL path. |
| 438 | ${resp}= Openbmc Post Request ${url_path} |
| 439 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 440 | |
| 441 | Execute Post And Check Data |
| 442 | [Arguments] ${url_path} ${parm} |
| 443 | [Documentation] Request Post on url path and expected non empty data. |
| 444 | # Description of arguments: |
| 445 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 446 | ${data}= Create Dictionary data=@{parm} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 447 | ${resp}= Openbmc Post Request ${url_path} data=${data} |
| 448 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 449 | ${jsondata}= To JSON ${resp.content} |
| 450 | Should Not Be Empty ${jsondata["data"]} |
| 451 | |
| 452 | Execute Delete And Check Response |
| 453 | [Documentation] Request "Delete" url path and expected REST response code. |
| 454 | [Arguments] ${expected_response_code} ${url_path} |
| 455 | # Description of arguments: |
| 456 | # expected_response_code Expected REST status codes. |
| 457 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 458 | ${data}= Create Dictionary data=@{EMPTY} |
| 459 | ${resp}= Openbmc Delete Request ${url_path} data=${data} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 460 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 461 | |
| 462 | Verify JSON Response Content |
| 463 | [Documentation] Verify JSON response data is intact. |
| 464 | [Arguments] ${url_path} ${data_empty}=${EMPTY} |
| 465 | |
| 466 | # Description of argument(s): |
| 467 | # url_path URL path. |
| 468 | # data_empty JSON data element. |
| 469 | |
| 470 | ${resp}= OpenBMC Get Request ${url_path} |
| 471 | ${jsondata}= To JSON ${resp.content} |
| 472 | Run Keyword If '${data_empty}' == '${EMPTY}' |
| 473 | ... Should Be Empty ${jsondata["data"]} |
| 474 | ... ELSE |
| 475 | ... Should Not Be Empty ${jsondata["data"]} |
| 476 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 477 | Should Be Equal As Strings ${jsondata["status"]} ok |