blob: 62ef99c19b3bfb23727119ca0d53dd90550110d1 [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
15
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050016*** Variables ***
Anvesh Kumar9f421212020-04-27 01:42:50 -050017
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050018# If user re-tries more than 5 time incorrectly, the user gets locked for 5 minutes.
19${default_lockout_duration} ${300}
Megha G Ne18cdb52023-10-11 04:45:32 -050020${admin_user} admin_user
21${default_adminuser_passwd} AdminUser1
22${admin_password} AdminUser2
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050023
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050024
25*** Test Cases ***
26
27Expire Root Password And Check IPMI Access Fails
28 [Documentation] Expire root user password and expect an error while access via IPMI.
29 [Tags] Expire_Root_Password_And_Check_IPMI_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050030 [Teardown] Test Teardown Execution
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050031
Megha G Ne18cdb52023-10-11 04:45:32 -050032 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050033
34 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v
35 Should Be Equal ${status} ${False}
36
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050037
38Expire Root Password And Check SSH Access Fails
39 [Documentation] Expire root user password and expect an error while access via SSH.
40 [Tags] Expire_Root_Password_And_Check_SSH_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050041 [Teardown] Test Teardown Execution
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050042
Megha G Ne18cdb52023-10-11 04:45:32 -050043 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050044
45 ${status}= Run Keyword And Return Status
46 ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
47 Should Be Equal ${status} ${False}
48
49
Anves Kumar rayankula67921142020-05-14 04:03:24 -050050Expire And Change Root User Password And Access Via SSH
51 [Documentation] Expire and change root user password and access via SSH.
George Keishingb98036a2022-01-31 12:39:47 -060052 [Tags] Expire_And_Change_Root_User_Password_And_Access_Via_SSH
Anves Kumar rayankula67921142020-05-14 04:03:24 -050053 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
54 ... Restore Default Password For Root User AND FFDC On Test Case Fail
55
Megha G Ne18cdb52023-10-11 04:45:32 -050056 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula67921142020-05-14 04:03:24 -050057
Anvesh Kumar9f421212020-04-27 01:42:50 -050058 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050059 # Change to a valid password.
60 ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
61 ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}]
62
63 # Verify login with the new password through SSH.
64 Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123
65
66
67Expire Root Password And Update Bad Password Length Via Redfish
68 [Documentation] Expire root password and update bad password via Redfish and expect an error.
69 [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish
70 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050071 ... Restore Default Password For Root User AND FFDC On Test Case Fail
Anves Kumar rayankula67921142020-05-14 04:03:24 -050072
Megha G Ne18cdb52023-10-11 04:45:32 -050073 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula67921142020-05-14 04:03:24 -050074
Anvesh Kumar9f421212020-04-27 01:42:50 -050075 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050076 ${status}= Run Keyword And Return Status
77 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
78 ... body={'Password': '0penBmc0penBmc0penBmc'}
79 Should Be Equal ${status} ${False}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050080
Anvesh Kumar9f421212020-04-27 01:42:50 -050081
82Expire And Change Root User Password Via Redfish And Verify
83 [Documentation] Expire and change root user password via Redfish and verify.
84 [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify
85 [Teardown] Run Keywords FFDC On Test Case Fail AND
86 ... Wait Until Keyword Succeeds 1 min 10 sec
87 ... Restore Default Password For Root User
88
Megha G Ne18cdb52023-10-11 04:45:32 -050089 Expire Password ${OPENBMC_USERNAME}
Anvesh Kumar9f421212020-04-27 01:42:50 -050090
shrsuman123a9d93412021-07-13 04:06:05 -050091 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anvesh Kumar9f421212020-04-27 01:42:50 -050092 # Change to a valid password.
93 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
94 ... body={'Password': '0penBmc123'}
95 Redfish.Logout
96
97 # Verify login with the new password.
98 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
99
100
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500101Verify Error While Creating User With Expired Password
102 [Documentation] Expire root password and expect an error while creating new user.
103 [Tags] Verify_Error_While_Creating_User_With_Expired_Password
104 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
105 ... Restore Default Password For Root User AND FFDC On Test Case Fail
106
Megha G Ne18cdb52023-10-11 04:45:32 -0500107 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500108
shrsuman123a9d93412021-07-13 04:06:05 -0500109 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500110 Redfish.Login
111 ${payload}= Create Dictionary
112 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
113 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
114 ... valid_status_codes=[${HTTP_FORBIDDEN}]
115
116
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500117Expire And Change Root Password Via GUI
118 [Documentation] Expire and change root password via GUI.
119 [Tags] Expire_And_Change_Root_Password_Via_GUI
shrsuman123a9d93412021-07-13 04:06:05 -0500120 [Setup] Launch Browser And Login GUI
121 [Teardown] Run Keywords Logout GUI AND Close Browser
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500122 ... AND Restore Default Password For Root User AND FFDC On Test Case Fail
123
Megha G Ne18cdb52023-10-11 04:45:32 -0500124 Expire Password ${OPENBMC_USERNAME}
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500125
shrsuman123a9d93412021-07-13 04:06:05 -0500126 Wait Until Page Contains Element ${xpath_root_button_menu}
127 Click Element ${xpath_root_button_menu}
128 Click Element ${xpath_profile_settings}
129 Wait Until Page Contains Change password
130
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500131 # Change valid password.
132 Input Text ${xpath_input_password} 0penBmc123
133 Input Text ${xpath_input_confirm_password} 0penBmc123
shrsuman123a9d93412021-07-13 04:06:05 -0500134 Click Button ${xpath_profile_save_button}
135 Wait Until Page Contains Successfully saved account settings.
136 Wait Until Page Does Not Contain Successfully saved account settings. timeout=20
137 Logout GUI
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500138
139 # Verify valid password.
shrsuman123a9d93412021-07-13 04:06:05 -0500140 Login GUI ${OPENBMC_USERNAME} 0penBmc123
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500141 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
142
143
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500144Verify Maximum Failed Attempts And Check Root User Account Locked
145 [Documentation] Verify maximum failed attempts and locks out root user account.
146 [Tags] Verify_Maximum_Failed_Attempts_And_Check_Root_User_Account_Locked
George Keishing4d4ef992021-01-28 09:56:53 -0600147 [Setup] Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500148
149 # Make maximum failed login attempts.
150 Repeat Keyword ${5} times
151 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login root 0penBmc123
152
153 # Verify that legitimate login fails due to lockout.
154 Run Keyword And Expect Error InvalidCredentialsError*
155 ... Redfish.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
156
157 # Wait for lockout duration to expire and then verify that login works.
158 Sleep ${default_lockout_duration}s
159 Redfish.Login
160 Redfish.Logout
161
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500162Verify New Password Persistency After BMC Reboot
163 [Documentation] Verify new password persistency after BMC reboot.
164 [Tags] Verify_New_Password_Persistency_After_BMC_Reboot
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500165 [Teardown] Test Teardown Execution
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500166
167 Redfish.Login
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500168
169 # Make sure the user account in question does not already exist.
170 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
171 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
172
173 # Create specified user.
174 ${payload}= Create Dictionary
175 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
176 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
177 ... valid_status_codes=[${HTTP_CREATED}]
178 Redfish.Logout
179
180 Redfish.Login admin_user TestPwd123
181
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500182 # Change to a valid password.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500183 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500184 ... body={'Password': '0penBmc123'}
185
186 # Reboot BMC and verify persistency.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500187 Redfish OBMC Reboot (off)
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500188
189 # verify new password
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500190 Redfish.Login admin_user 0penBmc123
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500191
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500192
Megha G Ne18cdb52023-10-11 04:45:32 -0500193Verify Expire And Change Admin User Password Via GUI
194 [Documentation] Force expire admin password and update admin password via GUI.
195 [Tags] Verify_Expire_And_Change_Admin_User_Password_Via_GUI
196 [Setup] Run Keywords Launch Browser And Login GUI AND
197 ... Redfish Create User ${admin_user} ${default_adminuser_passwd} Administrator ${True}
198 [Teardown] Run Keywords Logout GUI AND Close Browser
199
200 Expire Password ${admin_user}
201
202 Logout GUI
203
204 # Verify that admin user should not be able to login with expired password.
205 Login GUI ${admin_user} ${default_adminuser_passwd}
206
207 # Verify error message to update the password.
208 Wait Until Page Contains The password is expired and must be changed. timeout=10
209
210 # Update a valid acceptable password.
211 Input Text ${xpath_input_password} ${admin_password}
212 Input Text ${xpath_input_confirm_password} ${admin_password}
213 Click Button ${xpath_confirm_password_button}
214 Wait Until Page Contains Overview timeout=20
215
216 # Verify valid password.
217 Redfish.Login ${admin_user} ${admin_password}
218
219
Megha G N2f76ae42023-10-13 05:05:46 -0500220Expire Admin Password And Check IPMI Access Fails
221 [Documentation] Expire admin user password and expect an error while access via IPMI.
222 [Tags] Expire_Admin_Password_And_Check_IPMI_Access_Fails
223 [Setup] Redfish Create User ${admin_user} ${default_adminuser_passwd} Administrator ${True}
224
225 Expire Password ${admin_user}
226
227 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v
228 Should Be Equal ${status} ${False}
229
230
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500231*** Keywords ***
232
George Keishing4d4ef992021-01-28 09:56:53 -0600233Set Account Lockout Threshold
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500234 [Documentation] Set user account lockout threshold.
shrsuman123a9d93412021-07-13 04:06:05 -0500235 [Arguments] ${account_lockout_threshold}=${0} ${account_lockout_duration}=${50}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500236
237 # Description of argument(s):
238 # account_lockout_threshold Set lockout threshold value.
shrsuman123a9d93412021-07-13 04:06:05 -0500239 # account_lockout_duration Set lockout duration value.
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500240
241 Redfish.login
shrsuman123a9d93412021-07-13 04:06:05 -0500242 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
243 ... AccountLockoutDuration=${account_lockout_duration}
244 Redfish.Patch /redfish/v1/AccountService/ body=&{payload}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500245 gen_robot_valid.Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -0500246 Redfish.Logout
247
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500248Restore Default Password For Root User
249 [Documentation] Restore default password for root user (i.e. 0penBmc).
250
251 # Set default password for root user.
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500252 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
253 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500254 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500255 Redfish.Logout
256
257
258Test Teardown Execution
259 [Documentation] Do test teardown task.
260
261 Redfish.Login
262 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
Anvesh Kumar9f421212020-04-27 01:42:50 -0500263 Redfish.Logout
George Keishing4d4ef992021-01-28 09:56:53 -0600264 Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500265 FFDC On Test Case Fail
Megha G Ne18cdb52023-10-11 04:45:32 -0500266
267
268Expire Password
269 [Documentation] Force expire password.
270 [Arguments] ${username}
271
272 # Description of argument(s):
273 # username User to be created and expire.
274
275 # Expire the password.
276 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
277
278 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${username}
279 Should Contain Any ${output} password expiry information changed password changed
280
281 # Example output:
282 # passwd --expire admin
283 # passwd: password changed.
284
285 Close All Connections