Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test IPMI and Redfish combinations for user management. |
| 3 | |
| 4 | Resource ../../lib/resource.robot |
| 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | Resource ../../lib/ipmi_client.robot |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 8 | Library ../lib/ipmi_utils.py |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 9 | |
| 10 | Test Setup Test Setup Execution |
| 11 | Test Teardown Test Teardown Execution |
| 12 | |
| 13 | |
| 14 | *** Variables *** |
| 15 | |
| 16 | ${valid_password} 0penBmc1 |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 17 | ${valid_password2} 0penBmc2 |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 18 | ${admin_level_priv} 4 |
| 19 | ${operator_level_priv} 3 |
Ashwini Chandrappa | 6fac289 | 2021-12-13 07:03:35 -0600 | [diff] [blame] | 20 | ${max_num_users} ${17} |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 21 | |
| 22 | ** Test Cases ** |
| 23 | |
| 24 | Create Admin Redfish User And Verify Login Via IPMI |
| 25 | [Documentation] Create user using redfish and verify via IPMI. |
| 26 | [Tags] Create_Admin_Redfish_User_And_Verify_Login_Via_IPMI |
| 27 | |
| 28 | ${random_username}= Generate Random String 8 [LETTERS] |
| 29 | Set Test Variable ${random_username} |
| 30 | |
| 31 | ${payload}= Create Dictionary |
| 32 | ... UserName=${random_username} Password=${valid_password} |
| 33 | ... RoleId=Administrator Enabled=${True} |
| 34 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 35 | ... valid_status_codes=[${HTTP_CREATED}] |
| 36 | |
Sushma M M | 97fccae | 2020-07-27 14:55:19 -0500 | [diff] [blame] | 37 | # Delay added for created new user password to get set. |
| 38 | Sleep 5s |
| 39 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 40 | Verify IPMI Username And Password ${random_username} ${valid_password} |
| 41 | |
| 42 | |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 43 | Update User Password Via Redfish And Verify Using IPMI |
| 44 | [Documentation] Update user password via Redfish and verify using IPMI. |
| 45 | [Tags] Update_User_Password_Via_Redfish_And_Verify_Using_IPMI |
| 46 | |
| 47 | # Create user using Redfish. |
| 48 | ${random_username}= Generate Random String 8 [LETTERS] |
| 49 | Set Test Variable ${random_username} |
| 50 | |
| 51 | ${payload}= Create Dictionary |
| 52 | ... UserName=${random_username} Password=${valid_password} |
| 53 | ... RoleId=Administrator Enabled=${True} |
| 54 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 55 | ... valid_status_codes=[${HTTP_CREATED}] |
| 56 | |
| 57 | # Update user password using Redfish. |
| 58 | ${payload}= Create Dictionary Password=${valid_password2} |
| 59 | Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload} |
| 60 | |
| 61 | # Verify that IPMI command works with new password and fails with older password. |
| 62 | Verify IPMI Username And Password ${random_username} ${valid_password2} |
| 63 | |
Anusha Dathatri | 652fc74 | 2020-02-05 05:14:21 -0600 | [diff] [blame] | 64 | Run Keyword And Expect Error *Error: Unable to establish IPMI* |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 65 | ... Verify IPMI Username And Password ${random_username} ${valid_password} |
| 66 | |
| 67 | |
Rahul Maheshwari | ff63ac0 | 2019-03-29 10:25:21 -0500 | [diff] [blame] | 68 | Update User Privilege Via Redfish And Verify Using IPMI |
| 69 | [Documentation] Update user privilege via Redfish and verify using IPMI. |
| 70 | [Tags] Update_User_Privilege_Via_Redfish_And_Verify_Using_IPMI |
| 71 | |
| 72 | # Create user using Redfish with admin privilege. |
| 73 | ${random_username}= Generate Random String 8 [LETTERS] |
| 74 | Set Test Variable ${random_username} |
| 75 | |
| 76 | ${payload}= Create Dictionary |
| 77 | ... UserName=${random_username} Password=${valid_password} |
| 78 | ... RoleId=Administrator Enabled=${True} |
| 79 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 80 | ... valid_status_codes=[${HTTP_CREATED}] |
| 81 | |
| 82 | # Update user privilege to operator using Redfish. |
| 83 | ${payload}= Create Dictionary RoleId=Operator |
| 84 | Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload} |
| 85 | |
| 86 | # Verify new user privilege level via IPMI. |
Tony Lee | c317c98 | 2020-05-20 15:46:35 +0800 | [diff] [blame] | 87 | ${resp}= Run IPMI Standard Command user list ${CHANNEL_NUMBER} |
Rahul Maheshwari | ff63ac0 | 2019-03-29 10:25:21 -0500 | [diff] [blame] | 88 | |
| 89 | # Example of response data: |
| 90 | # ID Name Callin Link Auth IPMI Msg Channel Priv Limit |
| 91 | # 1 root false true true ADMINISTRATOR |
| 92 | # 2 OAvCxjMv false true true OPERATOR |
| 93 | # 3 true false false NO ACCESS |
| 94 | # .. |
| 95 | # .. |
| 96 | # 15 true false false NO ACCESS |
| 97 | |
| 98 | ${user_info}= |
| 99 | ... Get Lines Containing String ${resp} ${random_username} |
| 100 | Should Contain ${user_info} OPERATOR |
| 101 | |
| 102 | |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 103 | Delete User Via Redfish And Verify Using IPMI |
| 104 | [Documentation] Delete user via redfish and verify using IPMI. |
| 105 | [Tags] Delete_User_Via_Redfish_And_Verify_Using_IPMI |
| 106 | |
| 107 | # Create user using Redfish. |
| 108 | ${random_username}= Generate Random String 8 [LETTERS] |
| 109 | Set Test Variable ${random_username} |
| 110 | |
| 111 | ${payload}= Create Dictionary |
| 112 | ... UserName=${random_username} Password=${valid_password} |
| 113 | ... RoleId=Administrator Enabled=${True} |
| 114 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 115 | ... valid_status_codes=[${HTTP_CREATED}] |
| 116 | |
| 117 | # Delete user using Redfish. |
| 118 | Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} |
| 119 | |
| 120 | # Verify that IPMI command fails with deleted user. |
Anusha Dathatri | 652fc74 | 2020-02-05 05:14:21 -0600 | [diff] [blame] | 121 | Run Keyword And Expect Error *Error: Unable to establish IPMI* |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 122 | ... Verify IPMI Username And Password ${random_username} ${valid_password} |
| 123 | |
| 124 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 125 | Create IPMI User And Verify Login Via Redfish |
| 126 | [Documentation] Create user using IPMI and verify user login via Redfish. |
| 127 | [Tags] Create_IPMI_User_And_Verify_Login_Via_Redfish |
| 128 | |
| 129 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 130 | ... ${valid_password} ${admin_level_priv} |
| 131 | |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 132 | Redfish.Logout |
| 133 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 134 | # Verify user login using Redfish. |
| 135 | Redfish.Login ${username} ${valid_password} |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 136 | Redfish.Logout |
| 137 | |
| 138 | Redfish.Login |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 139 | |
| 140 | |
| 141 | Update User Password Via IPMI And Verify Using Redfish |
| 142 | [Documentation] Update user password using IPMI and verify user |
| 143 | ... login via Redfish. |
| 144 | [Tags] Update_User_Password_Via_IPMI_And_Verify_Using_Redfish |
| 145 | |
| 146 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 147 | ... ${valid_password} ${admin_level_priv} |
| 148 | |
| 149 | # Update user password using IPMI. |
| 150 | Run IPMI Standard Command |
| 151 | ... user set password ${userid} ${valid_password2} |
| 152 | |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 153 | Redfish.Logout |
| 154 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 155 | # Verify that user login works with new password using Redfish. |
| 156 | Redfish.Login ${username} ${valid_password2} |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 157 | Redfish.Logout |
| 158 | |
| 159 | Redfish.Login |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 160 | |
| 161 | |
| 162 | Update User Privilege Via IPMI And Verify Using Redfish |
| 163 | [Documentation] Update user privilege via IPMI and verify using Redfish. |
| 164 | [Tags] Update_User_Privilege_Via_IPMI_And_Verify_Using_Redfish |
| 165 | |
| 166 | # Create user using IPMI with admin privilege. |
| 167 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 168 | ... ${valid_password} ${admin_level_priv} |
| 169 | |
| 170 | # Change user privilege to opetrator using IPMI. |
| 171 | Run IPMI Standard Command |
Tony Lee | 69ed33e | 2020-05-20 17:15:02 +0800 | [diff] [blame] | 172 | ... user priv ${userid} ${operator_level_priv} ${CHANNEL_NUMBER} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 173 | |
| 174 | # Verify new user privilege level via Redfish. |
| 175 | ${privilege}= Redfish_Utils.Get Attribute |
| 176 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
| 177 | Should Be Equal ${privilege} Operator |
| 178 | |
| 179 | |
| 180 | Delete User Via IPMI And Verify Using Redfish |
| 181 | [Documentation] Delete user using IPMI and verify error while doing |
| 182 | ... user login with deleted user via Redfish. |
| 183 | [Tags] Delete_User_Via_IPMI_And_Verify_Using_Redfish |
| 184 | |
| 185 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 186 | ... ${valid_password} ${admin_level_priv} |
| 187 | |
| 188 | # Delete IPMI User. |
| 189 | Run IPMI Standard Command user set name ${userid} "" |
| 190 | |
| 191 | # Verify that Redfish login fails with deleted user. |
| 192 | Run Keyword And Expect Error *InvalidCredentialsError* |
| 193 | ... Redfish.Login ${username} ${valid_password} |
| 194 | |
| 195 | |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 196 | Verify Failure To Exceed Max Number Of Users |
| 197 | [Documentation] Verify failure attempting to exceed the max number of user accounts. |
| 198 | [Tags] Verify_Failure_To_Exceed_Max_Number_Of_Users |
| 199 | [Teardown] Run Keywords Test Teardown Execution AND Delete All Non Root IPMI User |
| 200 | |
| 201 | # Get existing user count. |
| 202 | ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/ |
| 203 | ${current_user_count}= Get From Dictionary ${resp.dict} Members@odata.count |
| 204 | |
| 205 | ${payload}= Create Dictionary Password=${valid_password} |
| 206 | ... RoleId=Administrator Enabled=${True} |
| 207 | |
| 208 | # Create users to reach maximum users count (i.e. 15 users). |
| 209 | FOR ${INDEX} IN RANGE ${current_user_count} ${max_num_users} |
| 210 | ${random_username}= Generate Random String 8 [LETTERS] |
| 211 | Set To Dictionary ${payload} UserName ${random_username} |
| 212 | Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload} |
| 213 | ... valid_status_codes=[${HTTP_CREATED}] |
| 214 | END |
| 215 | |
Ashwini Chandrappa | 6fac289 | 2021-12-13 07:03:35 -0600 | [diff] [blame] | 216 | # Verify error while creating 18th user. |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 217 | ${random_username}= Generate Random String 8 [LETTERS] |
| 218 | Set To Dictionary ${payload} UserName ${random_username} |
| 219 | Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload} |
| 220 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 221 | |
| 222 | |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 223 | Create IPMI User Without Any Privilege And Verify Via Redfish |
| 224 | [Documentation] Create user using IPMI without privilege and verify via redfish. |
| 225 | [Tags] Create_IPMI_User_Without_Any_Privilege_And_Verify_Via_Redfish |
| 226 | |
| 227 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 228 | ... ${valid_password} |
| 229 | |
| 230 | # Verify new user privilege level via Redfish. |
| 231 | ${privilege}= Redfish_Utils.Get Attribute |
| 232 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
| 233 | Valid Value privilege ['NoAccess'] |
| 234 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 235 | *** Keywords *** |
| 236 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 237 | IPMI Create Random User Plus Password And Privilege |
| 238 | [Documentation] Create random IPMI user with given password and privilege |
| 239 | ... level. |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 240 | [Arguments] ${password} ${privilege}=0 |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 241 | |
| 242 | # Description of argument(s): |
| 243 | # password Password to be assigned for the user. |
| 244 | # privilege Privilege level for the user (e.g. "1", "2", "3", etc.). |
| 245 | |
| 246 | # Create IPMI user. |
| 247 | ${random_username}= Generate Random String 8 [LETTERS] |
| 248 | Set Suite Variable ${random_username} |
| 249 | |
| 250 | ${random_userid}= Evaluate random.randint(2, 15) modules=random |
| 251 | IPMI Create User ${random_userid} ${random_username} |
| 252 | |
| 253 | # Set given password for newly created user. |
| 254 | Run IPMI Standard Command |
| 255 | ... user set password ${random_userid} ${password} |
| 256 | |
| 257 | # Enable IPMI user. |
| 258 | Run IPMI Standard Command user enable ${random_userid} |
| 259 | |
| 260 | # Set given privilege and enable IPMI messaging for newly created user. |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 261 | Run Keyword If '${privilege}' != '0' |
| 262 | ... Set Channel Access ${random_userid} ipmi=on privilege=${privilege} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 263 | |
| 264 | [Return] ${random_username} ${random_userid} |
| 265 | |
| 266 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 267 | Test Setup Execution |
| 268 | [Documentation] Do test case setup tasks. |
| 269 | |
| 270 | Redfish.Login |
| 271 | |
| 272 | |
| 273 | Test Teardown Execution |
| 274 | [Documentation] Do the post test teardown. |
| 275 | |
| 276 | FFDC On Test Case Fail |
| 277 | # Delete the test user. |
| 278 | Run Keyword And Ignore Error |
| 279 | ... Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} |
| 280 | |
| 281 | Redfish.Logout |