Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test root user expire password. |
| 3 | |
| 4 | Resource ../lib/resource.robot |
| 5 | Resource ../lib/bmc_redfish_resource.robot |
| 6 | Resource ../lib/ipmi_client.robot |
| 7 | Library ../lib/bmc_ssh_utils.py |
| 8 | Library SSHLibrary |
| 9 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 10 | Suite Setup Suite Setup Execution |
| 11 | Suite Teardown Suite Teardown Execution |
| 12 | |
| 13 | Test Teardown Test Teardown Execution |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 14 | |
| 15 | *** Test Cases *** |
| 16 | |
| 17 | Expire 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 |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 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 | |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 29 | Expire 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 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 40 | Redfish.Login |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 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 | |
| 49 | Expire 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 |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 53 | ... Restore Default Password For Root User AND FFDC On Test Case Fail |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 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 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 59 | Redfish.Login |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 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} |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 64 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 65 | |
| 66 | Expire 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 | |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 90 | Verify Error While Creating User With Expired Password |
| 91 | [Documentation] Expire root password and expect an error while creating new user. |
| 92 | [Tags] Verify_Error_While_Creating_User_With_Expired_Password |
| 93 | [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec |
| 94 | ... Restore Default Password For Root User AND FFDC On Test Case Fail |
| 95 | |
| 96 | |
| 97 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 98 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 99 | Should Contain ${output} password expiry information changed |
| 100 | |
| 101 | Verify Root Password Expired |
| 102 | Redfish.Login |
| 103 | ${payload}= Create Dictionary |
| 104 | ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True} |
| 105 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
| 106 | ... valid_status_codes=[${HTTP_FORBIDDEN}] |
| 107 | |
| 108 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 109 | *** Keywords *** |
| 110 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 111 | Suite Setup Execution |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 112 | [Documentation] Suite setup execution. |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 113 | |
| 114 | Redfish.login |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 115 | Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0} |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 116 | Valid Length OPENBMC_PASSWORD min_length=8 |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 117 | Redfish.Logout |
| 118 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 119 | |
| 120 | Restore Default Password For Root User |
| 121 | [Documentation] Restore default password for root user (i.e. 0penBmc). |
| 122 | |
| 123 | # Set default password for root user. |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 124 | Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 125 | ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}] |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 126 | # Verify that root user is able to run Redfish command using default password. |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 127 | Redfish.Logout |
| 128 | |
| 129 | |
| 130 | Test Teardown Execution |
| 131 | [Documentation] Do test teardown task. |
| 132 | |
| 133 | Redfish.Login |
| 134 | Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User |
| 135 | FFDC On Test Case Fail |
| 136 | |
| 137 | |
| 138 | Suite Teardown Execution |
| 139 | [Documentation] Do suite teardown task. |
| 140 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 141 | Redfish.login |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 142 | Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5} |
| 143 | Redfish.Logout |
| 144 | |
| 145 | Verify Root Password Expired |
| 146 | [Documentation] Checking whether root password expired or not. |
| 147 | |
| 148 | Create Session openbmc ${AUTH_URI} |
| 149 | ${headers}= Create Dictionary Content-Type=application/json |
| 150 | @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 151 | ${data}= Create Dictionary data=@{credentials} |
| 152 | ${resp}= Post Request openbmc /login data=${data} headers=${headers} |
| 153 | ${json}= To JSON ${resp.content} |
| 154 | Should Contain ${json["extendedMessage"]} POST the new password |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 155 | |