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