1*** Settings *** 2Documentation Test root user expire password. 3 4Resource ../lib/resource.robot 5Resource ../lib/bmc_redfish_resource.robot 6Resource ../lib/ipmi_client.robot 7Library ../lib/bmc_ssh_utils.py 8Library SSHLibrary 9 10Suite Setup Suite Setup Execution 11Suite Teardown Suite Teardown Execution 12 13Test Teardown Test Teardown Execution 14 15*** Test Cases *** 16 17Expire Root Password And Check IPMI Access Fails 18 [Documentation] Expire root user password and expect an error while access via IPMI. 19 [Tags] Expire_Root_Password_And_Check_IPMI_Access_Fails 20 21 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 22 23 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} 24 Should Contain ${output} password expiry information changed 25 26 ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v 27 Should Be Equal ${status} ${False} 28 29Expire And Change Root User Password And Access Via SSH 30 [Documentation] Expire and change root user password and access via SSH. 31 [Tags] Expire_Root_User_Password_And_Access_Via_SSH 32 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec 33 ... Restore Default Password For Root User AND FFDC On Test Case Fail 34 35 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 36 37 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} 38 Should Contain ${output} password expiry information changed 39 40 Redfish.Login 41 # Change to a valid password. 42 ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} 43 ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}] 44 45 # Verify login with the new password through SSH. 46 Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123 47 48 49Expire Root Password And Update Bad Password Length Via Redfish 50 [Documentation] Expire root password and update bad password via Redfish and expect an error. 51 [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish 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 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} 57 Should Contain ${output} password expiry information changed 58 59 Redfish.Login 60 ${status}= Run Keyword And Return Status 61 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} 62 ... body={'Password': '0penBmc0penBmc0penBmc'} 63 Should Be Equal ${status} ${False} 64 65 66Expire And Change Root User Password Via Redfish And Verify 67 [Documentation] Expire and change root user password via Redfish and verify. 68 [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify 69 [Teardown] Run Keywords FFDC On Test Case Fail AND 70 ... Wait Until Keyword Succeeds 1 min 10 sec 71 ... Restore Default Password For Root User 72 73 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 74 75 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} 76 Should Contain ${output} password expiry information changed 77 78 79 Redfish.Login 80 Verify Root Password Expired 81 # Change to a valid password. 82 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} 83 ... body={'Password': '0penBmc123'} 84 Redfish.Logout 85 86 # Verify login with the new password. 87 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123 88 89 90*** Keywords *** 91 92Suite Setup Execution 93 [Documentation] Test setup execution. 94 95 Redfish.login 96 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0} 97 Valid Length OPENBMC_PASSWORD min_length=8 98 Redfish.Logout 99 100 101Restore Default Password For Root User 102 [Documentation] Restore default password for root user (i.e. 0penBmc). 103 104 # Set default password for root user. 105 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} 106 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}] 107 # Verify that root user is able to run Redfish command using default password. 108 Redfish.Logout 109 110 111Test Teardown Execution 112 [Documentation] Do test teardown task. 113 114 Redfish.Login 115 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User 116 FFDC On Test Case Fail 117 118 119Suite Teardown Execution 120 [Documentation] Do suite teardown task. 121 122 Redfish.login 123 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5} 124 Redfish.Logout 125 126Verify Root Password Expired 127 [Documentation] Checking whether root password expired or not. 128 129 Create Session openbmc ${AUTH_URI} 130 ${headers}= Create Dictionary Content-Type=application/json 131 @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 132 ${data}= Create Dictionary data=@{credentials} 133 ${resp}= Post Request openbmc /login data=${data} headers=${headers} 134 ${json}= To JSON ${resp.content} 135 Should Contain ${json["extendedMessage"]} POST the new password 136 Post Request openbmc /xyz/openbmc_project/user/root/action/SetPassword 137 ... data={"data":["0penBmc006"]} headers=${headers} 138 139