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 |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 7 | Library Collections |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 8 | Test Teardown FFDC On Test Case Fail |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 9 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 10 | *** Variables *** |
| 11 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | *** Test Cases *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 13 | |
George Keishing | 89f7c1f | 2017-05-03 16:08:37 -0500 | [diff] [blame] | 14 | REST Login Session To BMC |
| 15 | [Documentation] Test REST session log-in. |
| 16 | [Tags] REST_Login_Session_To_BMC |
| 17 | |
| 18 | Initialize OpenBMC |
| 19 | # Raw GET REST operation to verify session is established. |
| 20 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 21 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 22 | |
| 23 | |
| 24 | REST Logout Session To BMC |
| 25 | [Documentation] Test REST session log-out. |
| 26 | [Tags] REST_Logout_Session_To_BMC |
| 27 | |
| 28 | Initialize OpenBMC |
| 29 | Log Out OpenBMC |
| 30 | # Raw GET REST operation to verify session is logout. |
| 31 | ${resp}= Get Request openbmc /xyz/openbmc_project/ |
| 32 | Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED} |
| 33 | |
| 34 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 35 | Get Response Codes |
| 36 | [Documentation] REST "Get" response status test. |
| 37 | #-------------------------------------------------------------------- |
| 38 | # Expect status URL Path |
| 39 | #-------------------------------------------------------------------- |
| 40 | ${HTTP_OK} / |
| 41 | ${HTTP_OK} /xyz/ |
| 42 | ${HTTP_OK} /xyz/openbmc_project/ |
| 43 | ${HTTP_OK} /xyz/openbmc_project/enumerate |
| 44 | ${HTTP_NOT_FOUND} /i/dont/exist/ |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 45 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 46 | [Tags] Get_Response_Codes |
| 47 | [Template] Execute Get And Check Response |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 48 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 49 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 50 | Get Data |
| 51 | [Documentation] REST "Get" request url and expect the |
| 52 | ... response OK and data non empty. |
| 53 | #-------------------------------------------------------------------- |
| 54 | # URL Path |
| 55 | #-------------------------------------------------------------------- |
| 56 | /xyz/openbmc_project/ |
| 57 | /xyz/openbmc_project/list |
| 58 | /xyz/openbmc_project/enumerate |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 59 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 60 | [Tags] Get_Data |
| 61 | [Template] Execute Get And Check Data |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 62 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 63 | |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 64 | Get Data Validation |
| 65 | [Documentation] REST "Get" request url and expect the |
| 66 | ... pre-defined string in response data. |
| 67 | #-------------------------------------------------------------------- |
| 68 | # URL Path Expect Data |
| 69 | #-------------------------------------------------------------------- |
| 70 | /xyz/openbmc_project/ /xyz/openbmc_project/logging |
| 71 | /i/dont/exist/ path or object not found: /i/dont/exist |
| 72 | |
| 73 | [Tags] Get_Data_Validation |
| 74 | [Template] Execute Get And Verify Data |
| 75 | |
| 76 | |
| 77 | Put Response Codes |
| 78 | [Documentation] REST "Put" request url and expect the REST pre-defined |
| 79 | ... codes. |
| 80 | #-------------------------------------------------------------------- |
| 81 | # Expect status URL Path |
| 82 | #-------------------------------------------------------------------- |
| 83 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 84 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 85 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
| 86 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/list |
| 87 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate |
| 88 | |
| 89 | [Tags] Put_Response_Codes |
| 90 | [Template] Execute Put And Check Response |
| 91 | |
| 92 | |
| 93 | Put Data Validation |
| 94 | [Documentation] REST "Put" request url and expect success. |
| 95 | #-------------------------------------------------------------------- |
| 96 | # URL Path Parm Data |
| 97 | #-------------------------------------------------------------------- |
| 98 | /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off |
| 99 | |
| 100 | [Tags] Put_Data_Validation |
| 101 | [Template] Execute Put And Expect Success |
| 102 | |
| 103 | |
| 104 | Post Response Code |
| 105 | [Documentation] REST Post request url and expect the |
| 106 | ... REST response code pre define. |
| 107 | #-------------------------------------------------------------------- |
| 108 | # Expect status URL Path |
| 109 | #-------------------------------------------------------------------- |
| 110 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 111 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 112 | ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/ |
| 113 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate |
| 114 | |
| 115 | [Tags] Post_Response_Codes |
| 116 | [Template] Execute Post And Check Response |
| 117 | |
| 118 | |
| 119 | Delete Response Code |
| 120 | [Documentation] REST "Delete" request url and expect the |
| 121 | ... REST response code pre define. |
| 122 | #-------------------------------------------------------------------- |
| 123 | # Expect status URL Path |
| 124 | #-------------------------------------------------------------------- |
| 125 | ${HTTP_METHOD_NOT_ALLOWED} / |
| 126 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/ |
| 127 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/ |
| 128 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate |
| 129 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/list |
| 130 | ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/enumerate |
| 131 | |
| 132 | [Tags] Delete_Response_Codes |
| 133 | [Template] Execute Delete And Check Response |
| 134 | |
Gunnar Mills | 56b3289 | 2016-11-14 13:56:17 -0600 | [diff] [blame] | 135 | |
Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 136 | *** Keywords *** |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 137 | |
| 138 | Execute Get And Check Response |
| 139 | [Documentation] Request "Get" url path and expect REST response code. |
| 140 | [Arguments] ${expected_response_code} ${url_path} |
| 141 | # Description of arguments: |
| 142 | # expected_response_code Expected REST status codes. |
| 143 | # url_path URL path. |
| 144 | ${resp}= Openbmc Get Request ${url_path} |
| 145 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 146 | |
| 147 | Execute Get And Check Data |
| 148 | [Documentation] Request "Get" url path and expect non empty data. |
| 149 | [Arguments] ${url_path} |
| 150 | # Description of arguments: |
| 151 | # url_path URL path. |
| 152 | ${resp}= Openbmc Get Request ${url_path} |
| 153 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 154 | ${jsondata}= To JSON ${resp.content} |
| 155 | Should Not Be Empty ${jsondata["data"]} |
| 156 | |
| 157 | Execute Get And Verify Data |
| 158 | [Documentation] Request "Get" url path and verify data. |
| 159 | [Arguments] ${url_path} ${expected_response_code} |
| 160 | # Description of arguments: |
| 161 | # expected_response_code Expected REST status codes. |
| 162 | # url_path URL path. |
| 163 | ${resp}= Openbmc Get Request ${url_path} |
| 164 | ${jsondata}= To JSON ${resp.content} |
| 165 | Run Keyword If '${resp.status_code}' == '${HTTP_OK}' |
| 166 | ... Should Contain ${jsondata["data"]} ${expected_response_code} |
| 167 | ... ELSE |
| 168 | ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code} |
| 169 | |
| 170 | Execute Put And Check Response |
| 171 | [Documentation] Request "Put" url path and expect REST response code. |
| 172 | [Arguments] ${expected_response_code} ${url_path} |
| 173 | # Description of arguments: |
| 174 | # expected_response_code Expected REST status codes. |
| 175 | # url_path URL path. |
| 176 | ${resp}= Openbmc Put Request ${url_path} |
| 177 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 178 | |
| 179 | Execute Put And Expect Success |
| 180 | [Documentation] Request "Put" on url path. |
| 181 | [Arguments] ${url_path} ${parm} |
| 182 | # Description of arguments: |
| 183 | # url_path URL path. |
| 184 | # parm Value/string to be set. |
| 185 | # expected_response_code Expected REST status codes. |
| 186 | ${parmDict}= Create Dictionary data=${parm} |
| 187 | ${resp}= Openbmc Put Request ${url_path} data=${parmDict} |
| 188 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 189 | |
| 190 | Execute Post And Check Response |
| 191 | [Documentation] Request Post url path and expect REST response code. |
| 192 | [Arguments] ${expected_response_code} ${url_path} |
| 193 | # Description of arguments: |
| 194 | # expected_response_code Expected REST status codes. |
| 195 | # url_path URL path. |
| 196 | ${resp}= Openbmc Post Request ${url_path} |
| 197 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |
| 198 | |
| 199 | Execute Post And Check Data |
| 200 | [Arguments] ${url_path} ${parm} |
| 201 | [Documentation] Request Post on url path and expected non empty data. |
| 202 | # Description of arguments: |
| 203 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 204 | ${data}= Create Dictionary data=@{parm} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 205 | ${resp}= Openbmc Post Request ${url_path} data=${data} |
| 206 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 207 | ${jsondata}= To JSON ${resp.content} |
| 208 | Should Not Be Empty ${jsondata["data"]} |
| 209 | |
| 210 | Execute Delete And Check Response |
| 211 | [Documentation] Request "Delete" url path and expected REST response code. |
| 212 | [Arguments] ${expected_response_code} ${url_path} |
| 213 | # Description of arguments: |
| 214 | # expected_response_code Expected REST status codes. |
| 215 | # url_path URL path. |
George Keishing | 4c02e62 | 2017-04-17 07:57:10 -0500 | [diff] [blame] | 216 | ${data}= Create Dictionary data=@{EMPTY} |
| 217 | ${resp}= Openbmc Delete Request ${url_path} data=${data} |
George Keishing | 8553666 | 2017-03-03 10:49:58 -0600 | [diff] [blame] | 218 | Should Be Equal As Strings ${resp.status_code} ${expected_response_code} |