blob: bcbca0e7596e5353aa417bce6ef6c6a06fb87c82 [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
53 ... Restore Default Password For Root User AND FFDC On Test Case Fail
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 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 rayankulaa87b1b12020-05-06 01:18:28 -050090*** Keywords ***
91
Anvesh Kumar9f421212020-04-27 01:42:50 -050092Suite Setup Execution
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050093 [Documentation] Test setup execution.
94
95 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -050096 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 0}
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -050097 Valid Length OPENBMC_PASSWORD min_length=8
Anvesh Kumar9f421212020-04-27 01:42:50 -050098 Redfish.Logout
99
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500100
101Restore Default Password For Root User
102 [Documentation] Restore default password for root user (i.e. 0penBmc).
103
104 # Set default password for root user.
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500105 Redfish.Patch /redfish/v1/AccountService/Accounts/${OPENBMC_USERNAME}
106 ... body={'Password': '${OPENBMC_PASSWORD}'} valid_status_codes=[${HTTP_OK}]
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500107 # Verify that root user is able to run Redfish command using default password.
Anvesh Kumar9f421212020-04-27 01:42:50 -0500108 Redfish.Logout
109
110
111Test Teardown Execution
112 [Documentation] Do test teardown task.
113
114 Redfish.Login
115 Wait Until Keyword Succeeds 1 min 10 sec Restore Default Password For Root User
116 FFDC On Test Case Fail
117
118
119Suite Teardown Execution
120 [Documentation] Do suite teardown task.
121
Anves Kumar rayankulaa87b1b12020-05-06 01:18:28 -0500122 Redfish.login
Anvesh Kumar9f421212020-04-27 01:42:50 -0500123 Redfish.Patch /redfish/v1/AccountService/ body={"AccountLockoutThreshold": 5}
124 Redfish.Logout
125
126Verify Root Password Expired
127 [Documentation] Checking whether root password expired or not.
128
129 Create Session openbmc ${AUTH_URI}
130 ${headers}= Create Dictionary Content-Type=application/json
131 @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
132 ${data}= Create Dictionary data=@{credentials}
133 ${resp}= Post Request openbmc /login data=${data} headers=${headers}
134 ${json}= To JSON ${resp.content}
135 Should Contain ${json["extendedMessage"]} POST the new password
136 Post Request openbmc /xyz/openbmc_project/user/root/action/SetPassword
137 ... data={"data":["0penBmc006"]} headers=${headers}
Anves Kumar rayankula67921142020-05-14 04:03:24 -0500138