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 |
George Keishing | b53a37e | 2018-10-26 11:59:34 -0500 | [diff] [blame] | 9 | |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 10 | Test Teardown FFDC On Test Case Fail |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 11 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | *** Variables *** |
| 13 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 14 | *** Test Cases *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | |
George Keishing | 89f7c1f | 2017-05-03 16:08:37 -0500 | [diff] [blame] | 16 | REST Login Session To BMC |
| 17 | [Documentation] Test REST session log-in. |
| 18 | [Tags] REST_Login_Session_To_BMC |
| 19 | |
| 20 | Initialize OpenBMC |
| 21 | # Raw GET REST operation to verify session is established. |
| 22 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 23 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 24 | |
| 25 | |
| 26 | REST Logout Session To BMC |
| 27 | [Documentation] Test REST session log-out. |
| 28 | [Tags] REST_Logout_Session_To_BMC |
| 29 | |
| 30 | Initialize OpenBMC |
| 31 | Log Out OpenBMC |
| 32 | # Raw GET REST operation to verify session is logout. |
| 33 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 34 | Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED} |
| 35 | |
| 36 | |
George Keishing | 6715f31 | 2017-05-10 03:22:40 -0500 | [diff] [blame] | 37 | REST Delete All Sessions And Expect Error |
| 38 | [Documentation] Test REST empty cache using delete operation. |
| 39 | [Tags] REST_Delete_All_Sessions_And_Expect_Error |
| 40 | |
| 41 | # Throws exception: |
| 42 | # Non-existing index or alias 'openbmc'. |
| 43 | |
| 44 | Initialize OpenBMC |
| 45 | Delete All Sessions |
| 46 | # Raw GET REST operation and expect exception error. |
| 47 | Run Keyword And Expect Error |
| 48 | ... Non-existing index or alias 'openbmc'. |
| 49 | ... Get Request openbmc /xyz/openbmc_project/ |
| 50 | |
| 51 | |
George Keishing | 3b1f277 | 2017-07-31 09:44:45 -0500 | [diff] [blame] | 52 | Multiple Requests On BMC Using Single REST Session |
| 53 | [Documentation] Trigger multiple REST operations using an active |
| 54 | ... connection session. |
| 55 | [Tags] Multiple_Requests_On_BMC_Using_Single_REST_Session |
| 56 | |
| 57 | Initialize OpenBMC |
| 58 | |
| 59 | # Session object "openbmc". |
| 60 | ${resp}= Get Request openbmc /xyz/openbmc_project/state/ |
| 61 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 62 | |
| 63 | ${resp}= Get Request openbmc /xyz/openbmc_project/software/enumerate |
| 64 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 65 | |
| 66 | |
George Keishing | 6715f31 | 2017-05-10 03:22:40 -0500 | [diff] [blame] | 67 | Verify REST JSON Data On Success |
| 68 | [Documentation] Verify JSON data success response messages. |
| 69 | [Tags] Verify_REST_JSON_Data_On_Success |
| 70 | # Example: |
| 71 | # Response code:200, Content:{ |
| 72 | # "data": [ |
| 73 | # "/xyz/openbmc_project/sensors", |
| 74 | # "/xyz/openbmc_project/inventory", |
| 75 | # "/xyz/openbmc_project/software", |
| 76 | # "/xyz/openbmc_project/object_mapper", |
| 77 | # "/xyz/openbmc_project/logging" |
| 78 | # ], |
| 79 | # "message": "200 OK", |
| 80 | # "status": "ok" |
| 81 | # } |
| 82 | |
| 83 | ${resp}= OpenBMC Get Request /xyz/openbmc_project/ |
| 84 | ${jsondata}= To JSON ${resp.content} |
| 85 | Should Not Be Empty ${jsondata["data"]} |
| 86 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 87 | Should Be Equal As Strings ${jsondata["status"]} ok |
| 88 | |
| 89 | |
| 90 | Verify REST JSON Data On Failure |
| 91 | [Documentation] Verify JSON data failure response messages. |
| 92 | [Tags] Verify_REST_JSON_Data_On_Failure |
| 93 | # Example: |
| 94 | # Response code:404, Content:{ |
| 95 | # "data": { |
Andrew Geissler | b4312f3 | 2018-11-14 15:57:49 -0600 | [diff] [blame] | 96 | # "description": "org.freedesktop.DBus.Error.FileNotFound: path or object not found: |
| 97 | # /xyz/idont/exist" |
George Keishing | 6715f31 | 2017-05-10 03:22:40 -0500 | [diff] [blame] | 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} |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 105 | Should Be Equal As Strings ${jsondata["data"]["description"]} |
Andrew Geissler | b4312f3 | 2018-11-14 15:57:49 -0600 | [diff] [blame] | 106 | ... 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] | 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. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 272 | [Tags] Get_Response_Codes |
| 273 | [Template] Execute Get And Check Response |
| 274 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 275 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 276 | ${HTTP_OK} /xyz/openbmc_project/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 277 | ${HTTP_OK} /xyz/openbmc_project/state/enumerate |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 278 | ${HTTP_NOT_FOUND} /i/dont/exist/ |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 279 | |
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 | Get Data |
| 282 | [Documentation] REST "Get" request url and expect the |
| 283 | ... response OK and data non empty. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 284 | [Tags] Get_Data |
| 285 | [Template] Execute Get And Check Data |
| 286 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 287 | # URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 288 | /xyz/openbmc_project/ |
| 289 | /xyz/openbmc_project/list |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 290 | /xyz/openbmc_project/state/enumerate |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 291 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 292 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 293 | Get Data Validation |
| 294 | [Documentation] REST "Get" request url and expect the |
| 295 | ... pre-defined string in response data. |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 296 | [Tags] Get_Data_Validation |
| 297 | [Template] Execute Get And Verify Data |
| 298 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 299 | # URL Path Expect Data |
| 300 | /xyz/openbmc_project/ /xyz/openbmc_project/logging |
| 301 | /i/dont/exist/ path or object not found: /i/dont/exist |
| 302 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 303 | |
| 304 | Put Response Codes |
| 305 | [Documentation] REST "Put" request url and expect the REST pre-defined |
| 306 | ... codes. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 307 | [Tags] Put_Response_Codes |
| 308 | [Template] Execute Put And Check Response |
| 309 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 310 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 311 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 312 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 313 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 314 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 315 | |
| 316 | Put Data Validation |
| 317 | [Documentation] REST "Put" request url and expect success. |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 318 | [Tags] Put_Data_Validation |
| 319 | [Template] Execute Put And Expect Success |
| 320 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 321 | # URL Path Parm Data |
| 322 | /xyz/openbmc_project/state/host0/attr/RequestedHostTransition |
| 323 | ... xyz.openbmc_project.State.Host.Transition.Off |
| 324 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 325 | |
| 326 | Post Response Code |
| 327 | [Documentation] REST Post request url and expect the |
| 328 | ... REST response code pre define. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 329 | [Tags] Post_Response_Codes |
| 330 | [Template] Execute Post And Check Response |
| 331 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 332 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 333 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 334 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 335 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 336 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/login |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 337 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 338 | |
| 339 | Delete Response Code |
| 340 | [Documentation] REST "Delete" request url and expect the |
| 341 | ... REST response code pre define. |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 342 | [Tags] Delete_Response_Codes |
| 343 | [Template] Execute Delete And Check Response |
| 344 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 345 | # Expect status URL Path |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 346 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 347 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 348 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/ |
George Keishing | 5cb75f8 | 2017-12-11 08:41:34 -0600 | [diff] [blame] | 349 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/state/ |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 350 | |
Gunnar Mills | 56b3289 | 2016-11-14 13:56:17 -0600 | [diff] [blame] | 351 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 352 | Verify All REST Objects Are Accessible |
| 353 | [Documentation] Verify all the REST objects are accessible using "GET". |
| 354 | [Tags] Verify_All_REST_Objects_Are_Accessible |
| 355 | |
| 356 | ${uri_list}= Get Sub URI List ${OPENBMC_BASE_URI} |
George Keishing | 32e4d17 | 2018-10-01 07:41:56 -0500 | [diff] [blame] | 357 | |
| 358 | # URI's which won't support GET request. |
| 359 | Remove Values From List ${uri_list} |
| 360 | ... /xyz/openbmc_project/certs/client/ldap |
| 361 | ... /xyz/openbmc_project/certs/server/https |
George Keishing | 97ab251 | 2018-10-12 01:47:01 -0500 | [diff] [blame] | 362 | ... /xyz/openbmc_project/certs/authority/ldap |
George Keishing | 32e4d17 | 2018-10-01 07:41:56 -0500 | [diff] [blame] | 363 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 364 | ${error_uri_list}= Create List |
| 365 | :FOR ${uri} IN @{uri_list} |
| 366 | \ ${resp}= Openbmc Get Request ${uri} quiet=${1} |
| 367 | \ Run keyword if '${resp.status_code}' != '${HTTP_OK}' |
| 368 | \ ... Append To List ${error_uri_list} ${uri} : ${resp.status_code} |
| 369 | Should Be Empty ${error_uri_list} |
| 370 | |
Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 371 | *** Keywords *** |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 372 | |
manasarm | 5f76a2d | 2018-01-11 11:34:41 +0530 | [diff] [blame] | 373 | Get Sub URI List |
| 374 | [Documentation] Return list of sub URIs inside the URI sent by caller. |
| 375 | [Arguments] ${uri} |
| 376 | # Description of argument(s): |
| 377 | # uri The URI for which all the sub URIs are returned. |
| 378 | # Example: |
| 379 | # "/xyz/openbmc_project/" |
| 380 | ${resp}= Openbmc Get Request ${uri}list quiet=${1} |
| 381 | ${sub_uris}= Collections.Get From Dictionary ${resp.json()} data |
| 382 | [Return] ${sub_uris} |
| 383 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 384 | Execute Get And Check Response |
| 385 | [Documentation] Request "Get" url path and expect REST response code. |
| 386 | [Arguments] ${expected_response_code} ${url_path} |
| 387 | # Description of arguments: |
| 388 | # expected_response_code Expected REST status codes. |
| 389 | # url_path URL path. |
| 390 | ${resp}= Openbmc Get Request ${url_path} |
| 391 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 392 | |
| 393 | Execute Get And Check Data |
| 394 | [Documentation] Request "Get" url path and expect non empty data. |
| 395 | [Arguments] ${url_path} |
| 396 | # Description of arguments: |
| 397 | # url_path URL path. |
| 398 | ${resp}= Openbmc Get Request ${url_path} |
| 399 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 400 | ${jsondata}= To JSON ${resp.content} |
| 401 | Should Not Be Empty ${jsondata["data"]} |
| 402 | |
| 403 | Execute Get And Verify Data |
| 404 | [Documentation] Request "Get" url path and verify data. |
| 405 | [Arguments] ${url_path} ${expected_response_code} |
| 406 | # Description of arguments: |
| 407 | # expected_response_code Expected REST status codes. |
| 408 | # url_path URL path. |
| 409 | ${resp}= Openbmc Get Request ${url_path} |
| 410 | ${jsondata}= To JSON ${resp.content} |
| 411 | Run Keyword If '${resp.status_code}' == '${HTTP_OK}' |
| 412 | ... Should Contain ${jsondata["data"]} ${expected_response_code} |
| 413 | ... ELSE |
| 414 | ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code} |
| 415 | |
| 416 | Execute Put And Check Response |
| 417 | [Documentation] Request "Put" url path and expect REST response code. |
| 418 | [Arguments] ${expected_response_code} ${url_path} |
| 419 | # Description of arguments: |
| 420 | # expected_response_code Expected REST status codes. |
| 421 | # url_path URL path. |
| 422 | ${resp}= Openbmc Put Request ${url_path} |
| 423 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 424 | |
| 425 | Execute Put And Expect Success |
| 426 | [Documentation] Request "Put" on url path. |
| 427 | [Arguments] ${url_path} ${parm} |
| 428 | # Description of arguments: |
| 429 | # url_path URL path. |
| 430 | # parm Value/string to be set. |
| 431 | # expected_response_code Expected REST status codes. |
| 432 | ${parmDict}= Create Dictionary data=${parm} |
| 433 | ${resp}= Openbmc Put Request ${url_path} data=${parmDict} |
| 434 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 435 | |
| 436 | Execute Post And Check Response |
| 437 | [Documentation] Request Post url path and expect REST response code. |
| 438 | [Arguments] ${expected_response_code} ${url_path} |
| 439 | # Description of arguments: |
| 440 | # expected_response_code Expected REST status codes. |
| 441 | # url_path URL path. |
| 442 | ${resp}= Openbmc Post Request ${url_path} |
| 443 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 444 | |
| 445 | Execute Post And Check Data |
| 446 | [Arguments] ${url_path} ${parm} |
| 447 | [Documentation] Request Post on url path and expected non empty data. |
| 448 | # Description of arguments: |
| 449 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 450 | ${data}= Create Dictionary data=@{parm} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 451 | ${resp}= Openbmc Post Request ${url_path} data=${data} |
| 452 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 453 | ${jsondata}= To JSON ${resp.content} |
| 454 | Should Not Be Empty ${jsondata["data"]} |
| 455 | |
| 456 | Execute Delete And Check Response |
| 457 | [Documentation] Request "Delete" url path and expected REST response code. |
| 458 | [Arguments] ${expected_response_code} ${url_path} |
| 459 | # Description of arguments: |
| 460 | # expected_response_code Expected REST status codes. |
| 461 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 462 | ${data}= Create Dictionary data=@{EMPTY} |
| 463 | ${resp}= Openbmc Delete Request ${url_path} data=${data} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 464 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
George Keishing | adefa26 | 2017-07-08 12:54:06 -0500 | [diff] [blame] | 465 | |
| 466 | Verify JSON Response Content |
| 467 | [Documentation] Verify JSON response data is intact. |
| 468 | [Arguments] ${url_path} ${data_empty}=${EMPTY} |
| 469 | |
| 470 | # Description of argument(s): |
| 471 | # url_path URL path. |
| 472 | # data_empty JSON data element. |
| 473 | |
| 474 | ${resp}= OpenBMC Get Request ${url_path} |
| 475 | ${jsondata}= To JSON ${resp.content} |
| 476 | Run Keyword If '${data_empty}' == '${EMPTY}' |
| 477 | ... Should Be Empty ${jsondata["data"]} |
| 478 | ... ELSE |
| 479 | ... Should Not Be Empty ${jsondata["data"]} |
| 480 | Should Be Equal As Strings ${jsondata["message"]} 200 OK |
| 481 | Should Be Equal As Strings ${jsondata["status"]} ok |