Modified Expire password keywords
Code fixes:
- Verify New Password Persistency After BMC Reboot
- Set Accont Lockout Threshold
- Test Teardown Execution
Change-Id: Iac85c92d918e99b7d33aa5048e16da50bff3b475
Signed-off-by: Anves Kumar rayankula <anvesr77@in.ibm.com>
diff --git a/security/test_bmc_expire_password.robot b/security/test_bmc_expire_password.robot
index 1c274a9..9ef5c01 100644
--- a/security/test_bmc_expire_password.robot
+++ b/security/test_bmc_expire_password.robot
@@ -7,6 +7,8 @@
Library ../lib/bmc_ssh_utils.py
Library SSHLibrary
+Test Setup Set Accont Lockout Threshold
+
*** Variables ***
# If user re-tries more than 5 time incorrectly, the user gets locked for 5 minutes.
@@ -150,6 +152,7 @@
Verify Maximum Failed Attempts And Check Root User Account Locked
[Documentation] Verify maximum failed attempts and locks out root user account.
[Tags] Verify_Maximum_Failed_Attempts_And_Check_Root_User_Account_Locked
+ [Setup] Set Accont Lockout Threshold account_lockout_threshold=${5}
# Make maximum failed login attempts.
Repeat Keyword ${5} times
@@ -167,33 +170,46 @@
Verify New Password Persistency After BMC Reboot
[Documentation] Verify new password persistency after BMC reboot.
[Tags] Verify_New_Password_Persistency_After_BMC_Reboot
- [Teardown] Run Keywords Restore Default Password For Root User
- ... AND FFDC On Test Case Fail
-
- Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
- ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
- Should Contain ${output} password expiry information changed
+ [Teardown] Test Teardown Execution
Redfish.Login
+
+ # Make sure the user account in question does not already exist.
+ Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
+ ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
+
+ # Create specified user.
+ ${payload}= Create Dictionary
+ ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
+ Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
+ ... valid_status_codes=[${HTTP_CREATED}]
+ Redfish.Logout
+
+ Redfish.Login admin_user TestPwd123
+
# Change to a valid password.
- Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
+ Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user
... body={'Password': '0penBmc123'}
# Reboot BMC and verify persistency.
- OBMC Reboot (off)
+ Redfish OBMC Reboot (off)
# verify new password
- Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
+ Redfish.Login admin_user 0penBmc123
*** Keywords ***
-Test Setup Execution
- [Documentation] Suite setup execution.
+Set Accont Lockout Threshold
+ [Documentation] Set user account lockout threshold.
+ [Arguments] ${account_lockout_threshold}=${0}
+
+ # Description of argument(s):
+ # account_lockout_threshold Set lockout threshold value.
Redfish.login
- Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0}
- Valid Length OPENBMC_PASSWORD min_length=8
+ Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold":${account_lockout_threshold}}
+ gen_robot_valid.Valid Length OPENBMC_PASSWORD min_length=8
Redfish.Logout
Restore Default Password For Root User
@@ -211,8 +227,8 @@
Redfish.Login
Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
- Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5}
Redfish.Logout
+ Set Accont Lockout Threshold account_lockout_threshold=${5}
FFDC On Test Case Fail
@@ -226,3 +242,4 @@
${resp}= Post Request openbmc /login data=${data} headers=${headers}
${json}= To JSON ${resp.content}
Should Contain ${json["extendedMessage"]} POST the new password
+