blob: 347663a7df54f936b979e2a98a262c265f943c83 [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 rayankula67921142020-05-14 04:03:24 -050029Expire 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 Kumar9f421212020-04-27 01:42:50 -050040 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050041 # 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
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050053 ... Restore Default Password For Root User AND FFDC On Test Case Fail
Anves Kumar rayankula67921142020-05-14 04:03:24 -050054
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 Kumar9f421212020-04-27 01:42:50 -050059 Redfish.Login
Anves Kumar rayankula67921142020-05-14 04:03:24 -050060 ${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 rayankulaa87b1b12020-05-06 01:18:28 -050064
Anvesh Kumar9f421212020-04-27 01:42:50 -050065
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
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -050090Verify 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 rayankulaa87b1b12020-05-06 01:18:28 -0500109*** Keywords ***
110
Anvesh Kumar9f421212020-04-27 01:42:50 -0500111Suite Setup Execution
Anves Kumar rayankula322e3aa2020-06-01 00:28:48 -0500112 [Documentation] Suite setup execution.
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500113
114 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -0500115 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500116 Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -0500117 Redfish.Logout
118
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500119
120Restore 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 rayankula67921142020-05-14 04:03:24 -0500124 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
125 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500126 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500127 Redfish.Logout
128
129
130Test 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
138Suite Teardown Execution
139 [Documentation] Do suite teardown task.
140
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500141 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -0500142 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5}
143 Redfish.Logout
144
145Verify 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 rayankula67921142020-05-14 04:03:24 -0500155