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 |
Anves Kumar rayankula | 9233ce1 | 2020-06-17 00:14:41 -0500 | [diff] [blame] | 5 | Resource ../gui/lib/resource.robot |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 6 | Resource ../lib/ipmi_client.robot |
| 7 | Library ../lib/bmc_ssh_utils.py |
| 8 | Library SSHLibrary |
| 9 | |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 10 | *** Variables *** |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 11 | |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 12 | # If user re-tries more than 5 time incorrectly, the user gets locked for 5 minutes. |
| 13 | ${default_lockout_duration} ${300} |
| 14 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 15 | |
| 16 | *** Test Cases *** |
| 17 | |
| 18 | Expire Root Password And Check IPMI Access Fails |
| 19 | [Documentation] Expire root user password and expect an error while access via IPMI. |
| 20 | [Tags] Expire_Root_Password_And_Check_IPMI_Access_Fails |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 21 | [Teardown] Test Teardown Execution |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 22 | |
| 23 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 24 | |
| 25 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 26 | Should Contain ${output} password expiry information changed |
| 27 | |
| 28 | ${status}= Run Keyword And Return Status Run External IPMI Standard Command lan print -v |
| 29 | Should Be Equal ${status} ${False} |
| 30 | |
Anves Kumar rayankula | 5df05f7 | 2020-06-22 23:58:25 -0500 | [diff] [blame] | 31 | |
| 32 | Expire Root Password And Check SSH Access Fails |
| 33 | [Documentation] Expire root user password and expect an error while access via SSH. |
| 34 | [Tags] Expire_Root_Password_And_Check_SSH_Access_Fails |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 35 | [Teardown] Test Teardown Execution |
Anves Kumar rayankula | 5df05f7 | 2020-06-22 23:58:25 -0500 | [diff] [blame] | 36 | |
| 37 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 38 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 39 | Should Contain ${output} password expiry information changed |
| 40 | |
| 41 | ${status}= Run Keyword And Return Status |
| 42 | ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 43 | Should Be Equal ${status} ${False} |
| 44 | |
| 45 | |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 46 | Expire And Change Root User Password And Access Via SSH |
| 47 | [Documentation] Expire and change root user password and access via SSH. |
| 48 | [Tags] Expire_Root_User_Password_And_Access_Via_SSH |
| 49 | [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec |
| 50 | ... Restore Default Password For Root User AND FFDC On Test Case Fail |
| 51 | |
| 52 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 53 | |
| 54 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 55 | Should Contain ${output} password expiry information changed |
| 56 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 57 | Redfish.Login |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 58 | # Change to a valid password. |
| 59 | ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 60 | ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}] |
| 61 | |
| 62 | # Verify login with the new password through SSH. |
| 63 | Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123 |
| 64 | |
| 65 | |
| 66 | Expire Root Password And Update Bad Password Length Via Redfish |
| 67 | [Documentation] Expire root password and update bad password via Redfish and expect an error. |
| 68 | [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish |
| 69 | [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 70 | ... 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] | 71 | |
| 72 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 73 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 74 | Should Contain ${output} password expiry information changed |
| 75 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 76 | Redfish.Login |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 77 | ${status}= Run Keyword And Return Status |
| 78 | ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 79 | ... body={'Password': '0penBmc0penBmc0penBmc'} |
| 80 | Should Be Equal ${status} ${False} |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 81 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 82 | |
| 83 | Expire And Change Root User Password Via Redfish And Verify |
| 84 | [Documentation] Expire and change root user password via Redfish and verify. |
| 85 | [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify |
| 86 | [Teardown] Run Keywords FFDC On Test Case Fail AND |
| 87 | ... Wait Until Keyword Succeeds 1 min 10 sec |
| 88 | ... Restore Default Password For Root User |
| 89 | |
| 90 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 91 | |
| 92 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 93 | Should Contain ${output} password expiry information changed |
| 94 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 95 | Redfish.Login |
| 96 | Verify Root Password Expired |
| 97 | # Change to a valid password. |
| 98 | Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 99 | ... body={'Password': '0penBmc123'} |
| 100 | Redfish.Logout |
| 101 | |
| 102 | # Verify login with the new password. |
| 103 | Redfish.Login ${OPENBMC_USERNAME} 0penBmc123 |
| 104 | |
| 105 | |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 106 | Verify Error While Creating User With Expired Password |
| 107 | [Documentation] Expire root password and expect an error while creating new user. |
| 108 | [Tags] Verify_Error_While_Creating_User_With_Expired_Password |
| 109 | [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec |
| 110 | ... Restore Default Password For Root User AND FFDC On Test Case Fail |
| 111 | |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 112 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 113 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 114 | Should Contain ${output} password expiry information changed |
| 115 | |
| 116 | Verify Root Password Expired |
| 117 | Redfish.Login |
| 118 | ${payload}= Create Dictionary |
| 119 | ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True} |
| 120 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
| 121 | ... valid_status_codes=[${HTTP_FORBIDDEN}] |
| 122 | |
| 123 | |
Anves Kumar rayankula | 9233ce1 | 2020-06-17 00:14:41 -0500 | [diff] [blame] | 124 | Expire And Change Root Password Via GUI |
| 125 | [Documentation] Expire and change root password via GUI. |
| 126 | [Tags] Expire_And_Change_Root_Password_Via_GUI |
| 127 | [Setup] Run Keywords Launch Browser And Login OpenBMC GUI |
| 128 | [Teardown] Run Keywords Logout And Close Browser |
| 129 | ... AND Restore Default Password For Root User AND FFDC On Test Case Fail |
| 130 | |
| 131 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 132 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 133 | Should Contain ${output} password expiry information changed |
| 134 | |
| 135 | Click Button ${xpath_button_user_action} |
| 136 | Click Element ${xpath_button_profile_settings} |
| 137 | Page Should Contain Change password |
| 138 | Sleep 2s |
| 139 | # Change valid password. |
| 140 | Input Text ${xpath_input_password} 0penBmc123 |
| 141 | Input Text ${xpath_input_confirm_password} 0penBmc123 |
| 142 | Click Button ${xpath_submit_button} |
| 143 | |
| 144 | # Verify valid password. |
| 145 | Open Browser With URL ${obmc_gui_url} |
| 146 | Login OpenBMC GUI ${OPENBMC_USERNAME} 0penBmc123 |
| 147 | Redfish.Login ${OPENBMC_USERNAME} 0penBmc123 |
| 148 | |
| 149 | |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 150 | Verify Maximum Failed Attempts And Check Root User Account Locked |
| 151 | [Documentation] Verify maximum failed attempts and locks out root user account. |
| 152 | [Tags] Verify_Maximum_Failed_Attempts_And_Check_Root_User_Account_Locked |
| 153 | |
| 154 | # Make maximum failed login attempts. |
| 155 | Repeat Keyword ${5} times |
| 156 | ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login root 0penBmc123 |
| 157 | |
| 158 | # Verify that legitimate login fails due to lockout. |
| 159 | Run Keyword And Expect Error InvalidCredentialsError* |
| 160 | ... Redfish.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 161 | |
| 162 | # Wait for lockout duration to expire and then verify that login works. |
| 163 | Sleep ${default_lockout_duration}s |
| 164 | Redfish.Login |
| 165 | Redfish.Logout |
| 166 | |
Anves Kumar rayankula | c46a896 | 2020-08-07 10:00:44 -0500 | [diff] [blame] | 167 | Verify New Password Persistency After BMC Reboot |
| 168 | [Documentation] Verify new password persistency after BMC reboot. |
| 169 | [Tags] Verify_New_Password_Persistency_After_BMC_Reboot |
| 170 | [Teardown] Run Keywords Restore Default Password For Root User |
| 171 | ... AND FFDC On Test Case Fail |
| 172 | |
| 173 | Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 174 | ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME} |
| 175 | Should Contain ${output} password expiry information changed |
| 176 | |
| 177 | Redfish.Login |
| 178 | # Change to a valid password. |
| 179 | Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 180 | ... body={'Password': '0penBmc123'} |
| 181 | |
| 182 | # Reboot BMC and verify persistency. |
| 183 | OBMC Reboot (off) |
| 184 | |
| 185 | # verify new password |
| 186 | Redfish.Login ${OPENBMC_USERNAME} 0penBmc123 |
| 187 | |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 188 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 189 | *** Keywords *** |
| 190 | |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 191 | Test Setup Execution |
Anves Kumar rayankula | 322e3aa | 2020-06-01 00:28:48 -0500 | [diff] [blame] | 192 | [Documentation] Suite setup execution. |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 193 | |
| 194 | Redfish.login |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 195 | Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0} |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 196 | Valid Length OPENBMC_PASSWORD min_length=8 |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 197 | Redfish.Logout |
| 198 | |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 199 | Restore Default Password For Root User |
| 200 | [Documentation] Restore default password for root user (i.e. 0penBmc). |
| 201 | |
| 202 | # Set default password for root user. |
Anves Kumar rayankula | 6792114 | 2020-05-14 04:03:24 -0500 | [diff] [blame] | 203 | Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME} |
| 204 | ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}] |
Anves Kumar rayankula | a87b1b1 | 2020-05-06 01:18:28 -0500 | [diff] [blame] | 205 | # 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] | 206 | Redfish.Logout |
| 207 | |
| 208 | |
| 209 | Test Teardown Execution |
| 210 | [Documentation] Do test teardown task. |
| 211 | |
| 212 | Redfish.Login |
| 213 | Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 214 | Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5} |
| 215 | Redfish.Logout |
Anves Kumar rayankula | 68f985b | 2020-07-24 04:39:46 -0500 | [diff] [blame] | 216 | FFDC On Test Case Fail |
| 217 | |
Anvesh Kumar | 9f42121 | 2020-04-27 01:42:50 -0500 | [diff] [blame] | 218 | |
| 219 | Verify Root Password Expired |
| 220 | [Documentation] Checking whether root password expired or not. |
| 221 | |
| 222 | Create Session openbmc ${AUTH_URI} |
| 223 | ${headers}= Create Dictionary Content-Type=application/json |
| 224 | @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 225 | ${data}= Create Dictionary data=@{credentials} |
| 226 | ${resp}= Post Request openbmc /login data=${data} headers=${headers} |
| 227 | ${json}= To JSON ${resp.content} |
| 228 | Should Contain ${json["extendedMessage"]} POST the new password |