blob: 1bd261b394231756919e536ed2d3c8c4bd5c550d [file] [log] [blame]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -05001*** 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
Anvesh Kumar9f421212020-04-27 01:42:50 -050010Suite Setup Suite Setup Execution
11Suite Teardown Suite Teardown Execution
12
13Test Teardown Test Teardown Execution
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050014
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
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050020
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 rayankula5df05f72020-06-22 23:58:25 -050029
30Expire Root Password And Check SSH Access Fails
31 [Documentation] Expire root user password and expect an error while access via SSH.
32 [Tags] Expire_Root_Password_And_Check_SSH_Access_Fails
33
34 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
35 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
36 Should Contain ${output} password expiry information changed
37
38 ${status}= Run Keyword And Return Status
39 ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
40 Should Be Equal ${status} ${False}
41
42
Anves Kumar rayankula67921142020-05-14 04:03:24 -050043Expire And Change Root User Password And Access Via SSH
44 [Documentation] Expire and change root user password and access via SSH.
45 [Tags] Expire_Root_User_Password_And_Access_Via_SSH
46 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
47 ... Restore Default Password For Root User AND FFDC On Test Case Fail
48
49 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
50
51 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
52 Should Contain ${output} password expiry information changed
53
Anvesh Kumar9f421212020-04-27 01:42:50 -050054 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050055 # Change to a valid password.
56 ${resp}= Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
57 ... body={'Password': '0penBmc123'} valid_status_codes=[${HTTP_OK}]
58
59 # Verify login with the new password through SSH.
60 Open Connection And Log In ${OPENBMC_USERNAME} 0penBmc123
61
62
63Expire Root Password And Update Bad Password Length Via Redfish
64 [Documentation] Expire root password and update bad password via Redfish and expect an error.
65 [Tags] Expire_Root_Password_And_Update_Bad_Password_Length_Via_Redfish
66 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050067 ... Restore Default Password For Root User AND FFDC On Test Case Fail
Anves Kumar rayankula67921142020-05-14 04:03:24 -050068
69 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
70 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
71 Should Contain ${output} password expiry information changed
72
Anvesh Kumar9f421212020-04-27 01:42:50 -050073 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050074 ${status}= Run Keyword And Return Status
75 ... Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
76 ... body={'Password': '0penBmc0penBmc0penBmc'}
77 Should Be Equal ${status} ${False}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050078
Anvesh Kumar9f421212020-04-27 01:42:50 -050079
80Expire And Change Root User Password Via Redfish And Verify
81 [Documentation] Expire and change root user password via Redfish and verify.
82 [Tags] Expire_And_Change_Root_User_Password_Via_Redfish_And_Verify
83 [Teardown] Run Keywords FFDC On Test Case Fail AND
84 ... Wait Until Keyword Succeeds 1 min 10 sec
85 ... Restore Default Password For Root User
86
87 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
88
89 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
90 Should Contain ${output} password expiry information changed
91
92
93 Redfish.Login
94 Verify Root Password Expired
95 # Change to a valid password.
96 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
97 ... body={'Password': '0penBmc123'}
98 Redfish.Logout
99
100 # Verify login with the new password.
101 Redfish.Login ${OPENBMC_USERNAME} 0penBmc123
102
103
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500104Verify Error While Creating User With Expired Password
105 [Documentation] Expire root password and expect an error while creating new user.
106 [Tags] Verify_Error_While_Creating_User_With_Expired_Password
107 [Teardown] Run Keywords Wait Until Keyword Succeeds 1 min 10 sec
108 ... Restore Default Password For Root User AND FFDC On Test Case Fail
109
110
111 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
112 ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${OPENBMC_USERNAME}
113 Should Contain ${output} password expiry information changed
114
115 Verify Root Password Expired
116 Redfish.Login
117 ${payload}= Create Dictionary
118 ... UserName=admin_user Password=TestPwd123 RoleId=Administrator Enabled=${True}
119 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
120 ... valid_status_codes=[${HTTP_FORBIDDEN}]
121
122
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500123*** Keywords ***
124
Anvesh Kumar9f421212020-04-27 01:42:50 -0500125Suite Setup Execution
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500126 [Documentation] Suite setup execution.
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500127
128 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -0500129 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500130 Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -0500131 Redfish.Logout
132
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500133Restore Default Password For Root User
134 [Documentation] Restore default password for root user (i.e. 0penBmc).
135
136 # Set default password for root user.
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500137 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
138 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500139 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500140 Redfish.Logout
141
142
143Test Teardown Execution
144 [Documentation] Do test teardown task.
145
146 Redfish.Login
147 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
148 FFDC On Test Case Fail
149
150
151Suite Teardown Execution
152 [Documentation] Do suite teardown task.
153
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500154 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -0500155 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5}
156 Redfish.Logout
157
158Verify Root Password Expired
159 [Documentation] Checking whether root password expired or not.
160
161 Create Session openbmc ${AUTH_URI}
162 ${headers}= Create Dictionary Content-Type=application/json
163 @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
164 ${data}= Create Dictionary data=@{credentials}
165 ${resp}= Post Request openbmc /login data=${data} headers=${headers}
166 ${json}= To JSON ${resp.content}
167 Should Contain ${json["extendedMessage"]} POST the new password