blob: 4416216418c1ec2487b7b8db3e0359ba51fccda9 [file] [log] [blame]
Rahul Maheshwari51dee262019-03-06 23:36:21 -06001*** Settings ***
2Documentation Test IPMI and Redfish combinations for user management.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/ipmi_client.robot
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -05008Library ../lib/ipmi_utils.py
Rahul Maheshwari51dee262019-03-06 23:36:21 -06009
10Test Setup Test Setup Execution
11Test Teardown Test Teardown Execution
12
13
14*** Variables ***
15
16${valid_password} 0penBmc1
Rahul Maheshwaricf2336e2019-03-15 00:49:13 -050017${valid_password2} 0penBmc2
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -050018${admin_level_priv} 4
19${operator_level_priv} 3
Ashwini Chandrappa6fac2892021-12-13 07:03:35 -060020${max_num_users} ${17}
Rahul Maheshwari51dee262019-03-06 23:36:21 -060021
22** Test Cases **
23
24Create Admin Redfish User And Verify Login Via IPMI
25 [Documentation] Create user using redfish and verify via IPMI.
26 [Tags] Create_Admin_Redfish_User_And_Verify_Login_Via_IPMI
27
28 ${random_username}= Generate Random String 8 [LETTERS]
29 Set Test Variable ${random_username}
30
31 ${payload}= Create Dictionary
32 ... UserName=${random_username} Password=${valid_password}
33 ... RoleId=Administrator Enabled=${True}
34 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload}
35 ... valid_status_codes=[${HTTP_CREATED}]
36
Sushma M M97fccae2020-07-27 14:55:19 -050037 # Delay added for created new user password to get set.
38 Sleep 5s
39
Rahul Maheshwari51dee262019-03-06 23:36:21 -060040 Verify IPMI Username And Password ${random_username} ${valid_password}
41
42
Rahul Maheshwaricf2336e2019-03-15 00:49:13 -050043Update User Password Via Redfish And Verify Using IPMI
44 [Documentation] Update user password via Redfish and verify using IPMI.
45 [Tags] Update_User_Password_Via_Redfish_And_Verify_Using_IPMI
46
47 # Create user using Redfish.
48 ${random_username}= Generate Random String 8 [LETTERS]
49 Set Test Variable ${random_username}
50
51 ${payload}= Create Dictionary
52 ... UserName=${random_username} Password=${valid_password}
53 ... RoleId=Administrator Enabled=${True}
54 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload}
55 ... valid_status_codes=[${HTTP_CREATED}]
56
57 # Update user password using Redfish.
58 ${payload}= Create Dictionary Password=${valid_password2}
59 Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload}
60
61 # Verify that IPMI command works with new password and fails with older password.
62 Verify IPMI Username And Password ${random_username} ${valid_password2}
63
Anusha Dathatri652fc742020-02-05 05:14:21 -060064 Run Keyword And Expect Error *Error: Unable to establish IPMI*
Rahul Maheshwaricf2336e2019-03-15 00:49:13 -050065 ... Verify IPMI Username And Password ${random_username} ${valid_password}
66
67
Rahul Maheshwariff63ac02019-03-29 10:25:21 -050068Update User Privilege Via Redfish And Verify Using IPMI
69 [Documentation] Update user privilege via Redfish and verify using IPMI.
70 [Tags] Update_User_Privilege_Via_Redfish_And_Verify_Using_IPMI
71
72 # Create user using Redfish with admin privilege.
73 ${random_username}= Generate Random String 8 [LETTERS]
74 Set Test Variable ${random_username}
75
76 ${payload}= Create Dictionary
77 ... UserName=${random_username} Password=${valid_password}
78 ... RoleId=Administrator Enabled=${True}
79 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload}
80 ... valid_status_codes=[${HTTP_CREATED}]
81
82 # Update user privilege to operator using Redfish.
83 ${payload}= Create Dictionary RoleId=Operator
84 Redfish.Patch /redfish/v1/AccountService/Accounts/${random_username} body=&{payload}
85
86 # Verify new user privilege level via IPMI.
Tony Leec317c982020-05-20 15:46:35 +080087 ${resp}= Run IPMI Standard Command user list ${CHANNEL_NUMBER}
Rahul Maheshwariff63ac02019-03-29 10:25:21 -050088
89 # Example of response data:
90 # ID Name Callin Link Auth IPMI Msg Channel Priv Limit
91 # 1 root false true true ADMINISTRATOR
92 # 2 OAvCxjMv false true true OPERATOR
93 # 3 true false false NO ACCESS
94 # ..
95 # ..
96 # 15 true false false NO ACCESS
97
98 ${user_info}=
99 ... Get Lines Containing String ${resp} ${random_username}
100 Should Contain ${user_info} OPERATOR
101
102
Rahul Maheshwaricf2336e2019-03-15 00:49:13 -0500103Delete User Via Redfish And Verify Using IPMI
104 [Documentation] Delete user via redfish and verify using IPMI.
105 [Tags] Delete_User_Via_Redfish_And_Verify_Using_IPMI
106
107 # Create user using Redfish.
108 ${random_username}= Generate Random String 8 [LETTERS]
109 Set Test Variable ${random_username}
110
111 ${payload}= Create Dictionary
112 ... UserName=${random_username} Password=${valid_password}
113 ... RoleId=Administrator Enabled=${True}
114 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload}
115 ... valid_status_codes=[${HTTP_CREATED}]
116
117 # Delete user using Redfish.
118 Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username}
119
120 # Verify that IPMI command fails with deleted user.
Anusha Dathatri652fc742020-02-05 05:14:21 -0600121 Run Keyword And Expect Error *Error: Unable to establish IPMI*
Rahul Maheshwaricf2336e2019-03-15 00:49:13 -0500122 ... Verify IPMI Username And Password ${random_username} ${valid_password}
123
124
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500125Create IPMI User And Verify Login Via Redfish
126 [Documentation] Create user using IPMI and verify user login via Redfish.
127 [Tags] Create_IPMI_User_And_Verify_Login_Via_Redfish
128
129 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
130 ... ${valid_password} ${admin_level_priv}
131
Anusha Dathatri4d894652020-02-12 04:08:10 -0600132 Redfish.Logout
133
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500134 # Verify user login using Redfish.
135 Redfish.Login ${username} ${valid_password}
Anusha Dathatri4d894652020-02-12 04:08:10 -0600136 Redfish.Logout
137
138 Redfish.Login
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500139
140
141Update User Password Via IPMI And Verify Using Redfish
142 [Documentation] Update user password using IPMI and verify user
143 ... login via Redfish.
144 [Tags] Update_User_Password_Via_IPMI_And_Verify_Using_Redfish
145
146 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
147 ... ${valid_password} ${admin_level_priv}
148
149 # Update user password using IPMI.
150 Run IPMI Standard Command
151 ... user set password ${userid} ${valid_password2}
152
Anusha Dathatri4d894652020-02-12 04:08:10 -0600153 Redfish.Logout
154
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500155 # Verify that user login works with new password using Redfish.
156 Redfish.Login ${username} ${valid_password2}
Anusha Dathatri4d894652020-02-12 04:08:10 -0600157 Redfish.Logout
158
159 Redfish.Login
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500160
161
162Update User Privilege Via IPMI And Verify Using Redfish
163 [Documentation] Update user privilege via IPMI and verify using Redfish.
164 [Tags] Update_User_Privilege_Via_IPMI_And_Verify_Using_Redfish
165
166 # Create user using IPMI with admin privilege.
167 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
168 ... ${valid_password} ${admin_level_priv}
169
170 # Change user privilege to opetrator using IPMI.
171 Run IPMI Standard Command
Tony Lee69ed33e2020-05-20 17:15:02 +0800172 ... user priv ${userid} ${operator_level_priv} ${CHANNEL_NUMBER}
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500173
174 # Verify new user privilege level via Redfish.
175 ${privilege}= Redfish_Utils.Get Attribute
176 ... /redfish/v1/AccountService/Accounts/${username} RoleId
177 Should Be Equal ${privilege} Operator
178
179
180Delete User Via IPMI And Verify Using Redfish
181 [Documentation] Delete user using IPMI and verify error while doing
182 ... user login with deleted user via Redfish.
183 [Tags] Delete_User_Via_IPMI_And_Verify_Using_Redfish
184
185 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
186 ... ${valid_password} ${admin_level_priv}
187
188 # Delete IPMI User.
189 Run IPMI Standard Command user set name ${userid} ""
190
191 # Verify that Redfish login fails with deleted user.
192 Run Keyword And Expect Error *InvalidCredentialsError*
193 ... Redfish.Login ${username} ${valid_password}
194
195
Rahul Maheshwari3e61ce62019-06-18 02:09:01 -0500196Verify Failure To Exceed Max Number Of Users
197 [Documentation] Verify failure attempting to exceed the max number of user accounts.
198 [Tags] Verify_Failure_To_Exceed_Max_Number_Of_Users
199 [Teardown] Run Keywords Test Teardown Execution AND Delete All Non Root IPMI User
200
201 # Get existing user count.
202 ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/
203 ${current_user_count}= Get From Dictionary ${resp.dict} Members@odata.count
204
205 ${payload}= Create Dictionary Password=${valid_password}
206 ... RoleId=Administrator Enabled=${True}
207
208 # Create users to reach maximum users count (i.e. 15 users).
209 FOR ${INDEX} IN RANGE ${current_user_count} ${max_num_users}
210 ${random_username}= Generate Random String 8 [LETTERS]
211 Set To Dictionary ${payload} UserName ${random_username}
212 Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
213 ... valid_status_codes=[${HTTP_CREATED}]
214 END
215
Ashwini Chandrappa6fac2892021-12-13 07:03:35 -0600216 # Verify error while creating 18th user.
Rahul Maheshwari3e61ce62019-06-18 02:09:01 -0500217 ${random_username}= Generate Random String 8 [LETTERS]
218 Set To Dictionary ${payload} UserName ${random_username}
219 Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
220 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
221
222
Anusha Dathatri9ecaaf42020-01-20 04:50:13 -0600223Create IPMI User Without Any Privilege And Verify Via Redfish
224 [Documentation] Create user using IPMI without privilege and verify via redfish.
225 [Tags] Create_IPMI_User_Without_Any_Privilege_And_Verify_Via_Redfish
226
227 ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
228 ... ${valid_password}
229
230 # Verify new user privilege level via Redfish.
231 ${privilege}= Redfish_Utils.Get Attribute
232 ... /redfish/v1/AccountService/Accounts/${username} RoleId
233 Valid Value privilege ['NoAccess']
234
Rahul Maheshwari51dee262019-03-06 23:36:21 -0600235*** Keywords ***
236
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500237IPMI Create Random User Plus Password And Privilege
238 [Documentation] Create random IPMI user with given password and privilege
239 ... level.
Anusha Dathatri9ecaaf42020-01-20 04:50:13 -0600240 [Arguments] ${password} ${privilege}=0
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500241
242 # Description of argument(s):
243 # password Password to be assigned for the user.
244 # privilege Privilege level for the user (e.g. "1", "2", "3", etc.).
245
246 # Create IPMI user.
247 ${random_username}= Generate Random String 8 [LETTERS]
248 Set Suite Variable ${random_username}
249
250 ${random_userid}= Evaluate random.randint(2, 15) modules=random
251 IPMI Create User ${random_userid} ${random_username}
252
253 # Set given password for newly created user.
254 Run IPMI Standard Command
255 ... user set password ${random_userid} ${password}
256
257 # Enable IPMI user.
258 Run IPMI Standard Command user enable ${random_userid}
259
260 # Set given privilege and enable IPMI messaging for newly created user.
Anusha Dathatri9ecaaf42020-01-20 04:50:13 -0600261 Run Keyword If '${privilege}' != '0'
262 ... Set Channel Access ${random_userid} ipmi=on privilege=${privilege}
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500263
264 [Return] ${random_username} ${random_userid}
265
266
Rahul Maheshwari51dee262019-03-06 23:36:21 -0600267Test Setup Execution
268 [Documentation] Do test case setup tasks.
269
270 Redfish.Login
271
272
273Test Teardown Execution
274 [Documentation] Do the post test teardown.
275
276 FFDC On Test Case Fail
277 # Delete the test user.
278 Run Keyword And Ignore Error
279 ... Redfish.Delete /redfish/v1/AccountService/Accounts/${random_username}
280
281 Redfish.Logout