blob: 6839d30a2217168728bb4cd9e02644410310821d [file] [log] [blame]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -05001*** Settings ***
2Documentation Test root user expire password.
3
4Resource ../lib/resource.robot
shrsuman123a9d93412021-07-13 04:06:05 -05005Resource ../gui/lib/gui_resource.robot
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -05006Resource ../lib/ipmi_client.robot
shrsuman123a9d93412021-07-13 04:06:05 -05007Resource ../lib/bmc_redfish_utils.robot
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -05008Library ../lib/bmc_ssh_utils.py
9Library SSHLibrary
10
George Keishing4d4ef992021-01-28 09:56:53 -060011Test Setup Set Account Lockout Threshold
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -050012
Megha G Ne18cdb52023-10-11 04:45:32 -050013Force Tags BMC_Expire_Password
14
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050015*** Variables ***
Anvesh Kumar9f421212020-04-27 01:42:50 -050016
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050017# If user re-tries more than 5 time incorrectly, the user gets locked for 5 minutes.
18${default_lockout_duration} ${300}
Megha G Ne18cdb52023-10-11 04:45:32 -050019${admin_user} admin_user
20${default_adminuser_passwd} AdminUser1
21${admin_password} AdminUser2
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050022
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050023
24*** Test Cases ***
25
26Expire Root Password And Check IPMI Access Fails
27 [Documentation] Expire root user password and expect an error while access via IPMI.
28 [Tags] Expire_Root_Password_And_Check_IPMI_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050029 [Teardown] Test Teardown Execution
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050030
Megha G Ne18cdb52023-10-11 04:45:32 -050031 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050032
33 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v
34 Should Be Equal ${status} ${False}
35
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050036
37Expire Root Password And Check SSH Access Fails
38 [Documentation] Expire root user password and expect an error while access via SSH.
39 [Tags] Expire_Root_Password_And_Check_SSH_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050040 [Teardown] Test Teardown Execution
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050041
Megha G Ne18cdb52023-10-11 04:45:32 -050042 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050043
44 ${status}= Run Keyword And Return Status
45 ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
46 Should Be Equal ${status} ${False}
47
48
Anves Kumar rayankula67921142020-05-14 04:03:24 -050049Expire And Change Root User Password And Access Via SSH
50 [Documentation] Expire and change root user password and access via SSH.
George Keishingb98036a2022-01-31 12:39:47 -060051 [Tags] Expire_And_Change_Root_User_Password_And_Access_Via_SSH
Anves Kumar rayankula67921142020-05-14 04:03:24 -050052 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
53 ... Restore Default Password For Root User AND FFDC On Test Case Fail
54
Megha G Ne18cdb52023-10-11 04:45:32 -050055 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula67921142020-05-14 04:03:24 -050056
Anvesh Kumar9f421212020-04-27 01:42:50 -050057 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050058 # Change to a valid password.
59 ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
60 ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}]
61
62 # Verify login with the new password through SSH.
63 Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123
64
65
66Expire Root Password And Update Bad Password Length Via Redfish
67 [Documentation] Expire root password and update bad password via Redfish and expect an error.
68 [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish
69 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050070 ... Restore Default Password For Root User AND FFDC On Test Case Fail
Anves Kumar rayankula67921142020-05-14 04:03:24 -050071
Megha G Ne18cdb52023-10-11 04:45:32 -050072 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula67921142020-05-14 04:03:24 -050073
Anvesh Kumar9f421212020-04-27 01:42:50 -050074 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050075 ${status}= Run Keyword And Return Status
76 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
77 ... body={'Password': '0penBmc0penBmc0penBmc'}
78 Should Be Equal ${status} ${False}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050079
Anvesh Kumar9f421212020-04-27 01:42:50 -050080
81Expire And Change Root User Password Via Redfish And Verify
82 [Documentation] Expire and change root user password via Redfish and verify.
83 [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify
84 [Teardown] Run Keywords FFDC On Test Case Fail AND
85 ... Wait Until Keyword Succeeds 1 min 10 sec
86 ... Restore Default Password For Root User
87
Megha G Ne18cdb52023-10-11 04:45:32 -050088 Expire Password ${OPENBMC_USERNAME}
Anvesh Kumar9f421212020-04-27 01:42:50 -050089
shrsuman123a9d93412021-07-13 04:06:05 -050090 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anvesh Kumar9f421212020-04-27 01:42:50 -050091 # Change to a valid password.
92 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
93 ... body={'Password': '0penBmc123'}
94 Redfish.Logout
95
96 # Verify login with the new password.
97 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
98
99
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500100Verify Error While Creating User With Expired Password
101 [Documentation] Expire root password and expect an error while creating new user.
102 [Tags] Verify_Error_While_Creating_User_With_Expired_Password
103 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
104 ... Restore Default Password For Root User AND FFDC On Test Case Fail
105
Megha G Ne18cdb52023-10-11 04:45:32 -0500106 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500107
shrsuman123a9d93412021-07-13 04:06:05 -0500108 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500109 Redfish.Login
110 ${payload}= Create Dictionary
111 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
112 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
113 ... valid_status_codes=[${HTTP_FORBIDDEN}]
114
115
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500116Expire And Change Root Password Via GUI
117 [Documentation] Expire and change root password via GUI.
118 [Tags] Expire_And_Change_Root_Password_Via_GUI
shrsuman123a9d93412021-07-13 04:06:05 -0500119 [Setup] Launch Browser And Login GUI
120 [Teardown] Run Keywords Logout GUI AND Close Browser
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500121 ... AND Restore Default Password For Root User AND FFDC On Test Case Fail
122
Megha G Ne18cdb52023-10-11 04:45:32 -0500123 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500124
shrsuman123a9d93412021-07-13 04:06:05 -0500125 Wait Until Page Contains Element ${xpath_root_button_menu}
126 Click Element ${xpath_root_button_menu}
127 Click Element ${xpath_profile_settings}
128 Wait Until Page Contains Change password
129
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500130 # Change valid password.
131 Input Text ${xpath_input_password} 0penBmc123
132 Input Text ${xpath_input_confirm_password} 0penBmc123
shrsuman123a9d93412021-07-13 04:06:05 -0500133 Click Button ${xpath_profile_save_button}
134 Wait Until Page Contains Successfully saved account settings.
135 Wait Until Page Does Not Contain Successfully saved account settings. timeout=20
136 Logout GUI
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500137
138 # Verify valid password.
shrsuman123a9d93412021-07-13 04:06:05 -0500139 Login GUI ${OPENBMC_USERNAME} 0penBmc123
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500140 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
141
142
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500143Verify Maximum Failed Attempts And Check Root User Account Locked
144 [Documentation] Verify maximum failed attempts and locks out root user account.
145 [Tags] Verify_Maximum_Failed_Attempts_And_Check_Root_User_Account_Locked
George Keishing4d4ef992021-01-28 09:56:53 -0600146 [Setup] Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500147
148 # Make maximum failed login attempts.
149 Repeat Keyword ${5} times
150 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login root 0penBmc123
151
152 # Verify that legitimate login fails due to lockout.
153 Run Keyword And Expect Error InvalidCredentialsError*
154 ... Redfish.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
155
156 # Wait for lockout duration to expire and then verify that login works.
157 Sleep ${default_lockout_duration}s
158 Redfish.Login
159 Redfish.Logout
160
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500161Verify New Password Persistency After BMC Reboot
162 [Documentation] Verify new password persistency after BMC reboot.
163 [Tags] Verify_New_Password_Persistency_After_BMC_Reboot
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500164 [Teardown] Test Teardown Execution
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500165
166 Redfish.Login
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500167
168 # Make sure the user account in question does not already exist.
169 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
170 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
171
172 # Create specified user.
173 ${payload}= Create Dictionary
174 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
175 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
176 ... valid_status_codes=[${HTTP_CREATED}]
177 Redfish.Logout
178
179 Redfish.Login admin_user TestPwd123
180
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500181 # Change to a valid password.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500182 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500183 ... body={'Password': '0penBmc123'}
184
185 # Reboot BMC and verify persistency.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500186 Redfish OBMC Reboot (off)
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500187
188 # verify new password
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500189 Redfish.Login admin_user 0penBmc123
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500190
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500191
Megha G Ne18cdb52023-10-11 04:45:32 -0500192Verify Expire And Change Admin User Password Via GUI
193 [Documentation] Force expire admin password and update admin password via GUI.
194 [Tags] Verify_Expire_And_Change_Admin_User_Password_Via_GUI
195 [Setup] Run Keywords Launch Browser And Login GUI AND
196 ... Redfish Create User ${admin_user} ${default_adminuser_passwd} Administrator ${True}
197 [Teardown] Run Keywords Logout GUI AND Close Browser
198
199 Expire Password ${admin_user}
200
201 Logout GUI
202
203 # Verify that admin user should not be able to login with expired password.
204 Login GUI ${admin_user} ${default_adminuser_passwd}
205
206 # Verify error message to update the password.
207 Wait Until Page Contains The password is expired and must be changed. timeout=10
208
209 # Update a valid acceptable password.
210 Input Text ${xpath_input_password} ${admin_password}
211 Input Text ${xpath_input_confirm_password} ${admin_password}
212 Click Button ${xpath_confirm_password_button}
213 Wait Until Page Contains Overview timeout=20
214
215 # Verify valid password.
216 Redfish.Login ${admin_user} ${admin_password}
217
218
Megha G N2f76ae42023-10-13 05:05:46 -0500219Expire Admin Password And Check IPMI Access Fails
220 [Documentation] Expire admin user password and expect an error while access via IPMI.
221 [Tags] Expire_Admin_Password_And_Check_IPMI_Access_Fails
222 [Setup] Redfish Create User ${admin_user} ${default_adminuser_passwd} Administrator ${True}
223
224 Expire Password ${admin_user}
225
226 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v
227 Should Be Equal ${status} ${False}
228
229
Megha G N80222cf2023-10-17 04:01:04 -0500230Verify Expire Admin Password And Update Bad Password Length Via Redfish
231 [Documentation] Expire admin password and update bad password with more than 20 characters
232 ... via Redfish and expect an error.
233 [Tags] Verify_Expire_Admin_Password_And_Update_Bad_Password_Length_Via_Redfish
234 [Setup] Redfish Create User ${admin_user} ${default_adminuser_passwd} Administrator ${True}
235
236 Expire Password ${admin_user}
237
238 Redfish.Login
239 ${status}= Run Keyword And Return Status
240 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
241 ... body={'Password': '0penBmc0penBmc0penBmc'}
242
243 Should Be Equal ${status} ${False}
244
245
Megha G N014ad012023-11-07 01:13:04 -0600246Verify Error While Creating User With Expired Admin Password
247 [Documentation] Expire admin password and expect an error while creating new user.
248 [Tags] Verify_Error_While_Creating_User_With_Expired_Admin_Password
249 [Teardown] Restore Default Password For Admin User
250
251 Expire Password ${admin_user}
252
253 Verify User Password Expired Using Redfish ${admin_user} ${default_adminuser_passwd}
254
255 # Create new user with expired admin password and expect an error.
256 ${payload}= Create Dictionary
257 ... UserName=admin_user1 Password=TestPwd123 RoleId=Administrator Enabled=${True}
258 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
259 ... valid_status_codes=[${HTTP_FORBIDDEN}]
260
261
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500262*** Keywords ***
263
George Keishing4d4ef992021-01-28 09:56:53 -0600264Set Account Lockout Threshold
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500265 [Documentation] Set user account lockout threshold.
shrsuman123a9d93412021-07-13 04:06:05 -0500266 [Arguments] ${account_lockout_threshold}=${0} ${account_lockout_duration}=${50}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500267
268 # Description of argument(s):
269 # account_lockout_threshold Set lockout threshold value.
shrsuman123a9d93412021-07-13 04:06:05 -0500270 # account_lockout_duration Set lockout duration value.
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500271
272 Redfish.login
shrsuman123a9d93412021-07-13 04:06:05 -0500273 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
274 ... AccountLockoutDuration=${account_lockout_duration}
275 Redfish.Patch /redfish/v1/AccountService/ body=&{payload}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500276 gen_robot_valid.Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -0500277 Redfish.Logout
278
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500279Restore Default Password For Root User
280 [Documentation] Restore default password for root user (i.e. 0penBmc).
281
282 # Set default password for root user.
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500283 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
284 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500285 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500286 Redfish.Logout
287
288
289Test Teardown Execution
290 [Documentation] Do test teardown task.
291
292 Redfish.Login
293 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
Anvesh Kumar9f421212020-04-27 01:42:50 -0500294 Redfish.Logout
George Keishing4d4ef992021-01-28 09:56:53 -0600295 Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500296 FFDC On Test Case Fail
Megha G Ne18cdb52023-10-11 04:45:32 -0500297
298
299Expire Password
300 [Documentation] Force expire password.
301 [Arguments] ${username}
302
303 # Description of argument(s):
304 # username User to be created and expire.
305
306 # Expire the password.
307 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
308
309 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${username}
310 Should Contain Any ${output} password expiry information changed password changed
311
312 # Example output:
313 # passwd --expire admin
314 # passwd: password changed.
315
316 Close All Connections
Megha G N014ad012023-11-07 01:13:04 -0600317
318
319Restore Default Password For Admin User
320 [Documentation] Restore default password for admin user (i.e. AdminUser1).
321
322 # Set default password for admin user.
323 Redfish.Patch /redfish/v1/AccountService/Accounts/${admin_user}
324 ... body={'Password': '${default_adminuser_passwd}'} valid_status_codes=[${HTTP_OK}]
325 # Verify that admin user is able to run Redfish command using default password.
326 Redfish.Logout