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 | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 23 | |
| 24 | *** Test Cases *** |
| 25 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 26 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 27 | Verify Redfishtool Sensor Commands |
| 28 | [Documentation] Verify redfishtool's sensor commands. |
| 29 | [Tags] Verify_Redfishtool_Sensor_Commands |
| 30 | |
| 31 | ${sensor_status}= Redfishtool Get /redfish/v1/Chassis/chassis/Sensors |
| 32 | ${json_object}= Evaluate json.loads('''${sensor_status}''') json |
| 33 | Should Be True ${json_object["Members@odata.count"]} > ${min_number_sensors} |
| 34 | ... msg=There should be at least ${min_number_sensors} sensors. |
| 35 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 36 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 37 | Verify Redfishtool Health Check Commands |
| 38 | [Documentation] Verify redfishtool's health check command. |
| 39 | [Tags] Verify_Redfishtool_Health_Check_Commands |
| 40 | |
| 41 | ${chassis_data}= Redfishtool Get /redfish/v1/Chassis/chassis/ |
| 42 | ${json_object}= Evaluate json.loads('''${chassis_data}''') json |
| 43 | ${status}= Set Variable ${json_object["Status"]} |
| 44 | Should Be Equal OK ${status["Health"]} |
| 45 | ... msg=Health status should be OK. |
| 46 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 47 | |
| 48 | Verify Redfishtool Create Users |
| 49 | [Documentation] Create user via Redfishtool and verify. |
| 50 | [Tags] Verify_Redfishtool_Create_Users |
| 51 | [Teardown] Redfishtool Delete User "UserT100" |
| 52 | |
| 53 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 54 | Redfishtool Verify User "UserT100" "Operator" |
| 55 | |
| 56 | |
| 57 | Verify Redfishtool Modify Users |
| 58 | [Documentation] Modify user via Redfishtool and verify. |
| 59 | [Tags] Verify_Redfishtool_Modify_Users |
| 60 | [Teardown] Redfishtool Delete User "UserT100" |
| 61 | |
| 62 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 63 | Redfishtool Update User Role "UserT100" "Administrator" |
| 64 | Redfishtool Verify User "UserT100" "Administrator" |
| 65 | |
| 66 | |
| 67 | Verify Redfishtool Delete Users |
| 68 | [Documentation] Delete user via Redfishtool and verify. |
| 69 | [Tags] Verify_Redfishtool_Delete_Users |
| 70 | |
| 71 | Redfishtool Create User "UserT100" "TestPwd123" "Operator" true |
| 72 | Redfishtool Delete User "UserT100" |
| 73 | ${status}= Redfishtool Verify User Name Exists "UserT100" |
| 74 | Should Be True ${status} == False |
| 75 | |
| 76 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 77 | *** Keywords *** |
| 78 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 79 | |
| 80 | Is HTTP error Expected |
| 81 | [Documentation] Check if the HTTP error is expected. |
| 82 | [Arguments] ${cmd_output} ${error_expected} |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 83 | |
| 84 | # Description of argument(s): |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 85 | # cmd_output Output of an HTTP operation. |
| 86 | # error_expected Expected error. |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 87 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 88 | ${error_expected}= Evaluate "${error_expected}" in """${cmd_output}""" |
| 89 | Should Be True ${error_expected} == True |
| 90 | |
| 91 | |
| 92 | Redfishtool Create User |
| 93 | [Documentation] Create new user. |
| 94 | [Arguments] ${user_name} ${password} ${roleID} ${enable} ${expected_error}="" |
| 95 | |
| 96 | # Description of argument(s): |
| 97 | # user_name The user name (e.g. "test", "robert", etc.). |
| 98 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 99 | # roleID The role of user (e.g. "Administrator", "Operator", etc.). |
| 100 | # enable Enabled attribute of (e.g. true or false). |
| 101 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 102 | # authentication error, etc. ) |
| 103 | |
| 104 | ${data}= Set Variable '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}' |
| 105 | Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} |
| 106 | ... ${expected_error} |
| 107 | |
| 108 | Redfishtool Update User Role |
| 109 | [Documentation] Update user role. |
| 110 | [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}="" |
| 111 | ... ${expected_error}="" |
| 112 | |
| 113 | # Description of argument(s): |
| 114 | # user_name The user name (e.g. "test", "robert", etc.). |
| 115 | # newRole The new role of user (e.g. "Administrator", "Operator", etc.). |
| 116 | # login_user The login user name used other than default root user. |
| 117 | # login_pasword The login password. |
| 118 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 119 | # authentication error, etc. ) |
| 120 | |
| 121 | Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} |
| 122 | ... ${root_cmd_args} ${expected_error} |
| 123 | |
| 124 | Redfishtool Delete User |
| 125 | [Documentation] Delete an user. |
| 126 | [Arguments] ${user_name} ${expected_error}="" |
| 127 | |
| 128 | # Description of argument(s): |
| 129 | # user_name The user name (e.g. "test", "robert", etc.). |
| 130 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 131 | # authentication error, etc. ). |
| 132 | |
| 133 | Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name} |
| 134 | ... ${root_cmd_args} ${expected_error} |
| 135 | |
| 136 | |
| 137 | Redfishtool Verify User |
| 138 | [Documentation] Verify role of the user. |
| 139 | [Arguments] ${user_name} ${role} |
| 140 | |
| 141 | # Description of argument(s): |
| 142 | # user_name The user name (e.g. "test", "robert", etc.). |
| 143 | # role The new role of user (e.g. "Administrator", "Operator", etc.). |
| 144 | |
| 145 | ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name} |
| 146 | ${json_obj}= Evaluate json.loads('''${user_account}''') json |
| 147 | Should Be equal "${json_obj["RoleId"]}" ${role} |
| 148 | |
| 149 | |
| 150 | Redfishtool Verify User Name Exists |
| 151 | [Documentation] Verify user name exists. |
| 152 | [Arguments] ${user_name} |
| 153 | |
| 154 | # Description of argument(s): |
| 155 | # user_name The user name (e.g. "test", "robert", etc.). |
| 156 | |
| 157 | ${status}= Run Keyword And Return Status redfishtool Get |
| 158 | ... /redfish/v1/AccountService/Accounts/${user_name} |
| 159 | [return] ${status} |
| 160 | |
| 161 | |
| 162 | Redfishtool Get |
| 163 | [Documentation] Execute redfishtool for GET operation. |
| 164 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 165 | |
| 166 | # Description of argument(s): |
| 167 | # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 168 | # cmd_args Commandline arguments. |
| 169 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 170 | # authentication error, etc. ). |
| 171 | |
| 172 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri} |
| 173 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 174 | [Return] ${cmd_output} |
| 175 | |
manashsarma | 91abf37 | 2020-03-17 20:34:02 -0500 | [diff] [blame] | 176 | |
| 177 | Redfishtool Post |
| 178 | [Documentation] Execute redfishtool for Post operation. |
| 179 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 180 | |
| 181 | # Description of argument(s): |
| 182 | # payload Payload with POST operation (e.g. data for user name, password, role, |
| 183 | # enabled attribute) |
| 184 | # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 185 | # cmd_args Commandline arguments. |
| 186 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 187 | # authentication error, etc. ). |
| 188 | |
| 189 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload} |
| 190 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 191 | [Return] ${cmd_output} |
| 192 | |
| 193 | |
| 194 | Redfishtool Patch |
| 195 | [Documentation] Execute redfishtool for Patch operation. |
| 196 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 197 | |
| 198 | # Description of argument(s): |
| 199 | # payload Payload with POST operation (e.g. data for user name, role, etc. ). |
| 200 | # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ). |
| 201 | # cmd_args Commandline arguments. |
| 202 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 203 | # authentication error, etc. ). |
| 204 | |
| 205 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload} |
| 206 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 207 | [Return] ${cmd_output} |
| 208 | |
| 209 | |
| 210 | Redfishtool Delete |
| 211 | [Documentation] Execute redfishtool for Post operation. |
| 212 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}="" |
| 213 | |
| 214 | # Description of argument(s): |
| 215 | # uri URI for DELETE operation. |
| 216 | # cmd_args Commandline arguments. |
| 217 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 218 | # authentication error, etc. ). |
| 219 | |
| 220 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri} |
| 221 | Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error} |
| 222 | [Return] ${cmd_output} |
| 223 | |
| 224 | |
manashsarma | 8b5d680 | 2020-03-09 04:09:15 -0500 | [diff] [blame] | 225 | Suite Setup Execution |
| 226 | [Documentation] Do suite setup execution. |
| 227 | |
| 228 | ${tool_exist}= Run which redfishtool |
| 229 | Should Not Be Empty ${tool_exist} |