blob: 32f1db30427ce69cc5eb7be9b520f166be78b60b [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
George Keishing87dc4422023-10-20 12:56:30 +053013Force Tags IPMI_User
14
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.*$
33${empty_name_pattern} ^User Name\\s.*\\s:\\s$
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060034
Ashwini Chandrappa5cefabf2021-08-30 23:48:14 -050035# User defined count.
36${USER_LOOP_COUNT} 20
37
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060038*** Test Cases ***
39
Rahul Maheshwariffc77352019-02-25 09:05:27 -060040Verify IPMI User Summary
41 [Documentation] Verify IPMI maximum supported IPMI user ID and
Gene Ratzlaffa631d692022-05-05 14:40:03 -040042 ... enabled user from user summary.
Rahul Maheshwariffc77352019-02-25 09:05:27 -060043 [Tags] Verify_IPMI_User_Summary
Gene Ratzlaffa631d692022-05-05 14:40:03 -040044 [Teardown] Run Keywords FFDC On Test Case Fail AND
45 ... Delete Created User ${random_userid}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060046
Gene Ratzlaffa631d692022-05-05 14:40:03 -040047 ${initial_user_count} ${maximum_ids}= Get Enabled User Count
48
Anusha Dathatridd8e7d82019-12-03 07:45:30 -060049 ${random_userid} ${random_username}= Create Random IPMI User
Gene Ratzlaffa631d692022-05-05 14:40:03 -040050 Wait And Confirm New User Entry ${random_username}
Tony Leef9379e82020-01-08 18:20:38 +080051 Set Test Variable ${random_userid}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060052 Run IPMI Standard Command user enable ${random_userid}
53
Gene Ratzlaffa631d692022-05-05 14:40:03 -040054 # Verify number of currently enabled users.
55 ${current_user_count} ${maximum_ids}= Get Enabled User Count
56 ${calculated_count}= Evaluate ${initial_user_count} + 1
57 Should Be Equal As Integers ${current_user_count} ${calculated_count}
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -050058
Gene Ratzlaffa631d692022-05-05 14:40:03 -040059 # Verify maximum user count IPMI local user can have.
60 Should Be Equal As Integers ${maximum_ids} ${expected_max_ids}
Rahul Maheshwariffc77352019-02-25 09:05:27 -060061
62
Tony Lee3d351ee2020-02-19 10:21:04 +080063Verify IPMI User List
64 [Documentation] Verify user list via IPMI.
65 [Tags] Verify_IPMI_User_List
66 [Teardown] Run Keywords FFDC On Test Case Fail AND
67 ... Delete Created User ${random_userid}
68
69 ${random_userid} ${random_username}= Create Random IPMI User
70 Set Test Variable ${random_userid}
71
72 Run IPMI Standard Command
73 ... user set password ${random_userid} ${valid_password}
74 Run IPMI Standard Command user enable ${random_userid}
75 # Delay added for IPMI user to get enabled.
76 Sleep 5s
77 # Set admin privilege and enable IPMI messaging for newly created user.
78 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
79
80 ${users_access}= Get User Access Ipmi ${CHANNEL_NUMBER}
81 Rprint Vars users_access
82
83 ${index}= Evaluate ${random_userid} - 1
84 # Verify the user access of created user.
85 Valid Value users_access[${index}]['id'] ['${random_userid}']
86 Valid Value users_access[${index}]['name'] ['${random_username}']
87 Valid Value users_access[${index}]['callin'] ['true']
88 Valid Value users_access[${index}]['link'] ['false']
89 Valid Value users_access[${index}]['auth'] ['true']
90 Valid Value users_access[${index}]['ipmi'] ['ADMINISTRATOR']
91
92
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060093Verify IPMI User Creation With Valid Name And ID
94 [Documentation] Create user via IPMI and verify.
George Keishingb98036a2022-01-31 12:39:47 -060095 [Tags] Verify_IPMI_User_Creation_With_Valid_Name_And_ID
Tony Leef9379e82020-01-08 18:20:38 +080096 [Teardown] Run Keywords FFDC On Test Case Fail AND
97 ... Delete Created User ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060098
Anusha Dathatridd8e7d82019-12-03 07:45:30 -060099 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800100 Set Test Variable ${random_userid}
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600101
102
103Verify IPMI User Creation With Invalid Name
104 [Documentation] Verify error while creating IPMI user with invalid
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400105 ... name (e.g. user name with special characters).
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600106 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name
107
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400108 ${random_userid}= Find Free User Id
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600109 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
110 ... user set name ${random_userid} ${invalid_username}
111 Should Contain ${msg} Invalid data
112
113
114Verify IPMI User Creation With Invalid ID
115 [Documentation] Verify error while creating IPMI user with invalid
116 ... ID(i.e. any number greater than 15 or 0).
117 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID
118
119 @{id_list}= Create List
120 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random
121 Append To List ${id_list} ${random_invalid_id}
122 Append To List ${id_list} 0
123
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500124 FOR ${id} IN @{id_list}
125 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
126 ... user set name ${id} newuser
Tony Leec8ed7532020-01-09 16:15:16 +0800127 Should Contain Any ${msg} User ID is limited to range Parameter out of range
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500128 END
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600129
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400130
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600131Verify Setting IPMI User With Invalid Password
132 [Documentation] Verify error while setting IPMI user with invalid
133 ... password.
134 [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
152 [Documentation] Verify error while setting IPMI root user with new
153 ... name.
154 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name
155
156 # Set invalid password for newly created user.
157 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
158 ... user set name ${root_userid} abcd
159
160 Should Contain ${msg} Set User Name command failed
161
162
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600163Verify IPMI User Password Via Test Command
164 [Documentation] Verify IPMI user password using test command.
165 [Tags] Verify_IPMI_User_Password_Via_Test_Command
Tony Leef9379e82020-01-08 18:20:38 +0800166 [Teardown] Run Keywords FFDC On Test Case Fail AND
167 ... Delete Created User ${random_userid}
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600168
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600169 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800170 Set Test Variable ${random_userid}
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600171
172 # Set valid password for newly created user.
173 Run IPMI Standard Command
174 ... user set password ${random_userid} ${valid_password}
175
176 # Verify newly set password using test command.
177 ${msg}= Run IPMI Standard Command
178 ... user test ${random_userid} ${max_password_length} ${valid_password}
179
180 Should Contain ${msg} Success
181
182
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600183Verify Setting Valid Password For IPMI User
184 [Documentation] Set valid password for IPMI user and verify.
185 [Tags] Verify_Setting_Valid_Password_For_IPMI_User
Tony Leef9379e82020-01-08 18:20:38 +0800186 [Teardown] Run Keywords FFDC On Test Case Fail AND
187 ... Delete Created User ${random_userid}
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600188
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600189 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800190 Set Test Variable ${random_userid}
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600191
192 # Set valid password for newly created user.
193 Run IPMI Standard Command
194 ... user set password ${random_userid} ${valid_password}
195
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600196 Run IPMI Standard Command user enable ${random_userid}
197
Rahul Maheshwari7d232ab2019-08-29 06:44:16 -0500198 # Delay added for IPMI user to get enable
199 Sleep 5s
200
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600201 # Set admin privilege and enable IPMI messaging for newly created user
202 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
203
204 Verify IPMI Username And Password ${random_username} ${valid_password}
205
206
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600207Verify IPMI User Creation With Same Name
208 [Documentation] Verify error while creating two IPMI user with same name.
209 [Tags] Verify_IPMI_User_Creation_With_Same_Name
Tony Leef9379e82020-01-08 18:20:38 +0800210 [Teardown] Run Keywords FFDC On Test Case Fail AND
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400211 ... Delete Created User ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600212
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400213 ${random_userid} ${random_username}= Create Random IPMI User
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600214
215 # Set same username for another IPMI user.
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400216 ${rand_userid_two}= Find Free User Id
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600217 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400218 ... user set name ${rand_userid_two} ${random_username}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600219 Should Contain ${msg} Invalid data field in request
220
221
222Verify Setting IPMI User With Null Password
223 [Documentation] Verify error while setting IPMI user with null
224 ... password.
225 [Tags] Verify_Setting_IPMI_User_With_Null_Password
Tony Leef9379e82020-01-08 18:20:38 +0800226 [Teardown] Run Keywords FFDC On Test Case Fail AND
227 ... Delete Created User ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600228
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600229 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800230 Set Test Variable ${random_userid}
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600231
232 # Set null password for newly created user.
233 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
234 ... user set password ${random_userid} ""
235
236 Should Contain ${msg} Invalid data field in request
237
238
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600239Verify IPMI User Deletion
240 [Documentation] Delete user via IPMI and verify.
241 [Tags] Verify_IPMI_User_Deletion
Tony Leef9379e82020-01-08 18:20:38 +0800242 [Teardown] Run Keywords FFDC On Test Case Fail AND
243 ... Delete Created User ${random_userid}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600244
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600245 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800246 Set Test Variable ${random_userid}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600247 # Delete IPMI User and verify
248 Run IPMI Standard Command user set name ${random_userid} ""
Nagarjun B26499142023-02-16 15:20:14 +0530249 ${user_info}= Get User Info ${random_userid} ${CHANNEL_NUMBER}
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600250 Should Be Equal ${user_info['user_name']} ${EMPTY}
251
252
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600253Test IPMI User Privilege Level
254 [Documentation] Verify IPMI user with user privilege can only run user level commands.
255 [Tags] Test_IPMI_User_Privilege_Level
256 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800257 [Teardown] Run Keywords FFDC On Test Case Fail AND
258 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600259
260 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
261 ${user_priv} Passed Failed Failed
262
263
264Test IPMI Operator Privilege Level
265 [Documentation] Verify IPMI user with operator privilege can only run user and operator levels commands.
266 ... level is set to operator.
267 [Tags] Test_IPMI_Operator_Privilege_Level
268 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800269 [Teardown] Run Keywords FFDC On Test Case Fail AND
270 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600271
272 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
273 ${operator_priv} Passed Passed Failed
274
275
276Test IPMI Administrator Privilege Level
277 [Documentation] Verify IPMI user with admin privilege can run all levels command.
278 [Tags] Test_IPMI_Administrator_Privilege_Level
279 [Template] Test IPMI User Privilege
Tony Leef9379e82020-01-08 18:20:38 +0800280 [Teardown] Run Keywords FFDC On Test Case Fail AND
281 ... Delete Created User ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600282
283 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status
284 ${admin_level_priv} Passed Passed Passed
285
286
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600287Enable IPMI User And Verify
288 [Documentation] Enable IPMI user and verify that the user is able
289 ... to run IPMI command.
290 [Tags] Enable_IPMI_User_And_Verify
Tony Leef9379e82020-01-08 18:20:38 +0800291 [Teardown] Run Keywords FFDC On Test Case Fail AND
292 ... Delete Created User ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600293
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600294 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800295 Set Test Variable ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600296 Run IPMI Standard Command
297 ... user set password ${random_userid} ${valid_password}
298
299 # Set admin privilege and enable IPMI messaging for newly created user.
300 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
301
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600302 # Delay added for user privilege to get set.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500303 Sleep 5s
304
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600305 Enable IPMI User And Verify ${random_userid}
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400306 Wait And Confirm New Username And Password ${random_username} ${valid_password}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600307
308 # Verify that enabled IPMI user is able to run IPMI command.
309 Verify IPMI Username And Password ${random_username} ${valid_password}
310
311
312Disable IPMI User And Verify
313 [Documentation] Disable IPMI user and verify that that the user
314 ... is unable to run IPMI command.
315 [Tags] Disable_IPMI_User_And_Verify
Tony Leef9379e82020-01-08 18:20:38 +0800316 [Teardown] Run Keywords FFDC On Test Case Fail AND
317 ... Delete Created User ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600318
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600319 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800320 Set Test Variable ${random_userid}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600321 Run IPMI Standard Command
322 ... user set password ${random_userid} ${valid_password}
323
324 # Set admin privilege and enable IPMI messaging for newly created user.
325 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
326
327 # Disable IPMI user and verify.
328 Run IPMI Standard Command user disable ${random_userid}
Nagarjun B26499142023-02-16 15:20:14 +0530329 ${user_info}= Get User Info ${random_userid} ${CHANNEL_NUMBER}
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600330 Should Be Equal ${user_info['enable_status']} disabled
331
332 # Verify that disabled IPMI user is unable to run IPMI command.
333 ${msg}= Run Keyword And Expect Error * Verify IPMI Username And Password
334 ... ${random_username} ${valid_password}
Rahul Maheshwaric3d1e962019-03-06 23:53:21 -0600335 Should Contain ${msg} Unable to establish IPMI
Rahul Maheshwari0c71f5e2019-02-20 03:52:55 -0600336
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600337
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600338Verify IPMI Root User Password Change
339 [Documentation] Change IPMI root user password and verify that
340 ... root user is able to run IPMI command.
341 [Tags] Verify_IPMI_Root_User_Password_Change
Tony Leef9379e82020-01-08 18:20:38 +0800342 [Teardown] Run Keywords FFDC On Test Case Fail AND
343 ... Wait Until Keyword Succeeds 15 sec 5 sec
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600344 ... Set Default Password For IPMI Root User
345
Anusha Dathatri9f84bc82020-01-28 07:46:48 -0600346 # User input password should be minimum 8 characters long.
347 Valid Length OPENBMC_PASSWORD min_length=8
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600348 # Set new password for root user.
349 Run IPMI Standard Command
350 ... user set password ${root_userid} ${valid_password}
351
Sushma M M97fccae2020-07-27 14:55:19 -0500352 # Delay added for user password to get set.
353 Sleep 5s
354
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600355 # Verify that root user is able to run IPMI command using new password.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500356 Wait Until Keyword Succeeds 15 sec 5 sec Verify IPMI Username And Password
357 ... root ${valid_password}
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600358
359
ganesanb5e775732023-10-31 11:13:20 +0000360Verify Administrator And User Privilege For Different Channels
361 [Documentation] Set administrator and user privilege for different channels and verify.
362 [Tags] Verify_Administrator_And_User_Privilege_For_Different_Channels
ganesanb0ae36202022-02-17 12:14:37 +0000363 [Setup] Check Active Ethernet Channels
Tony Leef9379e82020-01-08 18:20:38 +0800364 [Teardown] Run Keywords FFDC On Test Case Fail AND
365 ... Delete Created User ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500366
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600367 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800368 Set Test Variable ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500369 Run IPMI Standard Command
370 ... user set password ${random_userid} ${valid_password}
371
372 # Set admin privilege for newly created user with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000373 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500374
ganesanb5e775732023-10-31 11:13:20 +0000375 # Set user privilege for newly created user with channel 2.
376 Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500377
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600378 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500379
380 # Verify that user is able to run administrator level IPMI command with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000381 Verify IPMI Command ${random_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500382
383 # Verify that user is unable to run IPMI command with channel 2.
George Keishing6e641262022-05-05 10:46:22 -0500384 Run IPMI Standard Command
385 ... sel info ${secondary_channel_number} expected_rc=${1} U=${random_username} P=${valid_password}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500386
387
388Verify Operator And User Privilege For Different Channels
389 [Documentation] Set operator and user privilege for different channels and verify.
390 [Tags] Verify_Operator_And_User_Privilege_For_Different_Channels
ganesanb0ae36202022-02-17 12:14:37 +0000391 [Setup] Check Active Ethernet Channels
Tony Leef9379e82020-01-08 18:20:38 +0800392 [Teardown] Run Keywords FFDC On Test Case Fail AND
393 ... Delete Created User ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500394
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600395 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800396 Set Test Variable ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500397 Run IPMI Standard Command
398 ... user set password ${random_userid} ${valid_password}
399
400 # Set operator privilege for newly created user with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000401 Set Channel Access ${random_userid} ipmi=on privilege=${operator_priv} ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500402
403 # Set user privilege for newly created user with channel 2.
ganesanb0ae36202022-02-17 12:14:37 +0000404 Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500405
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600406 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500407
408 # Verify that user is able to run operator level IPMI command with channel 1.
ganesanb0ae36202022-02-17 12:14:37 +0000409 Verify IPMI Command ${random_username} ${valid_password} Operator ${CHANNEL_NUMBER}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500410
411 # Verify that user is able to run user level IPMI command with channel 2.
ganesanb0ae36202022-02-17 12:14:37 +0000412 Verify IPMI Command ${random_username} ${valid_password} User ${secondary_channel_number}
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500413
414
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600415Verify Setting IPMI User With Max Password Length
416 [Documentation] Verify IPMI user creation with password length of 20 characters.
417 [Tags] Verify_Setting_IPMI_User_With_Max_Password_Length
418 [Template] Set User Password And Verify
419
420 # password_length password_option expected_status
421 20 20 ${True}
422
423
424Verify Setting IPMI User With Invalid Password Length
425 [Documentation] Verify that IPMI user cannot be set with 21 character password using 16 char
426 ... or 20 char password option.
427 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password_Length
428 [Template] Set User Password And Verify
429
430 # password_length password_option expected_status
431 21 16 ${False}
432 21 20 ${False}
433
434
435Verify Setting IPMI User With 16 Character Password
436 [Documentation] Verify that IPMI user can create a 16 character password using 16 char or 20
437 ... char password option.
438 [Tags] Verify_Setting_IPMI_User_With_16_Character_Password
439 [Template] Set User Password And Verify
440
441 # password_length password_option expected_status
442 16 16 ${True}
443 16 20 ${True}
444
445
446Verify Default Selection Of 16 Character Password For IPMI User
447 [Documentation] Verify that ipmitool by default opts for the 16 character option when given a
448 ... password whose length is in between 17 and 20.
449 [Tags] Verify_Default_Selection_Of_16_Character_Password_For_IPMI_User
450 [Template] Set User Password And Verify
451
452 # password_length password_option expected_status
453 17 16 ${True}
454 20 16 ${True}
455
456
Anusha Dathatri466816f2020-01-30 05:12:36 -0600457Verify Minimum Password Length For IPMI User
458 [Documentation] Verify minimum password length of 8 characters.
459 [Tags] Verify_Minimum_Password_Length_For_IPMI_User
460 [Template] Set User Password And Verify
461
462 # password_length password_option expected_status
463 7 16 ${False}
464 8 16 ${True}
465 7 20 ${False}
466 8 20 ${True}
467
468
Ashwini Chandrappa5cefabf2021-08-30 23:48:14 -0500469Verify Continuous IPMI Command Execution
470 [Documentation] Verify that continuous IPMI command execution runs fine.
471 [Tags] Verify_Continuous_IPMI_Command_Execution
472
473 FOR ${i} IN RANGE ${USER_LOOP_COUNT}
474 Run IPMI Standard Command lan print
475 Run IPMI Standard Command power status
476 Run IPMI Standard Command fru list
477 Run IPMI Standard Command sel list
478 END
479
480
chithragc0582f72021-12-08 10:34:23 -0500481Modify IPMI User
482 [Documentation] Verify modified IPMI user is communicating via IPMI.
483 [Tags] Modify_IPMI_User
484 [Teardown] Run Keywords FFDC On Test Case Fail AND
485 ... Delete Created User ${random_userid}
486
487 ${random_userid} ${random_username}= Create Random IPMI User
488 Set Test Variable ${random_userid}
489 Run IPMI Standard Command
490 ... user set password ${random_userid} ${valid_password}
491
492 # Set admin privilege and enable IPMI messaging for newly created user.
493 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
494
495 # Delay added for user privilege to get set.
496 Sleep 5s
497
498 Enable IPMI User And Verify ${random_userid}
499
500 # Verify that user is able to run administrator level IPMI command.
501 Verify IPMI Command ${random_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
502
503 # Set different username for same IPMI user.
504 Run IPMI Standard Command
505 ... user set name ${random_userid} ${new_username}
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400506 Wait And Confirm New Username And Password ${new_username} ${valid_password}
chithragc0582f72021-12-08 10:34:23 -0500507
508 # Verify that user is able to run administrator level IPMI command.
509 Verify IPMI Command ${new_username} ${valid_password} Administrator ${CHANNEL_NUMBER}
510
511
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600512*** Keywords ***
513
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600514Set Default Password For IPMI Root User
515 [Documentation] Set default password for IPMI root user (i.e. 0penBmc).
Rahul Maheshwaridd63c742019-02-27 23:03:54 -0600516 # Set default password for root user.
517 ${result}= Run External IPMI Standard Command
518 ... user set password ${root_userid} ${OPENBMC_PASSWORD}
519 ... P=${valid_password}
520 Should Contain ${result} Set User Password command successful
521
522 # Verify that root user is able to run IPMI command using default password.
523 Verify IPMI Username And Password root ${OPENBMC_PASSWORD}
524
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600525
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600526Test IPMI User Privilege
527 [Documentation] Test IPMI user privilege by executing IPMI command with different privileges.
528 [Arguments] ${privilege_level} ${user_cmd_status} ${operator_cmd_status} ${admin_cmd_status}
529
530 # Description of argument(s):
531 # privilege_level Privilege level of IPMI user (e.g. 4, 3).
532 # user_cmd_status Expected status of IPMI command run with the "User"
533 # privilege (i.e. "Passed" or "Failed").
534 # operator_cmd_status Expected status of IPMI command run with the "Operator"
535 # privilege (i.e. "Passed" or "Failed").
536 # admin_cmd_status Expected status of IPMI command run with the "Administrator"
537 # privilege (i.e. "Passed" or "Failed").
538
539 # Create IPMI user and set valid password.
540 ${random_username}= Generate Random String 8 [LETTERS]
541 ${random_userid}= Evaluate random.randint(2, 15) modules=random
542 IPMI Create User ${random_userid} ${random_username}
Tony Leef9379e82020-01-08 18:20:38 +0800543 Set Test Variable ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600544 Run IPMI Standard Command
545 ... user set password ${random_userid} ${valid_password}
546
547 # Set privilege and enable IPMI messaging for newly created user.
548 Set Channel Access ${random_userid} ipmi=on privilege=${privilege_level}
549
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600550 # Delay added for user privilege to get set.
Rahul Maheshwari62c8aea2019-09-27 05:23:12 -0500551 Sleep 5s
552
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600553 Enable IPMI User And Verify ${random_userid}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600554
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500555 Verify IPMI Command ${random_username} ${valid_password} User
556 ... expected_status=${user_cmd_status}
557 Verify IPMI Command ${random_username} ${valid_password} Operator
558 ... expected_status=${operator_cmd_status}
559 Verify IPMI Command ${random_username} ${valid_password} Administrator
560 ... expected_status=${admin_cmd_status}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600561
562
563Verify IPMI Command
564 [Documentation] Verify IPMI command execution with given username,
565 ... password, privilege and expected status.
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500566 [Arguments] ${username} ${password} ${privilege} ${channel}=${1} ${expected_status}=Passed
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600567 # Description of argument(s):
568 # username The user name (e.g. "root", "robert", etc.).
569 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600570 # privilege The session privilege for IPMI command (e.g. "User", "Operator", etc.).
Rahul Maheshwari8e175622019-05-20 05:30:32 -0500571 # channel The user channel number (e.g. "1" or "2").
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600572 # expected_status Expected status of IPMI command run with the user
573 # of above password and privilege (i.e. "Passed" or "Failed").
574
575 ${expected_rc}= Set Variable If '${expected_status}' == 'Passed' ${0} ${1}
Rahul Maheshwariceb282e2019-09-16 00:11:41 -0500576 Wait Until Keyword Succeeds 15 sec 5 sec Run IPMI Standard Command
577 ... sel info ${channel} expected_rc=${expected_rc} U=${username} P=${password}
Rahul Maheshwaric05bf562019-03-01 04:02:53 -0600578 ... L=${privilege}
579
580
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600581Set User Password And Verify
582 [Documentation] Create a user and set its password with given length and option.
583 [Arguments] ${password_length} ${password_option} ${expected_result}
Tony Leef9379e82020-01-08 18:20:38 +0800584 [Teardown] Run Keyword Delete Created User ${random_userid}
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600585 # Description of argument(s):
586 # password_length Length of password to be generated and used (e.g. "16").
587 # password_option Password length option to be given in IPMI command (e.g. "16", "20").
588 # expected_result Expected result for setting the user's password (e.g. "True", "False").
589
590 Rprint Vars password_length password_option expected_result
591 ${random_userid} ${random_username}= Create Random IPMI User
Tony Leef9379e82020-01-08 18:20:38 +0800592 Set Test Variable ${random_userid}
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600593 ${password}= Get From Dictionary ${password_values} ${password_length}
594 Rprint Vars random_userid password
595
596 # Set password for newly created user.
597 ${status}= Run Keyword And Return Status Run IPMI Standard Command
598 ... user set password ${random_userid} ${password} ${password_option}
599 Rprint Vars status
600 Valid Value status [${expected_result}]
Anusha Dathatri7f810712020-01-07 04:13:16 -0600601 Return From Keyword If '${expected_result}' == '${False}'
Anusha Dathatridd8e7d82019-12-03 07:45:30 -0600602
603 # Set admin privilege and enable IPMI messaging for newly created user.
604 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
605
606 # Delay added for user privilege to get set.
607 Sleep 5s
608
609 Enable IPMI User And Verify ${random_userid}
610
611 # For password_option 16, passwords with length between 17 and 20 will be truncated.
612 # For all other cases, passwords will be retained as it is to verify.
613 ${truncated_password}= Set Variable ${password[:${password_option}]}
614 Rprint Vars truncated_password
615 ${status}= Run Keyword And Return Status Verify IPMI Username And Password ${random_username}
616 ... ${truncated_password}
617 Rprint Vars status
618 Valid Value status [${expected_result}]
619
620
Rahul Maheshwarif646baa2019-02-20 12:29:35 -0600621Test Teardown Execution
622 [Documentation] Do the test teardown execution.
623
624 FFDC On Test Case Fail
Tony Leef9379e82020-01-08 18:20:38 +0800625
626
ganesanb0ae36202022-02-17 12:14:37 +0000627Check Active Ethernet Channels
628 [Documentation] Check active ethernet channels and set suite variables.
629
630 ${channel_number_list}= Get Active Ethernet Channel List
631 ${channel_length}= Get Length ${channel_number_list}
632 Skip If '${channel_length}' == '1'
633 ... msg= Skips this test case as only one channel was in active.
634
635 FOR ${channel_num} IN @{channel_number_list}
636 ${secondary_channel_number}= Set Variable If ${channel_num} != ${CHANNEL_NUMBER} ${channel_num}
637 END
638
639 Set Suite Variable ${secondary_channel_number}
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -0500640
641
642Suite Setup Execution
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400643 [Documentation] Make sure the enabled user count is below maximum,
644 ... and prepares administrative user list suite variables.
645
646 Check Enabled User Count
George Keishingca9a7842022-07-07 03:44:44 -0500647 # Skip root user checking if user decides not to use root user as default.
648 Run Keyword If '${IPMI_USERNAME}' == 'root' Determine Root User Id
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400649
650
651Check Enabled User Count
652 [Documentation] Ensure that there are available user IDs.
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -0500653
654 # Check for the enabled user count
655 ${resp}= Run IPMI Standard Command user summary ${CHANNEL_NUMBER}
656 ${enabled_user_count}=
657 ... Get Lines Containing String ${resp} Enabled User Count
658
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400659 Should not contain ${enabled_user_count} ${expected_max_ids}
Ashwini Chandrappa12be4b42022-03-15 23:02:07 -0500660 ... msg=IPMI have reached maximum user count
George Keishing5e9fbbf2022-04-29 03:48:14 -0500661
662
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400663Determine Root User Id
664 [Documentation] Determines the user ID of the root user.
665
666 ${resp}= Wait Until Keyword Succeeds 15 sec 1 sec Run IPMI Standard Command
667 ... user list
668 @{lines}= Split To Lines ${resp}
669
670 ${root_userid}= Set Variable ${-1}
671 ${line_count}= Get Length ${lines}
672 FOR ${id_index} IN RANGE 1 ${line_count}
673 ${line}= Get From List ${lines} ${id_index}
674 ${root_found}= Get Lines Matching Regexp ${line} ${root_pattern}
675 IF '${root_found}' != '${EMPTY}'
676 ${root_userid}= Set Variable ${id_index}
George Keishinge9e44c42022-05-26 08:41:39 -0500677 Exit For Loop
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400678 END
679 END
680 Set Suite Variable ${root_userid}
681
682 Log To Console The root user ID is ${root_userid}.
683 Run Keyword If ${root_userid} < ${1} Fail msg= Did not identify root user ID.
684
685
Gene Ratzlaff3a3d5d52022-05-05 08:30:52 -0400686Wait And Confirm New Username And Password
George Keishing5e9fbbf2022-04-29 03:48:14 -0500687 [Documentation] Wait in loop trying to to confirm Username And Password.
688 [Arguments] ${username} ${password}
689
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400690 # Description of argument(s):
691 # username The user name (e.g. "root", "robert", etc.).
692 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
693
George Keishing5e9fbbf2022-04-29 03:48:14 -0500694 # Give time for previous command to complete.
695 Sleep 5s
696
697 # Looping verify that root user is able to run IPMI command using new password.
698 Wait Until Keyword Succeeds 15 sec 5 sec Verify IPMI Username And Password
699 ... ${username} ${password}
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400700
701
702Get Enabled User Count
703 [Documentation] Return as integers: current number of enabled users and
704 ... Maximum number of Ids.
705
706 # Isolate 'Enabled User Count' value and convert to integer
707 ${resp}= Wait Until Keyword Succeeds 15 sec 1 sec Run IPMI Standard Command
708 ... user summary ${CHANNEL_NUMBER}
709 ${user_count_line}= Get Lines Containing String ${resp} Enabled User Count
710 ${count}= Fetch From Right ${user_count_line} \:
711 ${user_count}= Convert To Integer ${count}
712
713 # Isolate 'Maximum IDs' value and convert to integer
714 ${maximum_ids}= Get Lines Containing String ${resp} Maximum IDs
715 ${max_ids}= Fetch From Right ${maximum_ids} \:
716 ${int_maximum_ids_count}= Convert To Integer ${max_ids}
717
718 [Return] ${user_count} ${int_maximum_ids_count}
719
720
721Wait And Confirm New User Entry
722 [Documentation] Wait in loop until new user appears with given username.
723 [Arguments] ${username}
724
725 # Description of argument(s):
726 # username The user name (e.g. "root", "robert", etc.).
727
728 Wait Until Keyword Succeeds 45 sec 1 sec Verify IPMI Username Visible
729 ... ${username}
730
731
732Verify IPMI Username Visible
733 [Documentation] Confirm that username is present in user list.
734 [Arguments] ${username}
735
736 # Description of argument(s):
737 # username The user name (e.g. "root", "robert", etc.).
738
739 ${resp}= Run IPMI Standard Command user list
740 Should Contain ${resp} ${username}
741
742
743Find Free User Id
744 [Documentation] Find a user ID that is not being used.
745
746 Check Enabled User Count
747 FOR ${num} IN RANGE 300
748 ${random_userid}= Evaluate random.randint(1, ${expected_max_ids}) modules=random
Nagarjun B26499142023-02-16 15:20:14 +0530749 ${access}= Run IPMI Standard Command channel getaccess ${CHANNEL_NUMBER} ${random_userid}
Gene Ratzlaffa631d692022-05-05 14:40:03 -0400750
751 ${name_line}= Get Lines Containing String ${access} User Name
752 Log To Console For ID ${random_userid}: ${name_line}
753 ${is_empty}= Run Keyword And Return Status
754 ... Should Match Regexp ${name_line} ${empty_name_pattern}
755
756 Exit For Loop If ${is_empty} == ${True}
757 END
George Keishingca9a7842022-07-07 03:44:44 -0500758 [Return] ${random_userid}