blob: 1c94f1ad3bedcf91d87580cb3a88baceab7a6f81 [file] [log] [blame]
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -06001*** Settings ***
2Documentation Test suite for OpenBMC IPMI user management.
3
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
ganesanb0ae36202022-02-17 12:14:37 +00006Resource ../lib/bmc_network_utils.robot
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -06007Library ../lib/ipmi_utils.py
Anusha Dathatridd8e7d82019-12-03 07:45:30 -06008Test Setup Printn
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -06009
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -050010Suite Setup Suite Setup Execution
Rahul Maheshwarif646baa2019-02-20 12:29:35 -060011Test Teardown Test Teardown Execution
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060012
Matt Fischer6fb70d92023-10-24 19:06:33 -060013Test Tags IPMI_User
George Keishing87dc4422023-10-20 12:56:30 +053014
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060015*** Variables ***
16
17${invalid_username} user%
18${invalid_password} abc123
chithragc0582f72021-12-08 10:34:23 -050019${new_username} newuser
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060020${root_userid} 1
21${operator_level_priv} 0x3
Rahul Maheshwaric05bf562019-03-01 04:02:53 -060022${user_priv} 2
23${operator_priv} 3
Rahul Maheshwarief0a7352019-02-20 11:07:48 -060024${admin_level_priv} 4
Rahul Maheshwaric19f8382019-02-20 08:19:22 -060025${valid_password} 0penBmc1
26${max_password_length} 20
Rahul Maheshwarief0a7352019-02-20 11:07:48 -060027${ipmi_setaccess_cmd} channel setaccess
Anusha Dathatridd8e7d82019-12-03 07:45:30 -060028&{password_values} 16=0penBmc10penBmc2 17=0penBmc10penBmc2B
29 ... 20=0penBmc10penBmc2Bmc3 21=0penBmc10penBmc2Bmc34
Anusha Dathatri466816f2020-01-30 05:12:36 -060030 ... 7=0penBmc 8=0penBmc0
Gene Ratzlaffa631d692022-05-05 14:40:03 -040031${expected_max_ids} 15
32${root_pattern} ^.*\\sroot\\s.*ADMINISTRATOR.*$
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060033
Ashwini Chandrappa5cefabf2021-08-30 23:48:14 -050034# User defined count.
35${USER_LOOP_COUNT} 20
36
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060037*** Test Cases ***
38
Rahul Maheshwariffc77352019-02-25 09:05:27 -060039Verify IPMI User Summary
40 [Documentation] Verify IPMI maximum supported IPMI user ID and
Gene Ratzlaffa631d692022-05-05 14:40:03 -040041 ... enabled user from user summary.
Rahul Maheshwariffc77352019-02-25 09:05:27 -060042 [Tags] Verify_IPMI_User_Summary
Gene Ratzlaffa631d692022-05-05 14:40:03 -040043 [Teardown] Run Keywords FFDC On Test Case Fail AND
44 ... Delete Created User ${random_userid}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060045
Gene Ratzlaffa631d692022-05-05 14:40:03 -040046 ${initial_user_count} ${maximum_ids}= Get Enabled User Count
47
Anusha Dathatridd8e7d82019-12-03 07:45:30 -060048 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +080049 Set Test Variable ${random_userid}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060050 Run IPMI Standard Command user enable ${random_userid}
51
Sridevi Ramesh99a77db2025-03-19 11:58:15 -050052 # Enable IPMI user and verify
53 Enable IPMI User And Verify ${random_userid}
54
Gene Ratzlaffa631d692022-05-05 14:40:03 -040055 # Verify number of currently enabled users.
56 ${current_user_count} ${maximum_ids}= Get Enabled User Count
57 ${calculated_count}= Evaluate ${initial_user_count} + 1
58 Should Be Equal As Integers ${current_user_count} ${calculated_count}
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -050059
Gene Ratzlaffa631d692022-05-05 14:40:03 -040060 # Verify maximum user count IPMI local user can have.
61 Should Be Equal As Integers ${maximum_ids} ${expected_max_ids}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060062
63
Tony Lee3d351ee2020-02-19 10:21:04 +080064Verify IPMI User List
65 [Documentation] Verify user list via IPMI.
66 [Tags] Verify_IPMI_User_List
67 [Teardown] Run Keywords FFDC On Test Case Fail AND
68 ... Delete Created User ${random_userid}
69
70 ${random_userid} ${random_username}= Create Random IPMI User
71 Set Test Variable ${random_userid}
72
73 Run IPMI Standard Command
74 ... user set password ${random_userid} ${valid_password}
75 Run IPMI Standard Command user enable ${random_userid}
76 # Delay added for IPMI user to get enabled.
77 Sleep 5s
78 # Set admin privilege and enable IPMI messaging for newly created user.
79 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
80
81 ${users_access}= Get User Access Ipmi ${CHANNEL_NUMBER}
82 Rprint Vars users_access
83
84 ${index}= Evaluate ${random_userid} - 1
85 # Verify the user access of created user.
86 Valid Value users_access[${index}]['id'] ['${random_userid}']
87 Valid Value users_access[${index}]['name'] ['${random_username}']
88 Valid Value users_access[${index}]['callin'] ['true']
89 Valid Value users_access[${index}]['link'] ['false']
90 Valid Value users_access[${index}]['auth'] ['true']
91 Valid Value users_access[${index}]['ipmi'] ['ADMINISTRATOR']
92
93
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060094Verify IPMI User Creation With Valid Name And ID
95 [Documentation] Create user via IPMI and verify.
George Keishingb98036a2022-01-31 12:39:47 -060096 [Tags] Verify_IPMI_User_Creation_With_Valid_Name_And_ID
Tony Leef9379e82020-01-08 18:20:38 +080097 [Teardown] Run Keywords FFDC On Test Case Fail AND
98 ... Delete Created User ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060099
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600100 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800101 Set Test Variable ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600102
103
104Verify IPMI User Creation With Invalid Name
105 [Documentation] Verify error while creating IPMI user with invalid
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400106 ... name (e.g. user name with special characters).
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600107 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name
108
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400109 ${random_userid}= Find Free User Id
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600110 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
111 ... user set name ${random_userid} ${invalid_username}
112 Should Contain ${msg} Invalid data
113
114
115Verify IPMI User Creation With Invalid ID
116 [Documentation] Verify error while creating IPMI user with invalid
117 ... ID(i.e. any number greater than 15 or 0).
118 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID
119
120 @{id_list}= Create List
121 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random
122 Append To List ${id_list} ${random_invalid_id}
123 Append To List ${id_list} 0
124
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500125 FOR ${id} IN @{id_list}
126 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
127 ... user set name ${id} newuser
Tony Leec8ed7532020-01-09 16:15:16 +0800128 Should Contain Any ${msg} User ID is limited to range Parameter out of range
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500129 END
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600130
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400131
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600132Verify Setting IPMI User With Invalid Password
Sridevi Ramesh99a77db2025-03-19 11:58:15 -0500133 [Documentation] Verify error while setting IPMI user with invalid password.
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600134 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password
Tony Leef9379e82020-01-08 18:20:38 +0800135 [Teardown] Run Keywords FFDC On Test Case Fail AND
136 ... Delete Created User ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600137
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600138 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800139 Set Test Variable ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600140
141 # Set invalid password for newly created user.
142 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
143 ... user set password ${random_userid} ${invalid_password}
144
Sushma M M97fccae2020-07-27 14:55:19 -0500145 # Delay added for user password to get set.
146 Sleep 5s
147
Anusha Dathatria54cddc2019-08-07 10:01:16 -0500148 Should Contain ${msg} Set User Password command failed
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600149
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400150
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600151Verify Setting IPMI Root User With New Name
Sridevi Ramesh99a77db2025-03-19 11:58:15 -0500152 [Documentation] Verify error while setting IPMI root user with new name.
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600153 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name
154
155 # Set invalid password for newly created user.
156 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
157 ... user set name ${root_userid} abcd
158
159 Should Contain ${msg} Set User Name command failed
160
161
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600162Verify IPMI User Password Via Test Command
163 [Documentation] Verify IPMI user password using test command.
164 [Tags] Verify_IPMI_User_Password_Via_Test_Command
Tony Leef9379e82020-01-08 18:20:38 +0800165 [Teardown] Run Keywords FFDC On Test Case Fail AND
166 ... Delete Created User ${random_userid}
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600167
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600168 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800169 Set Test Variable ${random_userid}
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600170
171 # Set valid password for newly created user.
172 Run IPMI Standard Command
173 ... user set password ${random_userid} ${valid_password}
174
175 # Verify newly set password using test command.
176 ${msg}= Run IPMI Standard Command
177 ... user test ${random_userid} ${max_password_length} ${valid_password}
178
179 Should Contain ${msg} Success
180
181
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600182Verify Setting Valid Password For IPMI User
183 [Documentation] Set valid password for IPMI user and verify.
184 [Tags] Verify_Setting_Valid_Password_For_IPMI_User
Tony Leef9379e82020-01-08 18:20:38 +0800185 [Teardown] Run Keywords FFDC On Test Case Fail AND
186 ... Delete Created User ${random_userid}
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600187
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600188 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800189 Set Test Variable ${random_userid}
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600190
191 # Set valid password for newly created user.
192 Run IPMI Standard Command
193 ... user set password ${random_userid} ${valid_password}
194
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600195 Run IPMI Standard Command user enable ${random_userid}
196
Rahul Maheshwari7d232ab2019-08-29 06:44:16 -0500197 # Delay added for IPMI user to get enable
198 Sleep 5s
199
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600200 # Set admin privilege and enable IPMI messaging for newly created user
201 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
202
203 Verify IPMI Username And Password ${random_username} ${valid_password}
204
205
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600206Verify IPMI User Creation With Same Name
207 [Documentation] Verify error while creating two IPMI user with same name.
208 [Tags] Verify_IPMI_User_Creation_With_Same_Name
Tony Leef9379e82020-01-08 18:20:38 +0800209 [Teardown] Run Keywords FFDC On Test Case Fail AND
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400210 ... Delete Created User ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600211
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400212 ${random_userid} ${random_username}= Create Random IPMI User
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600213
214 # Set same username for another IPMI user.
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400215 ${rand_userid_two}= Find Free User Id
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600216 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400217 ... user set name ${rand_userid_two} ${random_username}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600218 Should Contain ${msg} Invalid data field in request
219
220
221Verify Setting IPMI User With Null Password
222 [Documentation] Verify error while setting IPMI user with null
223 ... password.
224 [Tags] Verify_Setting_IPMI_User_With_Null_Password
Tony Leef9379e82020-01-08 18:20:38 +0800225 [Teardown] Run Keywords FFDC On Test Case Fail AND
226 ... Delete Created User ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600227
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600228 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800229 Set Test Variable ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600230
231 # Set null password for newly created user.
232 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
233 ... user set password ${random_userid} ""
234
235 Should Contain ${msg} Invalid data field in request
236
237
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600238Verify IPMI User Deletion
239 [Documentation] Delete user via IPMI and verify.
240 [Tags] Verify_IPMI_User_Deletion
Tony Leef9379e82020-01-08 18:20:38 +0800241 [Teardown] Run Keywords FFDC On Test Case Fail AND
242 ... Delete Created User ${random_userid}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600243
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600244 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800245 Set Test Variable ${random_userid}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600246 # Delete IPMI User and verify
247 Run IPMI Standard Command user set name ${random_userid} ""
Nagarjun B26499142023-02-16 15:20:14 +0530248 ${user_info}= Get User Info ${random_userid} ${CHANNEL_NUMBER}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600249 Should Be Equal ${user_info['user_name']} ${EMPTY}
250
251
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600252Test IPMI User Privilege Level
253 [Documentation] Verify IPMI user with user privilege can only run user level commands.
254 [Tags] Test_IPMI_User_Privilege_Level
255 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800256 [Teardown] Run Keywords FFDC On Test Case Fail AND
257 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600258
259 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
260 ${user_priv} Passed Failed Failed
261
262
263Test IPMI Operator Privilege Level
Sridevi Ramesh99a77db2025-03-19 11:58:15 -0500264 [Documentation] Verify IPMI user with operator privilege can only run user and
265 ... operator level commands.
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600266 [Tags] Test_IPMI_Operator_Privilege_Level
267 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800268 [Teardown] Run Keywords FFDC On Test Case Fail AND
269 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600270
271 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
272 ${operator_priv} Passed Passed Failed
273
274
275Test IPMI Administrator Privilege Level
276 [Documentation] Verify IPMI user with admin privilege can run all levels command.
277 [Tags] Test_IPMI_Administrator_Privilege_Level
278 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800279 [Teardown] Run Keywords FFDC On Test Case Fail AND
280 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600281
282 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
283 ${admin_level_priv} Passed Passed Passed
284
285
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600286Enable IPMI User And Verify
287 [Documentation] Enable IPMI user and verify that the user is able
288 ... to run IPMI command.
289 [Tags] Enable_IPMI_User_And_Verify
Tony Leef9379e82020-01-08 18:20:38 +0800290 [Teardown] Run Keywords FFDC On Test Case Fail AND
291 ... Delete Created User ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600292
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600293 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800294 Set Test Variable ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600295 Run IPMI Standard Command
296 ... user set password ${random_userid} ${valid_password}
297
298 # Set admin privilege and enable IPMI messaging for newly created user.
299 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
300
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600301 # Delay added for user privilege to get set.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500302 Sleep 5s
303
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600304 Enable IPMI User And Verify ${random_userid}
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400305 Wait And Confirm New Username And Password ${random_username} ${valid_password}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600306
307 # Verify that enabled IPMI user is able to run IPMI command.
308 Verify IPMI Username And Password ${random_username} ${valid_password}
309
310
311Disable IPMI User And Verify
312 [Documentation] Disable IPMI user and verify that that the user
313 ... is unable to run IPMI command.
314 [Tags] Disable_IPMI_User_And_Verify
Tony Leef9379e82020-01-08 18:20:38 +0800315 [Teardown] Run Keywords FFDC On Test Case Fail AND
316 ... Delete Created User ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600317
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600318 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800319 Set Test Variable ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600320 Run IPMI Standard Command
321 ... user set password ${random_userid} ${valid_password}
322
323 # Set admin privilege and enable IPMI messaging for newly created user.
324 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
325
326 # Disable IPMI user and verify.
327 Run IPMI Standard Command user disable ${random_userid}
Nagarjun B26499142023-02-16 15:20:14 +0530328 ${user_info}= Get User Info ${random_userid} ${CHANNEL_NUMBER}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600329 Should Be Equal ${user_info['enable_status']} disabled
330
331 # Verify that disabled IPMI user is unable to run IPMI command.
332 ${msg}= Run Keyword And Expect Error * Verify IPMI Username And Password
333 ... ${random_username} ${valid_password}
Rahul Maheshwaric3d1e962019-03-06 23:53:21 -0600334 Should Contain ${msg} Unable to establish IPMI
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600335
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600336
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600337Verify IPMI Root User Password Change
338 [Documentation] Change IPMI root user password and verify that
339 ... root user is able to run IPMI command.
340 [Tags] Verify_IPMI_Root_User_Password_Change
Ruud A. Haringa6622cb2023-11-16 12:04:59 -0500341 [Setup] Skip if len( '${OPENBMC_PASSWORD}' ) < 8
342 ... msg= Do not run this test if len( OPENBMC_PASSWORD ) < 8
343 # Reason: if OPENBMC_PASSWORD is not at least 8 characters,
344 # it cannot be restored in the Teardown step.
Tony Leef9379e82020-01-08 18:20:38 +0800345 [Teardown] Run Keywords FFDC On Test Case Fail AND
Ruud A. Haringa6622cb2023-11-16 12:04:59 -0500346 ... Run Keyword If "${TEST STATUS}" != "SKIP"
Tony Leef9379e82020-01-08 18:20:38 +0800347 ... Wait Until Keyword Succeeds 15 sec 5 sec
Ruud A. Haringa6622cb2023-11-16 12:04:59 -0500348 ... Restore Default Password For IPMI Root User
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600349
350 # Set new password for root user.
351 Run IPMI Standard Command
352 ... user set password ${root_userid} ${valid_password}
353
Sushma M M97fccae2020-07-27 14:55:19 -0500354 # Delay added for user password to get set.
355 Sleep 5s
356
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600357 # Verify that root user is able to run IPMI command using new password.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500358 Wait Until Keyword Succeeds 15 sec 5 sec Verify IPMI Username And Password
359 ... root ${valid_password}
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600360
361
ganesanb5e775732023-10-31 11:13:20 +0000362Verify Administrator And User Privilege For Different Channels
363 [Documentation] Set administrator and user privilege for different channels and verify.
364 [Tags] Verify_Administrator_And_User_Privilege_For_Different_Channels
ganesanb0ae36202022-02-17 12:14:37 +0000365 [Setup] Check Active Ethernet Channels
Tony Leef9379e82020-01-08 18:20:38 +0800366 [Teardown] Run Keywords FFDC On Test Case Fail AND
367 ... Delete Created User ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500368
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600369 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800370 Set Test Variable ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500371 Run IPMI Standard Command
372 ... user set password ${random_userid} ${valid_password}
373
374 # Set admin privilege for newly created user with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000375 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500376
ganesanb5e775732023-10-31 11:13:20 +0000377 # Set user privilege for newly created user with channel 2.
378 Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500379
Ruud A. Haring9e4481b2023-12-08 12:08:01 -0500380 # Delay added for user privileges to get set.
381 Sleep 5s
382
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600383 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500384
385 # Verify that user is able to run administrator level IPMI command with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000386 Verify IPMI Command ${random_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500387
388 # Verify that user is unable to run IPMI command with channel 2.
George Keishing6e641262022-05-05 10:46:22 -0500389 Run IPMI Standard Command
390 ... sel info ${secondary_channel_number} expected_rc=${1} U=${random_username} P=${valid_password}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500391
392
393Verify Operator And User Privilege For Different Channels
394 [Documentation] Set operator and user privilege for different channels and verify.
395 [Tags] Verify_Operator_And_User_Privilege_For_Different_Channels
ganesanb0ae36202022-02-17 12:14:37 +0000396 [Setup] Check Active Ethernet Channels
Tony Leef9379e82020-01-08 18:20:38 +0800397 [Teardown] Run Keywords FFDC On Test Case Fail AND
398 ... Delete Created User ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500399
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600400 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800401 Set Test Variable ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500402 Run IPMI Standard Command
403 ... user set password ${random_userid} ${valid_password}
404
405 # Set operator privilege for newly created user with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000406 Set Channel Access ${random_userid} ipmi=on privilege=${operator_priv} ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500407
408 # Set user privilege for newly created user with channel 2.
ganesanb0ae36202022-02-17 12:14:37 +0000409 Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500410
Ruud A. Haring9e4481b2023-12-08 12:08:01 -0500411 # Delay added for user privileges to get set.
412 Sleep 5s
413
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600414 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500415
416 # Verify that user is able to run operator level IPMI command with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000417 Verify IPMI Command ${random_username} ${valid_password} Operator ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500418
419 # Verify that user is able to run user level IPMI command with channel 2.
ganesanb0ae36202022-02-17 12:14:37 +0000420 Verify IPMI Command ${random_username} ${valid_password} User ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500421
422
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600423Verify Setting IPMI User With Max Password Length
424 [Documentation] Verify IPMI user creation with password length of 20 characters.
425 [Tags] Verify_Setting_IPMI_User_With_Max_Password_Length
426 [Template] Set User Password And Verify
427
428 # password_length password_option expected_status
429 20 20 ${True}
430
431
432Verify Setting IPMI User With Invalid Password Length
433 [Documentation] Verify that IPMI user cannot be set with 21 character password using 16 char
434 ... or 20 char password option.
435 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password_Length
436 [Template] Set User Password And Verify
437
438 # password_length password_option expected_status
439 21 16 ${False}
440 21 20 ${False}
441
442
443Verify Setting IPMI User With 16 Character Password
444 [Documentation] Verify that IPMI user can create a 16 character password using 16 char or 20
445 ... char password option.
446 [Tags] Verify_Setting_IPMI_User_With_16_Character_Password
447 [Template] Set User Password And Verify
448
449 # password_length password_option expected_status
450 16 16 ${True}
451 16 20 ${True}
452
453
454Verify Default Selection Of 16 Character Password For IPMI User
455 [Documentation] Verify that ipmitool by default opts for the 16 character option when given a
456 ... password whose length is in between 17 and 20.
457 [Tags] Verify_Default_Selection_Of_16_Character_Password_For_IPMI_User
458 [Template] Set User Password And Verify
459
460 # password_length password_option expected_status
461 17 16 ${True}
462 20 16 ${True}
463
464
Anusha Dathatri466816f2020-01-30 05:12:36 -0600465Verify Minimum Password Length For IPMI User
466 [Documentation] Verify minimum password length of 8 characters.
467 [Tags] Verify_Minimum_Password_Length_For_IPMI_User
468 [Template] Set User Password And Verify
469
470 # password_length password_option expected_status
471 7 16 ${False}
472 8 16 ${True}
473 7 20 ${False}
474 8 20 ${True}
475
476
Ashwini Chandrappa5cefabf2021-08-30 23:48:14 -0500477Verify Continuous IPMI Command Execution
478 [Documentation] Verify that continuous IPMI command execution runs fine.
479 [Tags] Verify_Continuous_IPMI_Command_Execution
480
481 FOR ${i} IN RANGE ${USER_LOOP_COUNT}
ishwaryamathim372cd862023-11-14 18:12:23 +0000482 Run IPMI Standard Command lan print ${CHANNEL_NUMBER}
Ashwini Chandrappa5cefabf2021-08-30 23:48:14 -0500483 Run IPMI Standard Command power status
484 Run IPMI Standard Command fru list
485 Run IPMI Standard Command sel list
486 END
487
488
chithragc0582f72021-12-08 10:34:23 -0500489Modify IPMI User
490 [Documentation] Verify modified IPMI user is communicating via IPMI.
491 [Tags] Modify_IPMI_User
492 [Teardown] Run Keywords FFDC On Test Case Fail AND
493 ... Delete Created User ${random_userid}
494
495 ${random_userid} ${random_username}= Create Random IPMI User
496 Set Test Variable ${random_userid}
497 Run IPMI Standard Command
498 ... user set password ${random_userid} ${valid_password}
499
500 # Set admin privilege and enable IPMI messaging for newly created user.
501 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
502
503 # Delay added for user privilege to get set.
504 Sleep 5s
505
506 Enable IPMI User And Verify ${random_userid}
507
508 # Verify that user is able to run administrator level IPMI command.
509 Verify IPMI Command ${random_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
510
511 # Set different username for same IPMI user.
512 Run IPMI Standard Command
513 ... user set name ${random_userid} ${new_username}
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400514 Wait And Confirm New Username And Password ${new_username} ${valid_password}
chithragc0582f72021-12-08 10:34:23 -0500515
516 # Verify that user is able to run administrator level IPMI command.
517 Verify IPMI Command ${new_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
518
519
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600520*** Keywords ***
521
Ruud A. Haringa6622cb2023-11-16 12:04:59 -0500522Restore Default Password For IPMI Root User
523 [Documentation] Restore default password for IPMI root user
524
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600525 ${result}= Run External IPMI Standard Command
526 ... user set password ${root_userid} ${OPENBMC_PASSWORD}
527 ... P=${valid_password}
528 Should Contain ${result} Set User Password command successful
529
530 # Verify that root user is able to run IPMI command using default password.
531 Verify IPMI Username And Password root ${OPENBMC_PASSWORD}
532
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600533
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600534Test IPMI User Privilege
535 [Documentation] Test IPMI user privilege by executing IPMI command with different privileges.
536 [Arguments] ${privilege_level} ${user_cmd_status} ${operator_cmd_status} ${admin_cmd_status}
537
538 # Description of argument(s):
539 # privilege_level Privilege level of IPMI user (e.g. 4, 3).
540 # user_cmd_status Expected status of IPMI command run with the "User"
541 # privilege (i.e. "Passed" or "Failed").
542 # operator_cmd_status Expected status of IPMI command run with the "Operator"
543 # privilege (i.e. "Passed" or "Failed").
544 # admin_cmd_status Expected status of IPMI command run with the "Administrator"
545 # privilege (i.e. "Passed" or "Failed").
546
547 # Create IPMI user and set valid password.
Ruud A. Haring9e4481b2023-12-08 12:08:01 -0500548 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800549 Set Test Variable ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600550 Run IPMI Standard Command
551 ... user set password ${random_userid} ${valid_password}
552
553 # Set privilege and enable IPMI messaging for newly created user.
554 Set Channel Access ${random_userid} ipmi=on privilege=${privilege_level}
555
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600556 # Delay added for user privilege to get set.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500557 Sleep 5s
558
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600559 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600560
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500561 Verify IPMI Command ${random_username} ${valid_password} User
562 ... expected_status=${user_cmd_status}
563 Verify IPMI Command ${random_username} ${valid_password} Operator
564 ... expected_status=${operator_cmd_status}
565 Verify IPMI Command ${random_username} ${valid_password} Administrator
566 ... expected_status=${admin_cmd_status}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600567
568
569Verify IPMI Command
570 [Documentation] Verify IPMI command execution with given username,
571 ... password, privilege and expected status.
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500572 [Arguments] ${username} ${password} ${privilege} ${channel}=${1} ${expected_status}=Passed
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600573 # Description of argument(s):
574 # username The user name (e.g. "root", "robert", etc.).
575 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600576 # privilege The session privilege for IPMI command (e.g. "User", "Operator", etc.).
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500577 # channel The user channel number (e.g. "1" or "2").
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600578 # expected_status Expected status of IPMI command run with the user
579 # of above password and privilege (i.e. "Passed" or "Failed").
580
581 ${expected_rc}= Set Variable If '${expected_status}' == 'Passed' ${0} ${1}
Rahul Maheshwariceb282e2019-09-16 00:11:41 -0500582 Wait Until Keyword Succeeds 15 sec 5 sec Run IPMI Standard Command
583 ... sel info ${channel} expected_rc=${expected_rc} U=${username} P=${password}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600584 ... L=${privilege}
585
586
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600587Set User Password And Verify
588 [Documentation] Create a user and set its password with given length and option.
589 [Arguments] ${password_length} ${password_option} ${expected_result}
Tony Leef9379e82020-01-08 18:20:38 +0800590 [Teardown] Run Keyword Delete Created User ${random_userid}
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600591 # Description of argument(s):
592 # password_length Length of password to be generated and used (e.g. "16").
593 # password_option Password length option to be given in IPMI command (e.g. "16", "20").
594 # expected_result Expected result for setting the user's password (e.g. "True", "False").
595
596 Rprint Vars password_length password_option expected_result
597 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800598 Set Test Variable ${random_userid}
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600599 ${password}= Get From Dictionary ${password_values} ${password_length}
600 Rprint Vars random_userid password
601
602 # Set password for newly created user.
603 ${status}= Run Keyword And Return Status Run IPMI Standard Command
604 ... user set password ${random_userid} ${password} ${password_option}
605 Rprint Vars status
606 Valid Value status [${expected_result}]
Anusha Dathatri7f810712020-01-07 04:13:16 -0600607 Return From Keyword If '${expected_result}' == '${False}'
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600608
609 # Set admin privilege and enable IPMI messaging for newly created user.
610 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
611
612 # Delay added for user privilege to get set.
613 Sleep 5s
614
615 Enable IPMI User And Verify ${random_userid}
616
617 # For password_option 16, passwords with length between 17 and 20 will be truncated.
618 # For all other cases, passwords will be retained as it is to verify.
619 ${truncated_password}= Set Variable ${password[:${password_option}]}
620 Rprint Vars truncated_password
621 ${status}= Run Keyword And Return Status Verify IPMI Username And Password ${random_username}
622 ... ${truncated_password}
623 Rprint Vars status
624 Valid Value status [${expected_result}]
625
626
Rahul Maheshwarif646baa2019-02-20 12:29:35 -0600627Test Teardown Execution
628 [Documentation] Do the test teardown execution.
629
630 FFDC On Test Case Fail
Tony Leef9379e82020-01-08 18:20:38 +0800631
632
ganesanb0ae36202022-02-17 12:14:37 +0000633Check Active Ethernet Channels
634 [Documentation] Check active ethernet channels and set suite variables.
635
636 ${channel_number_list}= Get Active Ethernet Channel List
637 ${channel_length}= Get Length ${channel_number_list}
638 Skip If '${channel_length}' == '1'
639 ... msg= Skips this test case as only one channel was in active.
640
641 FOR ${channel_num} IN @{channel_number_list}
642 ${secondary_channel_number}= Set Variable If ${channel_num} != ${CHANNEL_NUMBER} ${channel_num}
643 END
644
645 Set Suite Variable ${secondary_channel_number}
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -0500646
647
648Suite Setup Execution
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400649 [Documentation] Make sure the enabled user count is below maximum,
650 ... and prepares administrative user list suite variables.
651
652 Check Enabled User Count
George Keishingca9a7842022-07-07 03:44:44 -0500653 # Skip root user checking if user decides not to use root user as default.
654 Run Keyword If '${IPMI_USERNAME}' == 'root' Determine Root User Id
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400655
656
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400657Determine Root User Id
658 [Documentation] Determines the user ID of the root user.
659
660 ${resp}= Wait Until Keyword Succeeds 15 sec 1 sec Run IPMI Standard Command
ishwaryamathim372cd862023-11-14 18:12:23 +0000661 ... user list ${CHANNEL_NUMBER}
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400662 @{lines}= Split To Lines ${resp}
663
664 ${root_userid}= Set Variable ${-1}
665 ${line_count}= Get Length ${lines}
666 FOR ${id_index} IN RANGE 1 ${line_count}
667 ${line}= Get From List ${lines} ${id_index}
668 ${root_found}= Get Lines Matching Regexp ${line} ${root_pattern}
669 IF '${root_found}' != '${EMPTY}'
670 ${root_userid}= Set Variable ${id_index}
George Keishinge9e44c42022-05-26 08:41:39 -0500671 Exit For Loop
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400672 END
673 END
674 Set Suite Variable ${root_userid}
675
676 Log To Console The root user ID is ${root_userid}.
677 Run Keyword If ${root_userid} < ${1} Fail msg= Did not identify root user ID.
678
679
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400680Wait And Confirm New Username And Password
George Keishing5e9fbbf2022-04-29 03:48:14 -0500681 [Documentation] Wait in loop trying to to confirm Username And Password.
682 [Arguments] ${username} ${password}
683
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400684 # Description of argument(s):
685 # username The user name (e.g. "root", "robert", etc.).
686 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
687
George Keishing5e9fbbf2022-04-29 03:48:14 -0500688 # Give time for previous command to complete.
689 Sleep 5s
690
691 # Looping verify that root user is able to run IPMI command using new password.
692 Wait Until Keyword Succeeds 15 sec 5 sec Verify IPMI Username And Password
693 ... ${username} ${password}
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400694
695
696Get Enabled User Count
697 [Documentation] Return as integers: current number of enabled users and
698 ... Maximum number of Ids.
699
700 # Isolate 'Enabled User Count' value and convert to integer
701 ${resp}= Wait Until Keyword Succeeds 15 sec 1 sec Run IPMI Standard Command
702 ... user summary ${CHANNEL_NUMBER}
703 ${user_count_line}= Get Lines Containing String ${resp} Enabled User Count
704 ${count}= Fetch From Right ${user_count_line} \:
705 ${user_count}= Convert To Integer ${count}
706
707 # Isolate 'Maximum IDs' value and convert to integer
708 ${maximum_ids}= Get Lines Containing String ${resp} Maximum IDs
709 ${max_ids}= Fetch From Right ${maximum_ids} \:
710 ${int_maximum_ids_count}= Convert To Integer ${max_ids}
711
George Keishing409df052024-01-17 22:36:14 +0530712 RETURN ${user_count} ${int_maximum_ids_count}