blob: b1f21769bdc3d2b92a1c68b62f1d36c481964bda [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.
George Keishing5236ec52022-01-31 12:07:58 -0600218 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500219
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
nagarjunb2261267e92022-03-30 21:04:16 +0530390 ${cmd}= Catenate test -f /usr/sbin/faillock && /usr/sbin/faillock --user USER --reset
391 ... || /usr/sbin/pam_tally2 -u ${username} --reset
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600392 Bmc Execute Command ${cmd}
393
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500394 # Verify login with created user.
395 ${status}= Run Keyword If '${login_check}' == '${True}'
396 ... Verify Redfish User Login ${username} ${password}
397 Run Keyword If '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500398
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500399 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500400 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600401 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500402 Should Be Equal ${role_id} ${role_config}
403
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500404
405Redfish Verify User
406 [Documentation] Redfish user verification.
407 [Arguments] ${username} ${password} ${role_id} ${enabled}
408
409 # Description of argument(s):
410 # username The username to be created.
411 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500412 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500413 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500414 # enabled Indicates whether the username being created
415 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500416
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500417 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500418 # Doing a check of the returned status.
419 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500420
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500421 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500422 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600423 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500424 Should Be Equal ${role_id} ${role_config}
425
426
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500427Verify Redfish User Login
428 [Documentation] Verify Redfish login with given user id.
429 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
430 [Arguments] ${username} ${password}
431
432 # Description of argument(s):
433 # username Login username.
434 # password Login password.
435
436 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600437 # We don't really care if the current session is flushed out since we are going to login
438 # with new credential in next.
439 Run Keyword And Ignore Error Redfish.Logout
440
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500441 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
442 [Return] ${status}
443
444
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600445Redfish Create And Verify User
446 [Documentation] Redfish create and verify user.
447 [Arguments] ${username} ${password} ${role_id} ${enabled}
448
449 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500450 # username The username to be created.
451 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500452 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500453 # (e.g. "Administrator", "Operator", etc.).
454 # enabled Indicates whether the username being created
455 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600456
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500457 # Example:
458 #{
459 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
460 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
461 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
462 #"Description": "User Account",
463 #"Enabled": true,
464 #"Id": "test1",
465 #"Links": {
466 # "Role": {
467 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
468 # }
469 #},
470
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500471 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600472
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500473 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600474
475 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600476 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500477
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500478Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500479 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500480 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
481
482 # Description of argument(s):
483 # username The username to be created.
484 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500485 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500486 # (e.g. "Administrator", "Operator", etc.).
487 # enabled Indicates whether the username being created
488 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500489 # wrong_password Any invalid password.
490
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500491 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500492
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500493 Redfish.Logout
494
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500495 # Attempt to login with created user with invalid password.
496 Run Keyword And Expect Error InvalidCredentialsError*
497 ... Redfish.Login ${username} ${wrong_password}
498
499 Redfish.Login
500
501 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600502 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500503
504
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500505Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500506 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500507 [Arguments] ${username} ${password} ${role_id} ${enabled}
508
509 # Description of argument(s):
510 # username The username to be created.
511 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500512 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500513 # (e.g. "Administrator", "Operator", etc.).
514 # enabled Indicates whether the username being created
515 # should be enabled (${True}, ${False}).
516
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500517 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500518
519 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600520 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500521
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500522 Redfish.Logout
523
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500524 # Attempt to login with deleted user account.
525 Run Keyword And Expect Error InvalidCredentialsError*
526 ... Redfish.Login ${username} ${password}
527
528 Redfish.Login
529
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500530
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500531Verify Create User Without Enabling
532 [Documentation] Verify Create User Without Enabling.
533 [Arguments] ${username} ${password} ${role_id} ${enabled}
534
535 # Description of argument(s):
536 # username The username to be created.
537 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500538 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500539 # (e.g. "Administrator", "Operator", etc.).
540 # enabled Indicates whether the username being created
541 # should be enabled (${True}, ${False}).
542
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500543 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500544
545 Redfish.Logout
546
547 # Login with created user.
548 Run Keyword And Expect Error InvalidCredentialsError*
549 ... Redfish.Login ${username} ${password}
550
551 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500552
553 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600554 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500555