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 |
Rahul Maheshwari | 7b7ba22 | 2022-08-21 23:29:43 -0500 | [diff] [blame] | 20 | ${readonly_level_priv} 2 |
George Keishing | dc7d689 | 2022-07-07 14:28:32 -0500 | [diff] [blame] | 21 | ${ipmi_max_num_users} ${15} |
ganesanb | 4510229 | 2023-03-28 11:13:29 +0000 | [diff] [blame] | 22 | ${max_num_users} ${15} |
Gene Ratzlaff | d4cdc11 | 2022-05-06 13:17:35 -0400 | [diff] [blame] | 23 | ${empty_name_pattern} ^User Name\\s.*\\s:\\s$ |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 24 | |
| 25 | ** Test Cases ** |
| 26 | |
| 27 | Create Admin Redfish User And Verify Login Via IPMI |
| 28 | [Documentation] Create user using redfish and verify via IPMI. |
| 29 | [Tags] Create_Admin_Redfish_User_And_Verify_Login_Via_IPMI |
| 30 | |
| 31 | ${random_username}= Generate Random String 8 [LETTERS] |
| 32 | Set Test Variable ${random_username} |
| 33 | |
| 34 | ${payload}= Create Dictionary |
| 35 | ... UserName=${random_username} Password=${valid_password} |
| 36 | ... RoleId=Administrator Enabled=${True} |
| 37 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 38 | ... valid_status_codes=[${HTTP_CREATED}] |
| 39 | |
Sushma M M | 97fccae | 2020-07-27 14:55:19 -0500 | [diff] [blame] | 40 | # Delay added for created new user password to get set. |
| 41 | Sleep 5s |
| 42 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 43 | Verify IPMI Username And Password ${random_username} ${valid_password} |
| 44 | |
| 45 | |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 46 | Update User Password Via Redfish And Verify Using IPMI |
| 47 | [Documentation] Update user password via Redfish and verify using IPMI. |
| 48 | [Tags] Update_User_Password_Via_Redfish_And_Verify_Using_IPMI |
| 49 | |
| 50 | # Create user using Redfish. |
| 51 | ${random_username}= Generate Random String 8 [LETTERS] |
| 52 | Set Test Variable ${random_username} |
| 53 | |
| 54 | ${payload}= Create Dictionary |
| 55 | ... UserName=${random_username} Password=${valid_password} |
| 56 | ... RoleId=Administrator Enabled=${True} |
| 57 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 58 | ... valid_status_codes=[${HTTP_CREATED}] |
| 59 | |
| 60 | # Update user password using Redfish. |
| 61 | ${payload}= Create Dictionary Password=${valid_password2} |
| 62 | Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload} |
| 63 | |
| 64 | # Verify that IPMI command works with new password and fails with older password. |
| 65 | Verify IPMI Username And Password ${random_username} ${valid_password2} |
| 66 | |
Anusha Dathatri | 652fc74 | 2020-02-05 05:14:21 -0600 | [diff] [blame] | 67 | Run Keyword And Expect Error *Error: Unable to establish IPMI* |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 68 | ... Verify IPMI Username And Password ${random_username} ${valid_password} |
| 69 | |
| 70 | |
Rahul Maheshwari | ff63ac0 | 2019-03-29 10:25:21 -0500 | [diff] [blame] | 71 | Update User Privilege Via Redfish And Verify Using IPMI |
| 72 | [Documentation] Update user privilege via Redfish and verify using IPMI. |
| 73 | [Tags] Update_User_Privilege_Via_Redfish_And_Verify_Using_IPMI |
| 74 | |
| 75 | # Create user using Redfish with admin privilege. |
| 76 | ${random_username}= Generate Random String 8 [LETTERS] |
| 77 | Set Test Variable ${random_username} |
| 78 | |
| 79 | ${payload}= Create Dictionary |
| 80 | ... UserName=${random_username} Password=${valid_password} |
| 81 | ... RoleId=Administrator Enabled=${True} |
| 82 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 83 | ... valid_status_codes=[${HTTP_CREATED}] |
| 84 | |
| 85 | # Update user privilege to operator using Redfish. |
| 86 | ${payload}= Create Dictionary RoleId=Operator |
| 87 | Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload} |
| 88 | |
| 89 | # Verify new user privilege level via IPMI. |
Tony Lee | c317c98 | 2020-05-20 15:46:35 +0800 | [diff] [blame] | 90 | ${resp}= Run IPMI Standard Command user list ${CHANNEL_NUMBER} |
Rahul Maheshwari | ff63ac0 | 2019-03-29 10:25:21 -0500 | [diff] [blame] | 91 | |
| 92 | # Example of response data: |
| 93 | # ID Name Callin Link Auth IPMI Msg Channel Priv Limit |
| 94 | # 1 root false true true ADMINISTRATOR |
| 95 | # 2 OAvCxjMv false true true OPERATOR |
| 96 | # 3 true false false NO ACCESS |
| 97 | # .. |
| 98 | # .. |
| 99 | # 15 true false false NO ACCESS |
| 100 | |
| 101 | ${user_info}= |
| 102 | ... Get Lines Containing String ${resp} ${random_username} |
| 103 | Should Contain ${user_info} OPERATOR |
| 104 | |
| 105 | |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 106 | Delete User Via Redfish And Verify Using IPMI |
| 107 | [Documentation] Delete user via redfish and verify using IPMI. |
| 108 | [Tags] Delete_User_Via_Redfish_And_Verify_Using_IPMI |
| 109 | |
| 110 | # Create user using Redfish. |
| 111 | ${random_username}= Generate Random String 8 [LETTERS] |
| 112 | Set Test Variable ${random_username} |
| 113 | |
| 114 | ${payload}= Create Dictionary |
| 115 | ... UserName=${random_username} Password=${valid_password} |
| 116 | ... RoleId=Administrator Enabled=${True} |
| 117 | Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} |
| 118 | ... valid_status_codes=[${HTTP_CREATED}] |
| 119 | |
| 120 | # Delete user using Redfish. |
| 121 | Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} |
| 122 | |
| 123 | # Verify that IPMI command fails with deleted user. |
Anusha Dathatri | 652fc74 | 2020-02-05 05:14:21 -0600 | [diff] [blame] | 124 | Run Keyword And Expect Error *Error: Unable to establish IPMI* |
Rahul Maheshwari | cf2336e | 2019-03-15 00:49:13 -0500 | [diff] [blame] | 125 | ... Verify IPMI Username And Password ${random_username} ${valid_password} |
| 126 | |
| 127 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 128 | Create IPMI User And Verify Login Via Redfish |
| 129 | [Documentation] Create user using IPMI and verify user login via Redfish. |
| 130 | [Tags] Create_IPMI_User_And_Verify_Login_Via_Redfish |
| 131 | |
| 132 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 133 | ... ${valid_password} ${admin_level_priv} |
| 134 | |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 135 | Redfish.Logout |
| 136 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 137 | # Verify user login using Redfish. |
| 138 | Redfish.Login ${username} ${valid_password} |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 139 | Redfish.Logout |
| 140 | |
| 141 | Redfish.Login |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 142 | |
| 143 | |
| 144 | Update User Password Via IPMI And Verify Using Redfish |
| 145 | [Documentation] Update user password using IPMI and verify user |
| 146 | ... login via Redfish. |
| 147 | [Tags] Update_User_Password_Via_IPMI_And_Verify_Using_Redfish |
| 148 | |
| 149 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 150 | ... ${valid_password} ${admin_level_priv} |
| 151 | |
| 152 | # Update user password using IPMI. |
| 153 | Run IPMI Standard Command |
| 154 | ... user set password ${userid} ${valid_password2} |
| 155 | |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 156 | Redfish.Logout |
| 157 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 158 | # Verify that user login works with new password using Redfish. |
| 159 | Redfish.Login ${username} ${valid_password2} |
Anusha Dathatri | 4d89465 | 2020-02-12 04:08:10 -0600 | [diff] [blame] | 160 | Redfish.Logout |
| 161 | |
| 162 | Redfish.Login |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 163 | |
| 164 | |
Rahul Maheshwari | 7b7ba22 | 2022-08-21 23:29:43 -0500 | [diff] [blame] | 165 | Update User Privilege To Operator Via IPMI And Verify Using Redfish |
| 166 | [Documentation] Update user privilege to operator via IPMI and verify using Redfish. |
| 167 | [Tags] Update_User_Privilege_To_Operator_Via_IPMI_And_Verify_Using_Redfish |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 168 | # Create user using IPMI with admin privilege. |
| 169 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 170 | ... ${valid_password} ${admin_level_priv} |
| 171 | |
| 172 | # Change user privilege to opetrator using IPMI. |
| 173 | Run IPMI Standard Command |
Tony Lee | 69ed33e | 2020-05-20 17:15:02 +0800 | [diff] [blame] | 174 | ... user priv ${userid} ${operator_level_priv} ${CHANNEL_NUMBER} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 175 | |
| 176 | # Verify new user privilege level via Redfish. |
| 177 | ${privilege}= Redfish_Utils.Get Attribute |
| 178 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
| 179 | Should Be Equal ${privilege} Operator |
| 180 | |
| 181 | |
Rahul Maheshwari | 7b7ba22 | 2022-08-21 23:29:43 -0500 | [diff] [blame] | 182 | Update User Privilege To Readonly Via IPMI And Verify Using Redfish |
| 183 | [Documentation] Update user privilege to readonly via IPMI and verify using Redfish. |
| 184 | [Tags] Update_User_Privilege_To_Readonly_Via_IPMI_And_Verify_Using_Redfish |
| 185 | |
| 186 | # Create user using IPMI with admin privilege. |
| 187 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 188 | ... ${valid_password} ${admin_level_priv} |
| 189 | |
| 190 | # Change user privilege to readonly using IPMI. |
| 191 | Run IPMI Standard Command |
| 192 | ... user priv ${userid} ${readonly_level_priv} ${CHANNEL_NUMBER} |
| 193 | |
| 194 | # Verify new user privilege level via Redfish. |
| 195 | ${privilege}= Redfish_Utils.Get Attribute |
| 196 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
| 197 | Should Be Equal ${privilege} ReadOnly |
| 198 | |
| 199 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 200 | Delete User Via IPMI And Verify Using Redfish |
| 201 | [Documentation] Delete user using IPMI and verify error while doing |
| 202 | ... user login with deleted user via Redfish. |
| 203 | [Tags] Delete_User_Via_IPMI_And_Verify_Using_Redfish |
| 204 | |
| 205 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 206 | ... ${valid_password} ${admin_level_priv} |
| 207 | |
| 208 | # Delete IPMI User. |
| 209 | Run IPMI Standard Command user set name ${userid} "" |
| 210 | |
| 211 | # Verify that Redfish login fails with deleted user. |
| 212 | Run Keyword And Expect Error *InvalidCredentialsError* |
| 213 | ... Redfish.Login ${username} ${valid_password} |
| 214 | |
| 215 | |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 216 | Verify Failure To Exceed Max Number Of Users |
| 217 | [Documentation] Verify failure attempting to exceed the max number of user accounts. |
| 218 | [Tags] Verify_Failure_To_Exceed_Max_Number_Of_Users |
nagarjunb | 132d29a | 2022-07-29 09:02:47 +0000 | [diff] [blame] | 219 | [Teardown] Run Keywords Test Teardown Execution |
| 220 | ... AND Delete Users Via Redfish ${username_list} |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 221 | |
| 222 | # Get existing user count. |
| 223 | ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/ |
| 224 | ${current_user_count}= Get From Dictionary ${resp.dict} Members@odata.count |
| 225 | |
| 226 | ${payload}= Create Dictionary Password=${valid_password} |
| 227 | ... RoleId=Administrator Enabled=${True} |
| 228 | |
Ashwini Chandrappa | dfd4801 | 2022-04-06 06:33:37 -0500 | [diff] [blame] | 229 | @{username_list}= Create List |
| 230 | |
ganesanb | 4510229 | 2023-03-28 11:13:29 +0000 | [diff] [blame] | 231 | # Create users to reach maximum users count (i.e. 15 users). |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 232 | FOR ${INDEX} IN RANGE ${current_user_count} ${max_num_users} |
| 233 | ${random_username}= Generate Random String 8 [LETTERS] |
| 234 | Set To Dictionary ${payload} UserName ${random_username} |
| 235 | Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload} |
| 236 | ... valid_status_codes=[${HTTP_CREATED}] |
Ashwini Chandrappa | dfd4801 | 2022-04-06 06:33:37 -0500 | [diff] [blame] | 237 | Append To List ${username_list} /redfish/v1/AccountService/Accounts/${random_username} |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 238 | END |
| 239 | |
Ashwini Chandrappa | dfd4801 | 2022-04-06 06:33:37 -0500 | [diff] [blame] | 240 | # Verify error while creating 16th user. |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 241 | ${random_username}= Generate Random String 8 [LETTERS] |
| 242 | Set To Dictionary ${payload} UserName ${random_username} |
| 243 | Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload} |
| 244 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 245 | |
| 246 | |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 247 | Create IPMI User Without Any Privilege And Verify Via Redfish |
| 248 | [Documentation] Create user using IPMI without privilege and verify via redfish. |
| 249 | [Tags] Create_IPMI_User_Without_Any_Privilege_And_Verify_Via_Redfish |
| 250 | |
| 251 | ${username} ${userid}= IPMI Create Random User Plus Password And Privilege |
| 252 | ... ${valid_password} |
| 253 | |
| 254 | # Verify new user privilege level via Redfish. |
| 255 | ${privilege}= Redfish_Utils.Get Attribute |
| 256 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
kothais | 42b2e30 | 2023-11-03 06:56:08 +0000 | [diff] [blame] | 257 | Valid Value privilege ['ReadOnly'] |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 258 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 259 | *** Keywords *** |
| 260 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 261 | IPMI Create Random User Plus Password And Privilege |
| 262 | [Documentation] Create random IPMI user with given password and privilege |
| 263 | ... level. |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 264 | [Arguments] ${password} ${privilege}=0 |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 265 | |
| 266 | # Description of argument(s): |
| 267 | # password Password to be assigned for the user. |
| 268 | # privilege Privilege level for the user (e.g. "1", "2", "3", etc.). |
| 269 | |
| 270 | # Create IPMI user. |
| 271 | ${random_username}= Generate Random String 8 [LETTERS] |
| 272 | Set Suite Variable ${random_username} |
| 273 | |
Gene Ratzlaff | d4cdc11 | 2022-05-06 13:17:35 -0400 | [diff] [blame] | 274 | ${random_userid}= Find Free User Id |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 275 | IPMI Create User ${random_userid} ${random_username} |
| 276 | |
| 277 | # Set given password for newly created user. |
| 278 | Run IPMI Standard Command |
| 279 | ... user set password ${random_userid} ${password} |
| 280 | |
| 281 | # Enable IPMI user. |
| 282 | Run IPMI Standard Command user enable ${random_userid} |
| 283 | |
| 284 | # Set given privilege and enable IPMI messaging for newly created user. |
Anusha Dathatri | 9ecaaf4 | 2020-01-20 04:50:13 -0600 | [diff] [blame] | 285 | Run Keyword If '${privilege}' != '0' |
| 286 | ... Set Channel Access ${random_userid} ipmi=on privilege=${privilege} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 287 | |
| 288 | [Return] ${random_username} ${random_userid} |
| 289 | |
| 290 | |
nagarjunb | 132d29a | 2022-07-29 09:02:47 +0000 | [diff] [blame] | 291 | Delete Users Via Redfish |
| 292 | [Documentation] Delete all the users via redfish from given list. |
| 293 | [Arguments] ${user_list} |
| 294 | |
| 295 | # Description of argument(s): |
| 296 | # user_list List of user which are to be deleted. |
| 297 | |
| 298 | Redfish.Login |
| 299 | |
| 300 | FOR ${user} IN @{user_list} |
| 301 | Redfish.Delete ${user} |
| 302 | END |
| 303 | |
| 304 | Redfish.Logout |
| 305 | |
| 306 | |
Rahul Maheshwari | 51dee26 | 2019-03-06 23:36:21 -0600 | [diff] [blame] | 307 | Test Setup Execution |
| 308 | [Documentation] Do test case setup tasks. |
| 309 | |
| 310 | Redfish.Login |
| 311 | |
| 312 | |
| 313 | Test Teardown Execution |
| 314 | [Documentation] Do the post test teardown. |
| 315 | |
| 316 | FFDC On Test Case Fail |
| 317 | # Delete the test user. |
| 318 | Run Keyword And Ignore Error |
| 319 | ... Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username} |
| 320 | |
| 321 | Redfish.Logout |
Gene Ratzlaff | d4cdc11 | 2022-05-06 13:17:35 -0400 | [diff] [blame] | 322 | |
| 323 | |
| 324 | Find Free User Id |
| 325 | [Documentation] Find a userid that is not being used. |
| 326 | FOR ${jj} IN RANGE 300 |
George Keishing | dc7d689 | 2022-07-07 14:28:32 -0500 | [diff] [blame] | 327 | # IPMI maximum users count (i.e. 15 users). |
| 328 | ${random_userid}= Evaluate random.randint(1, ${ipmi_max_num_users}) modules=random |
Nagarjun B | 2649914 | 2023-02-16 15:20:14 +0530 | [diff] [blame] | 329 | ${access}= Run IPMI Standard Command channel getaccess ${CHANNEL_NUMBER} ${random_userid} |
Gene Ratzlaff | d4cdc11 | 2022-05-06 13:17:35 -0400 | [diff] [blame] | 330 | |
| 331 | ${name_line}= Get Lines Containing String ${access} User Name |
| 332 | Log To Console For ID ${random_userid}: ${name_line} |
| 333 | ${is_empty}= Run Keyword And Return Status |
| 334 | ... Should Match Regexp ${name_line} ${empty_name_pattern} |
| 335 | |
| 336 | Exit For Loop If ${is_empty} == ${True} |
| 337 | END |
| 338 | Run Keyword If '${jj}' == '299' Fail msg=A free user ID could not be found. |
| 339 | [Return] ${random_userid} |