blob: d38492aa6401a232e97e7c77601560eba1c240e7 [file] [log] [blame]
Sivas SRR6aa101f2019-02-19 22:31:55 -06001*** Settings ***
2Documentation Test Redfish user account.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -05007Resource ../../lib/bmc_redfish_utils.robot
Sivas SRR6aa101f2019-02-19 22:31:55 -06008
manashsarma654cbc12021-09-23 02:28:12 -05009Library SSHLibrary
10
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -050011Test Setup Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -060012Test Teardown Test Teardown Execution
13
Sandhya Somashekar37122b62019-06-18 06:02:02 -050014*** Variables ***
15
16${account_lockout_duration} ${30}
17${account_lockout_threshold} ${3}
18
Sivas SRR6aa101f2019-02-19 22:31:55 -060019** Test Cases **
20
21Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060022 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060023 [Tags] Verify_AccountService_Available
24
George Keishing97c93942019-03-04 12:45:07 -060025 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060026 Should Be Equal As Strings ${resp} ${True}
27
Sandhya Somashekara83fb472019-08-29 02:26:21 -050028Verify Redfish User Persistence After Reboot
29 [Documentation] Verify Redfish user persistence after reboot.
30 [Tags] Verify_Redfish_User_Persistence_After_Reboot
31
32 # Create Redfish users.
33 Redfish Create User admin_user TestPwd123 Administrator ${True}
34 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060035 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050036
37 # Reboot BMC.
38 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050039
40 # Verify users after reboot.
41 Redfish Verify User admin_user TestPwd123 Administrator ${True}
42 Redfish Verify User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060043 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050044
45 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -060046 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
47 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
48 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekara83fb472019-08-29 02:26:21 -050049
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060050Redfish Create and Verify Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050051 [Documentation] Create Redfish users with various roles.
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060052 [Tags] Redfish_Create_and_Verify_Users
53 [Template] Redfish Create And Verify User
54
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050055 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050056 admin_user TestPwd123 Administrator ${True}
57 operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060058 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060059
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050060Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050061 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050062 [Tags] Verify_Redfish_User_with_Wrong_Password
63 [Template] Verify Redfish User with Wrong Password
64
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050065 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050066 admin_user TestPwd123 Administrator ${True} alskjhfwurh
67 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Anusha Dathatri4062b442020-02-03 04:39:15 -060068 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050069
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050070Verify Login with Deleted Redfish Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050071 [Documentation] Verify login with deleted Redfish Users.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050072 [Tags] Verify_Login_with_Deleted_Redfish_Users
73 [Template] Verify Login with Deleted Redfish User
74
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050075 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050076 admin_user TestPwd123 Administrator ${True}
77 operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060078 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050079
George Keishinge0c5ec32019-06-13 09:45:29 -050080Verify User Creation Without Enabling It
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050081 [Documentation] Verify User Creation Without Enabling it.
George Keishinge0c5ec32019-06-13 09:45:29 -050082 [Tags] Verify_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050083 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050084
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050085 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050086 admin_user TestPwd123 Administrator ${False}
87 operator_user TestPwd123 Operator ${False}
Anusha Dathatri4062b442020-02-03 04:39:15 -060088 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050089
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050090Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -050091 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050092 [Tags] Verify_User_Creation_With_Invalid_Role_Id
93
94 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -060095 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050096 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
97
98 # Create specified user.
99 ${payload}= Create Dictionary
100 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600101 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500102 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
103
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500104Verify Error Upon Creating Same Users With Different Privileges
105 [Documentation] Verify error upon creating same users with different privileges.
106 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
107
108 Redfish Create User test_user TestPwd123 Administrator ${True}
109
110 # Create specified user.
111 ${payload}= Create Dictionary
112 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600113 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500114 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
115
Anusha Dathatri466816f2020-01-30 05:12:36 -0600116 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500117
118Verify Modifying User Attributes
119 [Documentation] Verify modifying user attributes.
120 [Tags] Verify_Modifying_User_Attributes
121
122 # Create Redfish users.
123 Redfish Create User admin_user TestPwd123 Administrator ${True}
124 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600125 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500126
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500127 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600128 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500129 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
130
131 # Update admin_user username using Redfish.
132 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600133 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500134
135 # Update operator_user password using Redfish.
136 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600137 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500138
Anusha Dathatri4062b442020-02-03 04:39:15 -0600139 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500140 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600141 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500142
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500143 # Verify users after updating
144 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
145 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600146 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500147
148 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600149 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
150 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
151 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500152
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500153Verify User Account Locked
154 [Documentation] Verify user account locked upon trying with invalid password.
155 [Tags] Verify_User_Account_Locked
156
157 Redfish Create User admin_user TestPwd123 Administrator ${True}
158
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500159 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
160 ... AccountLockoutDuration=${account_lockout_duration}
161 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500162
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500163 Redfish.Logout
164
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500165 # Make ${account_lockout_threshold} failed login attempts.
166 Repeat Keyword ${account_lockout_threshold} times
167 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
168
169 # Verify that legitimate login fails due to lockout.
170 Run Keyword And Expect Error InvalidCredentialsError*
171 ... Redfish.Login admin_user TestPwd123
172
173 # Wait for lockout duration to expire and then verify that login works.
174 Sleep ${account_lockout_duration}s
175 Redfish.Login admin_user TestPwd123
176
177 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500178
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500179 Redfish.Login
180
Anusha Dathatri466816f2020-01-30 05:12:36 -0600181 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500182
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500183Verify Admin User Privilege
184 [Documentation] Verify admin user privilege.
185 [Tags] Verify_Admin_User_Privilege
186
187 Redfish Create User admin_user TestPwd123 Administrator ${True}
188 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600189 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500190
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500191 Redfish.Logout
192
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500193 # Change role ID of operator user with admin user.
194 # Login with admin user.
195 Redfish.Login admin_user TestPwd123
196
197 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600198 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500199
200 # Verify modified user.
201 Redfish Verify User operator_user TestPwd123 Administrator ${True}
202
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500203 Redfish.Logout
204 Redfish.Login admin_user TestPwd123
205
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500206 # Change password of 'user' user with admin user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600207 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500208
209 # Verify modified user.
Anusha Dathatri4062b442020-02-03 04:39:15 -0600210 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500211
Anusha Dathatri466816f2020-01-30 05:12:36 -0600212 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
213 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
214 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500215
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500216Verify Operator User Privilege
217 [Documentation] Verify operator user privilege.
218 [Tags] Verify_operator_User_Privilege
219
220 Redfish Create User admin_user TestPwd123 Administrator ${True}
221 Redfish Create User operator_user TestPwd123 Operator ${True}
222
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500223 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500224 # Login with operator user.
225 Redfish.Login operator_user TestPwd123
226
George Keishing093c1bd2020-02-10 09:47:34 -0600227 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500228 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500229
230 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600231 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500232 ... valid_status_codes=[${HTTP_FORBIDDEN}]
233
234 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500235
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500236 Redfish.Login
237
Anusha Dathatri466816f2020-01-30 05:12:36 -0600238 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
239 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500240
241
Anusha Dathatri4062b442020-02-03 04:39:15 -0600242Verify ReadOnly User Privilege
243 [Documentation] Verify ReadOnly user privilege.
244 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500245
Anusha Dathatri4062b442020-02-03 04:39:15 -0600246 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500247 Redfish.Logout
248
249 # Login with read_only user.
250 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500251
252 # Read system level data.
253 ${system_model}= Redfish_Utils.Get Attribute
254 ... ${SYSTEM_BASE_URI} Model
255
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500256 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500257 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600258 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500259
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500260
Anusha Dathatri466816f2020-01-30 05:12:36 -0600261Verify Minimum Password Length For Redfish User
262 [Documentation] Verify minimum password length for new and existing user.
263 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
264
265 ${user_name}= Set Variable testUser
266
267 # Make sure the user account in question does not already exist.
268 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
269 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
270
271 # Try to create a user with invalid length password.
272 ${payload}= Create Dictionary
273 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
274 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
275 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
276
277 # Create specified user with valid length password.
278 Set To Dictionary ${payload} Password UserPwd1
279 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
280 ... valid_status_codes=[${HTTP_CREATED}]
281
282 # Try to change to an invalid password.
283 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
284 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
285
286 # Change to a valid password.
287 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
288
289 # Verify login.
290 Redfish.Logout
291 Redfish.Login ${user_name} UserPwd1
292 Redfish.Logout
293 Redfish.Login
294 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
295
296
Tony Lee94335f42021-02-04 15:16:39 +0800297Verify Standard User Roles Defined By Redfish
298 [Documentation] Verify standard user roles defined by Redfish.
299 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
300
301 ${member_list}= Redfish_Utils.Get Member List
302 ... /redfish/v1/AccountService/Roles
303
304 @{roles}= Create List
305 ... /redfish/v1/AccountService/Roles/Administrator
306 ... /redfish/v1/AccountService/Roles/Operator
307 ... /redfish/v1/AccountService/Roles/ReadOnly
308
309 List Should Contain Sub List ${member_list} ${roles}
310
311 # The standard roles are:
312
313 # | Role name | Assigned privileges |
314 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
315 # | Operator | Login, ConfigureComponents, ConfigureSelf |
316 # | ReadOnly | Login, ConfigureSelf |
317
318 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
319 @{operator}= Create List Login ConfigureComponents ConfigureSelf
320 @{readOnly}= Create List Login ConfigureSelf
321
322 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
323 ... readOnly_privileges=${readOnly}
324
325 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
326 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
327
328 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
329 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
330
331 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
332 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
333
334
manashsarma4910aa22021-07-26 09:12:36 -0500335Verify Error While Deleting Root User
336 [Documentation] Verify error while deleting root user.
337 [Tags] Verify_Error_While_Deleting_Root_User
338
339 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
340
341
manashsarma654cbc12021-09-23 02:28:12 -0500342Verify SSH Login Access With Admin User
343 [Documentation] Verify that admin user does not have SSH login access.
344 [Tags] Verify_SSH_Login_Access_With_Admin_User
345
346 # Create an admin User.
347 Redfish Create User new_admin TestPwd1 Administrator ${True}
348
349 # Attempt SSH login with admin user.
350 SSHLibrary.Open Connection ${OPENBMC_HOST}
351 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
352 Should Be Equal ${status} ${False}
353
354
Sivas SRR6aa101f2019-02-19 22:31:55 -0600355*** Keywords ***
356
Sivas SRR6aa101f2019-02-19 22:31:55 -0600357Test Teardown Execution
358 [Documentation] Do the post test teardown.
359
Anusha Dathatridb769702020-02-12 01:02:30 -0600360 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500361 FFDC On Test Case Fail
362
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600363
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500364Redfish Create User
365 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500366 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500367
368 # Description of argument(s):
369 # username The username to be created.
370 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500371 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500372 # (e.g. "Administrator", "Operator", etc.).
373 # enabled Indicates whether the username being created
374 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500375 # login_check Checks user login for created user.
376 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500377
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500378 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600379 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500380 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
381
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500382 # Create specified user.
383 ${payload}= Create Dictionary
384 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600385 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500386 ... valid_status_codes=[${HTTP_CREATED}]
387
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500388 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600389 # openbmc/phosphor-user-manager#4
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500390 ${cmd}= Catenate /usr/sbin/faillock --user USER --reset
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600391 Bmc Execute Command ${cmd}
392
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500393 # Verify login with created user.
394 ${status}= Run Keyword If '${login_check}' == '${True}'
395 ... Verify Redfish User Login ${username} ${password}
396 Run Keyword If '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500397
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500398 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500399 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600400 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500401 Should Be Equal ${role_id} ${role_config}
402
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500403
404Redfish Verify User
405 [Documentation] Redfish user verification.
406 [Arguments] ${username} ${password} ${role_id} ${enabled}
407
408 # Description of argument(s):
409 # username The username to be created.
410 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500411 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500412 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500413 # enabled Indicates whether the username being created
414 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500415
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500416 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500417 # Doing a check of the returned status.
418 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500419
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500420 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500421 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600422 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500423 Should Be Equal ${role_id} ${role_config}
424
425
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500426Verify Redfish User Login
427 [Documentation] Verify Redfish login with given user id.
428 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
429 [Arguments] ${username} ${password}
430
431 # Description of argument(s):
432 # username Login username.
433 # password Login password.
434
435 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600436 # We don't really care if the current session is flushed out since we are going to login
437 # with new credential in next.
438 Run Keyword And Ignore Error Redfish.Logout
439
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500440 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
441 [Return] ${status}
442
443
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600444Redfish Create And Verify User
445 [Documentation] Redfish create and verify user.
446 [Arguments] ${username} ${password} ${role_id} ${enabled}
447
448 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500449 # username The username to be created.
450 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500451 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500452 # (e.g. "Administrator", "Operator", etc.).
453 # enabled Indicates whether the username being created
454 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600455
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500456 # Example:
457 #{
458 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
459 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
460 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
461 #"Description": "User Account",
462 #"Enabled": true,
463 #"Id": "test1",
464 #"Links": {
465 # "Role": {
466 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
467 # }
468 #},
469
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500470 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600471
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500472 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600473
474 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600475 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500476
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500477Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500478 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500479 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
480
481 # Description of argument(s):
482 # username The username to be created.
483 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500484 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500485 # (e.g. "Administrator", "Operator", etc.).
486 # enabled Indicates whether the username being created
487 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500488 # wrong_password Any invalid password.
489
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500490 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500491
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500492 Redfish.Logout
493
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500494 # Attempt to login with created user with invalid password.
495 Run Keyword And Expect Error InvalidCredentialsError*
496 ... Redfish.Login ${username} ${wrong_password}
497
498 Redfish.Login
499
500 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600501 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500502
503
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500504Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500505 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500506 [Arguments] ${username} ${password} ${role_id} ${enabled}
507
508 # Description of argument(s):
509 # username The username to be created.
510 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500511 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500512 # (e.g. "Administrator", "Operator", etc.).
513 # enabled Indicates whether the username being created
514 # should be enabled (${True}, ${False}).
515
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500516 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500517
518 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600519 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500520
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500521 Redfish.Logout
522
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500523 # Attempt to login with deleted user account.
524 Run Keyword And Expect Error InvalidCredentialsError*
525 ... Redfish.Login ${username} ${password}
526
527 Redfish.Login
528
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500529
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500530Verify Create User Without Enabling
531 [Documentation] Verify Create User Without Enabling.
532 [Arguments] ${username} ${password} ${role_id} ${enabled}
533
534 # Description of argument(s):
535 # username The username to be created.
536 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500537 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500538 # (e.g. "Administrator", "Operator", etc.).
539 # enabled Indicates whether the username being created
540 # should be enabled (${True}, ${False}).
541
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500542 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500543
544 Redfish.Logout
545
546 # Login with created user.
547 Run Keyword And Expect Error InvalidCredentialsError*
548 ... Redfish.Login ${username} ${password}
549
550 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500551
552 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600553 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500554