manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 1 | *** Settings *** |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 2 | |
| 3 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 4 | Documentation Verify Redfish tool functionality. |
| 5 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 6 | Library OperatingSystem |
| 7 | Library String |
| 8 | Library Collections |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 9 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 10 | Resource ../../lib/resource.robot |
| 11 | Resource ../../lib/bmc_redfish_resource.robot |
| 12 | Resource ../../lib/openbmc_ffdc.robot |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 13 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 14 | |
| 15 | Suite Setup Suite Setup Execution |
| 16 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 17 | |
| 18 | *** Variables *** |
| 19 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 20 | |
| 21 | ${root_cmd_args} redfishtool raw -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always |
| 22 | ${min_number_sensors} ${15} |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 23 | ${min_number_roles} ${4} |
| 24 | ${min_number_users} ${1} |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 25 | |
| 26 | *** Test Cases *** |
| 27 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 28 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 29 | Verify Redfishtool Sensor Commands |
| 30 | [Documentation] Verify redfishtool's sensor commands. |
| 31 | [Tags] Verify_Redfishtool_Sensor_Commands |
| 32 | |
| 33 | ${sensor_status}= Redfishtool Get /redfish/v1/Chassis/chassis/Sensors |
| 34 | ${json_object}= Evaluate json.loads('''${sensor_status}''') json |
| 35 | Should Be True ${json_object["Members@odata.count"]} > ${min_number_sensors} |
| 36 | ... msg=There should be at least ${min_number_sensors} sensors. |
| 37 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 38 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 39 | Verify Redfishtool Health Check Commands |
| 40 | [Documentation] Verify redfishtool's health check command. |
| 41 | [Tags] Verify_Redfishtool_Health_Check_Commands |
| 42 | |
| 43 | ${chassis_data}= Redfishtool Get /redfish/v1/Chassis/chassis/ |
| 44 | ${json_object}= Evaluate json.loads('''${chassis_data}''') json |
| 45 | ${status}= Set Variable ${json_object["Status"]} |
| 46 | Should Be Equal OK ${status["Health"]} |
| 47 | ... msg=Health status should be OK. |
| 48 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 49 | |
| 50 | Verify Redfishtool Create Users |
| 51 | [Documentation] Create user via Redfishtool and verify. |
| 52 | [Tags] Verify_Redfishtool_Create_Users |
| 53 | [Teardown] Redfishtool Delete User "UserT100" |
| 54 | |
| 55 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 56 | Redfishtool Verify User "UserT100" "Operator" |
| 57 | |
| 58 | |
| 59 | Verify Redfishtool Modify Users |
| 60 | [Documentation] Modify user via Redfishtool and verify. |
| 61 | [Tags] Verify_Redfishtool_Modify_Users |
| 62 | [Teardown] Redfishtool Delete User "UserT100" |
| 63 | |
| 64 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 65 | Redfishtool Update User Role "UserT100" "Administrator" |
| 66 | Redfishtool Verify User "UserT100" "Administrator" |
| 67 | |
| 68 | |
| 69 | Verify Redfishtool Delete Users |
| 70 | [Documentation] Delete user via Redfishtool and verify. |
| 71 | [Tags] Verify_Redfishtool_Delete_Users |
| 72 | |
| 73 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 74 | Redfishtool Delete User "UserT100" |
| 75 | ${status}= Redfishtool Verify User Name Exists "UserT100" |
| 76 | Should Be True ${status} == False |
| 77 | |
| 78 | |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 79 | Verify Redfishtool Login With Deleted Redfish Users |
| 80 | [Documentation] Verify login with deleted user via Redfishtool. |
| 81 | [Tags] Verify_Redfishtool_Login_With_Deleted_Redfish_Users |
| 82 | |
| 83 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 84 | Redfishtool Delete User "UserT100" |
| 85 | Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123" ${HTTP_UNAUTHORIZED} |
| 86 | |
| 87 | Verify Redfishtool Error Upon Creating Same Users With Different Privileges |
| 88 | [Documentation] Verify error upon creating same users with different previleges. |
| 89 | [Tags] Verify_Redfishtool_Error_Upon_Creating_Same_Users_With_Different_Privileges |
| 90 | [Teardown] Redfishtool Delete User "UserT100" |
| 91 | |
| 92 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 93 | Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true expected_error=${HTTP_BAD_REQUEST} |
| 94 | |
| 95 | |
| 96 | Verify Redfishtool Admin User Privilege |
| 97 | [Documentation] Verify previlege of admin user. |
| 98 | [Tags] Verify_Redfishtool_Admin_User_Privilege |
| 99 | [Teardown] Run Keywords Redfishtool Delete User "UserT100" AND |
| 100 | ... Redfishtool Delete User "UserT101" |
| 101 | |
| 102 | Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true |
| 103 | |
| 104 | # Verify if an user can be added by admin |
| 105 | Redfishtool Create User "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" |
| 106 | |
| 107 | |
| 108 | Verify Redfishtool ReadOnly User Privilege |
| 109 | [Documentation] Verify Redfishtool ReadOnly user privilege works. |
| 110 | [Tags] Verify_Redfishtool_ReadOnly_User_Privilege |
| 111 | [Teardown] Redfishtool Delete User "UserT100" |
| 112 | |
| 113 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
| 114 | Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123" |
| 115 | |
| 116 | Redfishtool Create User |
| 117 | ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN} |
| 118 | |
| 119 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 120 | *** Keywords *** |
| 121 | |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 122 | Redfishtool Access Resource |
| 123 | [Documentation] Access resource. |
| 124 | [Arguments] ${uri} ${login_user} ${login_pasword} ${expected_error}="" |
| 125 | |
| 126 | # Description of argument(s): |
| 127 | # uri URI for resource access. |
| 128 | # login_user The login user name used other than default root user. |
| 129 | # login_pasword The login password. |
| 130 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 131 | # authentication error, etc. ) |
| 132 | |
| 133 | ${user_cmd_args}= Set Variable |
| 134 | ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
| 135 | Redfishtool Get ${uri} ${user_cmd_args} ${expected_error} |
| 136 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 137 | |
| 138 | Is HTTP error Expected |
| 139 | [Documentation] Check if the HTTP error is expected. |
| 140 | [Arguments] ${cmd_output} ${error_expected} |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 141 | |
| 142 | # Description of argument(s): |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 143 | # cmd_output Output of an HTTP operation. |
| 144 | # error_expected Expected error. |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 145 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 146 | ${error_expected}= Evaluate "${error_expected}" in """${cmd_output}""" |
| 147 | Should Be True ${error_expected} == True |
| 148 | |
| 149 | |
| 150 | Redfishtool Create User |
| 151 | [Documentation] Create new user. |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 152 | [Arguments] ${user_name} ${password} ${roleID} ${enable} ${login_user}="" ${login_pasword}="" ${expected_error}="" |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 153 | |
| 154 | # Description of argument(s): |
| 155 | # user_name The user name (e.g. "test", "robert", etc.). |
| 156 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 157 | # roleID The role of user (e.g. "Administrator", "Operator", etc.). |
| 158 | # enable Enabled attribute of (e.g. true or false). |
| 159 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 160 | # authentication error, etc. ) |
| 161 | |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 162 | ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 163 | ${data}= Set Variable '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}' |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 164 | Run Keyword If ${login_user} == "" |
| 165 | ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} ${expected_error} |
| 166 | ... ELSE |
| 167 | ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${user_cmd_args} ${expected_error} |
| 168 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 169 | |
| 170 | Redfishtool Update User Role |
| 171 | [Documentation] Update user role. |
| 172 | [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}="" |
| 173 | ... ${expected_error}="" |
| 174 | |
| 175 | # Description of argument(s): |
| 176 | # user_name The user name (e.g. "test", "robert", etc.). |
| 177 | # newRole The new role of user (e.g. "Administrator", "Operator", etc.). |
| 178 | # login_user The login user name used other than default root user. |
| 179 | # login_pasword The login password. |
| 180 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 181 | # authentication error, etc. ) |
| 182 | |
manashsarma | ea14dae | 2020-03-26 11:00:27 -0500 | [diff] [blame^] | 183 | ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
| 184 | Run Keyword If ${login_user} == "" |
| 185 | ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${root_cmd_args} ${expected_error} |
| 186 | ... ELSE |
| 187 | ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${user_cmd_args} ${expected_error} |
| 188 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 189 | |
| 190 | Redfishtool Delete User |
| 191 | [Documentation] Delete an user. |
| 192 | [Arguments] ${user_name} ${expected_error}="" |
| 193 | |
| 194 | # Description of argument(s): |
| 195 | # user_name The user name (e.g. "test", "robert", etc.). |
| 196 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 197 | # authentication error, etc. ). |
| 198 | |
| 199 | Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name} |
| 200 | ... ${root_cmd_args} ${expected_error} |
| 201 | |
| 202 | |
| 203 | Redfishtool Verify User |
| 204 | [Documentation] Verify role of the user. |
| 205 | [Arguments] ${user_name} ${role} |
| 206 | |
| 207 | # Description of argument(s): |
| 208 | # user_name The user name (e.g. "test", "robert", etc.). |
| 209 | # role The new role of user (e.g. "Administrator", "Operator", etc.). |
| 210 | |
| 211 | ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name} |
| 212 | ${json_obj}= Evaluate json.loads('''${user_account}''') json |
| 213 | Should Be equal "${json_obj["RoleId"]}" ${role} |
| 214 | |
| 215 | |
| 216 | Redfishtool Verify User Name Exists |
| 217 | [Documentation] Verify user name exists. |
| 218 | [Arguments] ${user_name} |
| 219 | |
| 220 | # Description of argument(s): |
| 221 | # user_name The user name (e.g. "test", "robert", etc.). |
| 222 | |
| 223 | ${status}= Run Keyword And Return Status redfishtool Get |
| 224 | ... /redfish/v1/AccountService/Accounts/${user_name} |
| 225 | [return] ${status} |
| 226 | |
| 227 | |
| 228 | Redfishtool Get |
| 229 | [Documentation] Execute redfishtool for GET operation. |
| 230 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 231 | |
| 232 | # Description of argument(s): |
| 233 | # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 234 | # cmd_args Commandline arguments. |
| 235 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 236 | # authentication error, etc. ). |
| 237 | |
| 238 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri} |
| 239 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 240 | [Return] ${cmd_output} |
| 241 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 242 | |
| 243 | Redfishtool Post |
| 244 | [Documentation] Execute redfishtool for Post operation. |
| 245 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 246 | |
| 247 | # Description of argument(s): |
| 248 | # payload Payload with POST operation (e.g. data for user name, password, role, |
| 249 | # enabled attribute) |
| 250 | # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 251 | # cmd_args Commandline arguments. |
| 252 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 253 | # authentication error, etc. ). |
| 254 | |
| 255 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload} |
| 256 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 257 | [Return] ${cmd_output} |
| 258 | |
| 259 | |
| 260 | Redfishtool Patch |
| 261 | [Documentation] Execute redfishtool for Patch operation. |
| 262 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 263 | |
| 264 | # Description of argument(s): |
| 265 | # payload Payload with POST operation (e.g. data for user name, role, etc. ). |
| 266 | # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ). |
| 267 | # cmd_args Commandline arguments. |
| 268 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 269 | # authentication error, etc. ). |
| 270 | |
| 271 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload} |
| 272 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 273 | [Return] ${cmd_output} |
| 274 | |
| 275 | |
| 276 | Redfishtool Delete |
| 277 | [Documentation] Execute redfishtool for Post operation. |
| 278 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 279 | |
| 280 | # Description of argument(s): |
| 281 | # uri URI for DELETE operation. |
| 282 | # cmd_args Commandline arguments. |
| 283 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 284 | # authentication error, etc. ). |
| 285 | |
| 286 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri} |
| 287 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 288 | [Return] ${cmd_output} |
| 289 | |
| 290 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 291 | Suite Setup Execution |
| 292 | [Documentation] Do suite setup execution. |
| 293 | |
| 294 | ${tool_exist}= Run which redfishtool |
| 295 | Should Not Be Empty ${tool_exist} |