blob: 2cf224118f9ab9066d84e0930693b6a9fbc3cd83 [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
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050013*** Variables ***
Anvesh Kumar9f421212020-04-27 01:42:50 -050014
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050015# If user re-tries more than 5 time incorrectly, the user gets locked for 5 minutes.
16${default_lockout_duration} ${300}
17
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050018
19*** Test Cases ***
20
21Expire Root Password And Check IPMI Access Fails
22 [Documentation] Expire root user password and expect an error while access via IPMI.
23 [Tags] Expire_Root_Password_And_Check_IPMI_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050024 [Teardown] Test Teardown Execution
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050025
26 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
27
28 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
29 Should Contain ${output} password expiry information changed
30
31 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v
32 Should Be Equal ${status} ${False}
33
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050034
35Expire Root Password And Check SSH Access Fails
36 [Documentation] Expire root user password and expect an error while access via SSH.
37 [Tags] Expire_Root_Password_And_Check_SSH_Access_Fails
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -050038 [Teardown] Test Teardown Execution
Anves Kumar rayankula5df05f72020-06-22 23:58:25 -050039
40 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
41 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
42 Should Contain ${output} password expiry information changed
43
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.
51 [Tags] Expire_Root_User_Password_And_Access_Via_SSH
52 [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
55 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
56
57 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
58 Should Contain ${output} password expiry information changed
59
Anvesh Kumar9f421212020-04-27 01:42:50 -050060 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050061 # Change to a valid password.
62 ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
63 ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}]
64
65 # Verify login with the new password through SSH.
66 Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123
67
68
69Expire Root Password And Update Bad Password Length Via Redfish
70 [Documentation] Expire root password and update bad password via Redfish and expect an error.
71 [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish
72 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050073 ... Restore Default Password For Root User AND FFDC On Test Case Fail
Anves Kumar rayankula67921142020-05-14 04:03:24 -050074
75 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
76 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
77 Should Contain ${output} password expiry information changed
78
Anvesh Kumar9f421212020-04-27 01:42:50 -050079 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050080 ${status}= Run Keyword And Return Status
81 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
82 ... body={'Password': '0penBmc0penBmc0penBmc'}
83 Should Be Equal ${status} ${False}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050084
Anvesh Kumar9f421212020-04-27 01:42:50 -050085
86Expire And Change Root User Password Via Redfish And Verify
87 [Documentation] Expire and change root user password via Redfish and verify.
88 [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify
89 [Teardown] Run Keywords FFDC On Test Case Fail AND
90 ... Wait Until Keyword Succeeds 1 min 10 sec
91 ... Restore Default Password For Root User
92
93 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
94
95 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
96 Should Contain ${output} password expiry information changed
97
shrsuman123a9d93412021-07-13 04:06:05 -050098 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anvesh Kumar9f421212020-04-27 01:42:50 -050099 # Change to a valid password.
100 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
101 ... body={'Password': '0penBmc123'}
102 Redfish.Logout
103
104 # Verify login with the new password.
105 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
106
107
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500108Verify Error While Creating User With Expired Password
109 [Documentation] Expire root password and expect an error while creating new user.
110 [Tags] Verify_Error_While_Creating_User_With_Expired_Password
111 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
112 ... Restore Default Password For Root User AND FFDC On Test Case Fail
113
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500114 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
115 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
116 Should Contain ${output} password expiry information changed
117
shrsuman123a9d93412021-07-13 04:06:05 -0500118 Verify User Password Expired Using Redfish ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500119 Redfish.Login
120 ${payload}= Create Dictionary
121 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
122 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
123 ... valid_status_codes=[${HTTP_FORBIDDEN}]
124
125
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500126Expire And Change Root Password Via GUI
127 [Documentation] Expire and change root password via GUI.
128 [Tags] Expire_And_Change_Root_Password_Via_GUI
shrsuman123a9d93412021-07-13 04:06:05 -0500129 [Setup] Launch Browser And Login GUI
130 [Teardown] Run Keywords Logout GUI AND Close Browser
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500131 ... AND Restore Default Password For Root User AND FFDC On Test Case Fail
132
133 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
134 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
135 Should Contain ${output} password expiry information changed
136
shrsuman123a9d93412021-07-13 04:06:05 -0500137 Wait Until Page Contains Element ${xpath_root_button_menu}
138 Click Element ${xpath_root_button_menu}
139 Click Element ${xpath_profile_settings}
140 Wait Until Page Contains Change password
141
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500142 # Change valid password.
143 Input Text ${xpath_input_password} 0penBmc123
144 Input Text ${xpath_input_confirm_password} 0penBmc123
shrsuman123a9d93412021-07-13 04:06:05 -0500145 Click Button ${xpath_profile_save_button}
146 Wait Until Page Contains Successfully saved account settings.
147 Wait Until Page Does Not Contain Successfully saved account settings. timeout=20
148 Logout GUI
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500149
150 # Verify valid password.
shrsuman123a9d93412021-07-13 04:06:05 -0500151 Login GUI ${OPENBMC_USERNAME} 0penBmc123
Anves Kumar rayankula9233ce12020-06-17 00:14:41 -0500152 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
153
154
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500155Verify Maximum Failed Attempts And Check Root User Account Locked
156 [Documentation] Verify maximum failed attempts and locks out root user account.
157 [Tags] Verify_Maximum_Failed_Attempts_And_Check_Root_User_Account_Locked
George Keishing4d4ef992021-01-28 09:56:53 -0600158 [Setup] Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500159
160 # Make maximum failed login attempts.
161 Repeat Keyword ${5} times
162 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login root 0penBmc123
163
164 # Verify that legitimate login fails due to lockout.
165 Run Keyword And Expect Error InvalidCredentialsError*
166 ... Redfish.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
167
168 # Wait for lockout duration to expire and then verify that login works.
169 Sleep ${default_lockout_duration}s
170 Redfish.Login
171 Redfish.Logout
172
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500173Verify New Password Persistency After BMC Reboot
174 [Documentation] Verify new password persistency after BMC reboot.
175 [Tags] Verify_New_Password_Persistency_After_BMC_Reboot
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500176 [Teardown] Test Teardown Execution
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500177
178 Redfish.Login
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500179
180 # Make sure the user account in question does not already exist.
181 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
182 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
183
184 # Create specified user.
185 ${payload}= Create Dictionary
186 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
187 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
188 ... valid_status_codes=[${HTTP_CREATED}]
189 Redfish.Logout
190
191 Redfish.Login admin_user TestPwd123
192
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500193 # Change to a valid password.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500194 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500195 ... body={'Password': '0penBmc123'}
196
197 # Reboot BMC and verify persistency.
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500198 Redfish OBMC Reboot (off)
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500199
200 # verify new password
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500201 Redfish.Login admin_user 0penBmc123
Anves Kumar rayankulac46a8962020-08-07 10:00:44 -0500202
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500203
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500204*** Keywords ***
205
George Keishing4d4ef992021-01-28 09:56:53 -0600206Set Account Lockout Threshold
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500207 [Documentation] Set user account lockout threshold.
shrsuman123a9d93412021-07-13 04:06:05 -0500208 [Arguments] ${account_lockout_threshold}=${0} ${account_lockout_duration}=${50}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500209
210 # Description of argument(s):
211 # account_lockout_threshold Set lockout threshold value.
shrsuman123a9d93412021-07-13 04:06:05 -0500212 # account_lockout_duration Set lockout duration value.
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500213
214 Redfish.login
shrsuman123a9d93412021-07-13 04:06:05 -0500215 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
216 ... AccountLockoutDuration=${account_lockout_duration}
217 Redfish.Patch /redfish/v1/AccountService/ body=&{payload}
Anves Kumar rayankulae6c745a2020-09-24 04:14:09 -0500218 gen_robot_valid.Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -0500219 Redfish.Logout
220
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500221Restore Default Password For Root User
222 [Documentation] Restore default password for root user (i.e. 0penBmc).
223
224 # Set default password for root user.
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500225 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
226 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500227 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500228 Redfish.Logout
229
230
231Test Teardown Execution
232 [Documentation] Do test teardown task.
233
234 Redfish.Login
235 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
Anvesh Kumar9f421212020-04-27 01:42:50 -0500236 Redfish.Logout
George Keishing4d4ef992021-01-28 09:56:53 -0600237 Set Account Lockout Threshold account_lockout_threshold=${5}
Anves Kumar rayankula68f985b2020-07-24 04:39:46 -0500238 FFDC On Test Case Fail