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