Added expire password testcases
Testcases:
- Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
- Verify If The Modified Admin Credential Is Valid Post Update
Change-Id: I70161a1d6da9c386035c82bcd7fdcc76668d323e
Signed-off-by: Anves Kumar rayankula <anvesr77@in.ibm.com>
diff --git a/lib/bmc_redfish_utils.robot b/lib/bmc_redfish_utils.robot
index eb19aa8..dc7ba5d 100644
--- a/lib/bmc_redfish_utils.robot
+++ b/lib/bmc_redfish_utils.robot
@@ -264,3 +264,39 @@
... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
END
+
+Expire And Update New Password Via Redfish
+ [Documentation] Expire and change password and verify using password.
+ [Arguments] ${username} ${password} ${new_password}
+
+ # Description of argument(s):
+ # username The username to be used to login to the BMC.
+ # password The password to be used to login to the BMC.
+ # new_password The new password to be used to update password.
+
+ # Expire admin password using ssh.
+ Open Connection And Log In ${username} ${password}
+ ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${username}
+ Should Contain ${output} password expiry information changed
+
+ # Verify user password expired using Redfish
+ Verify User Password Expired Using Redfish ${username} ${password}
+
+ # Change user password.
+ Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user
+ ... body={'Password': '${new_password}'}
+ Redfish.Logout
+
+
+Verify User Password Expired Using Redfish
+ [Documentation] Checking whether user password expired or not using redfish.
+
+ # Description of argument(s):
+ # username The username to be used to login to the BMC.
+ # password The password to be used to login to the BMC.
+
+ [Arguments] ${username} ${password} ${expected_result}=${True}
+ Redfish.Login ${username} ${password}
+ ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/${username}
+ Should Be Equal ${resp.dict["PasswordChangeRequired"]} ${expected_result}
+
diff --git a/redfish/update_service/test_redfish_bmc_code_update.robot b/redfish/update_service/test_redfish_bmc_code_update.robot
index f0f9aaa..31cf578 100644
--- a/redfish/update_service/test_redfish_bmc_code_update.robot
+++ b/redfish/update_service/test_redfish_bmc_code_update.robot
@@ -18,6 +18,7 @@
Resource ../../lib/logging_utils.robot
Resource ../../lib/redfish_code_update_utils.robot
Resource ../../lib/utils.robot
+Resource ../../lib/bmc_redfish_utils.robot
Library ../../lib/gen_robot_valid.py
Library ../../lib/tftp_update_utils.py
Library ../../lib/gen_robot_keyword.py
@@ -29,6 +30,11 @@
Force Tags BMC_Code_Update
+*** Variables ***
+
+@{ADMIN} admin_user TestPwd123
+&{USERS} Administrator=${ADMIN}
+
*** Test Cases ***
Redfish Code Update With ApplyTime OnReset
@@ -58,6 +64,39 @@
Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
+Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
+ [Tags] Verify_If_The_Modified_Admin_Credentails_Is_Valid_Backup_Image
+ [Setup] Create Users With Different Roles users=${USERS} force=${True}
+ [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
+
+ ${post_code_update_actions}= Get Post Boot Action
+ ${state}= Get Pre Reboot State
+ Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
+
+ Redfish.Login
+ # change to backup image and reset the BMC.
+ Switch Backup Firmware Image To Functional
+ Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
+
+ # verify modified admin password on backup image.
+ Redfish.Login admin_user 0penBmc123
+ Redfish.Logout
+
+Verify If The Modified Admin Credential Is Valid Post Update
+ [Tags] Verify_If_The_Modified_Admin_Credentails_Is_Valid_Post_Update
+ [Setup] Create Users With Different Roles users=${USERS} force=${True}
+ [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
+
+ Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
+
+ Redfish.Login
+ # Flash latest firmware using redfish.
+ Redfish Update Firmware OnReset
+
+ # verify modified admin credentails on latest image.
+ Redfish.Login admin_user 0penBmc123
+ Redfish.Logout
+
*** Keywords ***
Suite Setup Execution