blob: c0e69f8c7b397eace0c66926c4e584dd506854db [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
Sandhya Somashekara83fb472019-08-29 02:26:21 -050031 # Create Redfish users.
32 Redfish Create User admin_user TestPwd123 Administrator ${True}
33 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060034 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050035
36 # Reboot BMC.
37 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050038
39 # Verify users after reboot.
40 Redfish Verify User admin_user TestPwd123 Administrator ${True}
41 Redfish Verify User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060042 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050043
44 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -060045 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
46 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
47 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekara83fb472019-08-29 02:26:21 -050048
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050049Redfish Create and Verify Admin User
50 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050051 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060052 [Template] Redfish Create And Verify User
53
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050054 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050055 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050056
57
58Redfish Create and Verify Operator User
59 [Documentation] Create a Redfish user with operator role and verify.
60 [Tags] Redfish_Create_and_Verify_Operator_User
61 [Template] Redfish Create And Verify User
62
63 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050064 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050065
66
67Redfish Create and Verify Readonly User
68 [Documentation] Create a Redfish user with readonly role and verify.
69 [Tags] Redfish_Create_and_Verify_Readonly_User
70 [Template] Redfish Create And Verify User
71
72 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -060073 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060074
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050075
76Verify Redfish Admin User With Wrong Password
77 [Documentation] Verify Redfish admin user with wrong password.
78 [Tags] Verify_Redfish_Admin_User_With_Wrong_Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050079 [Template] Verify Redfish User with Wrong Password
80
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050081 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050082 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050083
84
85Verify Redfish Operator User with Wrong Password
86 [Documentation] Verify Redfish operator user with wrong password.
87 [Tags] Verify_Redfish_Operator_User_with_Wrong_Password
88 [Template] Verify Redfish User with Wrong Password
89
90 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050091 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050092
93
94Verify Redfish Readonly User With Wrong Password
95 [Documentation] Verify Redfish readonly user with wrong password.
96 [Tags] Verify_Redfish_Readonly_User_With_Wrong_Password
97 [Template] Verify Redfish User with Wrong Password
98
99 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600100 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500101
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500102
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500103Verify Login with Deleted Redfish Admin User
104 [Documentation] Verify login with deleted Redfish admin user.
105 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500106 [Template] Verify Login with Deleted Redfish User
107
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500108 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500109 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500110
111
112Verify Login with Deleted Redfish Operator User
113 [Documentation] Verify login with deleted Redfish operator user.
114 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
115 [Template] Verify Login with Deleted Redfish User
116
117 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500118 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500119
120
121Verify Login with Deleted Redfish Readonly User
122 [Documentation] Verify login with deleted Redfish readonly user.
123 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
124 [Template] Verify Login with Deleted Redfish User
125
126 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600127 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500128
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500129
130Verify Admin User Creation Without Enabling It
131 [Documentation] Verify admin user creation without enabling it.
132 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500133 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500134
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500135 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500136 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500137
138
139Verify Operator User Creation Without Enabling It
140 [Documentation] Verify operator user creation without enabling it.
141 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
142 [Template] Verify Create User Without Enabling
143
144 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500145 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500146
147
148Verify Readonly User Creation Without Enabling It
149 [Documentation] Verify readonly user creation without enabling it.
150 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
151 [Template] Verify Create User Without Enabling
152
153 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600154 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500155
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500156
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500157Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500158 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500159 [Tags] Verify_User_Creation_With_Invalid_Role_Id
160
161 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600162 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500163 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
164
165 # Create specified user.
166 ${payload}= Create Dictionary
167 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600168 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500169 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
170
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500171Verify Error Upon Creating Same Users With Different Privileges
172 [Documentation] Verify error upon creating same users with different privileges.
173 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
174
175 Redfish Create User test_user TestPwd123 Administrator ${True}
176
177 # Create specified user.
178 ${payload}= Create Dictionary
179 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600180 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500181 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
182
Anusha Dathatri466816f2020-01-30 05:12:36 -0600183 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500184
185Verify Modifying User Attributes
186 [Documentation] Verify modifying user attributes.
187 [Tags] Verify_Modifying_User_Attributes
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500188 # Create Redfish users.
189 Redfish Create User admin_user TestPwd123 Administrator ${True}
190 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600191 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500192
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500193 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600194 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500195 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
196
197 # Update admin_user username using Redfish.
198 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600199 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500200
201 # Update operator_user password using Redfish.
202 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600203 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500204
Anusha Dathatri4062b442020-02-03 04:39:15 -0600205 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500206 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600207 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500208
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500209 # Verify users after updating
210 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
211 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600212 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500213
214 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600215 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
216 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
217 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500218
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500219Verify User Account Locked
220 [Documentation] Verify user account locked upon trying with invalid password.
221 [Tags] Verify_User_Account_Locked
222
223 Redfish Create User admin_user TestPwd123 Administrator ${True}
224
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500225 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
226 ... AccountLockoutDuration=${account_lockout_duration}
227 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500228
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500229 Redfish.Logout
230
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500231 # Make ${account_lockout_threshold} failed login attempts.
232 Repeat Keyword ${account_lockout_threshold} times
233 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
234
235 # Verify that legitimate login fails due to lockout.
236 Run Keyword And Expect Error InvalidCredentialsError*
237 ... Redfish.Login admin_user TestPwd123
238
239 # Wait for lockout duration to expire and then verify that login works.
240 Sleep ${account_lockout_duration}s
241 Redfish.Login admin_user TestPwd123
242
243 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500244
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500245 Redfish.Login
246
Anusha Dathatri466816f2020-01-30 05:12:36 -0600247 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500248
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500249Verify Admin User Privilege
250 [Documentation] Verify admin user privilege.
251 [Tags] Verify_Admin_User_Privilege
252
253 Redfish Create User admin_user TestPwd123 Administrator ${True}
254 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600255 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500256
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500257 Redfish.Logout
258
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500259 # Change role ID of operator user with admin user.
260 # Login with admin user.
261 Redfish.Login admin_user TestPwd123
262
263 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600264 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500265
266 # Verify modified user.
267 Redfish Verify User operator_user TestPwd123 Administrator ${True}
268
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500269 Redfish.Logout
270 Redfish.Login admin_user TestPwd123
271
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500272 # Change password of 'user' user with admin user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600273 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500274
275 # Verify modified user.
Anusha Dathatri4062b442020-02-03 04:39:15 -0600276 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500277
Anusha Dathatri466816f2020-01-30 05:12:36 -0600278 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
279 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
280 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500281
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500282Verify Operator User Privilege
283 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600284 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500285
286 Redfish Create User admin_user TestPwd123 Administrator ${True}
287 Redfish Create User operator_user TestPwd123 Operator ${True}
288
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500289 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500290 # Login with operator user.
291 Redfish.Login operator_user TestPwd123
292
George Keishing093c1bd2020-02-10 09:47:34 -0600293 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500294 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500295
296 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600297 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500298 ... valid_status_codes=[${HTTP_FORBIDDEN}]
299
300 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500301
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500302 Redfish.Login
303
Anusha Dathatri466816f2020-01-30 05:12:36 -0600304 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
305 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500306
307
Anusha Dathatri4062b442020-02-03 04:39:15 -0600308Verify ReadOnly User Privilege
309 [Documentation] Verify ReadOnly user privilege.
310 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500311
Anusha Dathatri4062b442020-02-03 04:39:15 -0600312 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500313 Redfish.Logout
314
315 # Login with read_only user.
316 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500317
318 # Read system level data.
319 ${system_model}= Redfish_Utils.Get Attribute
320 ... ${SYSTEM_BASE_URI} Model
321
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500322 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500323 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600324 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500325
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500326
Anusha Dathatri466816f2020-01-30 05:12:36 -0600327Verify Minimum Password Length For Redfish User
328 [Documentation] Verify minimum password length for new and existing user.
329 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
330
331 ${user_name}= Set Variable testUser
332
333 # Make sure the user account in question does not already exist.
334 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
335 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
336
337 # Try to create a user with invalid length password.
338 ${payload}= Create Dictionary
339 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
340 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
341 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
342
343 # Create specified user with valid length password.
344 Set To Dictionary ${payload} Password UserPwd1
345 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
346 ... valid_status_codes=[${HTTP_CREATED}]
347
348 # Try to change to an invalid password.
349 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
350 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
351
352 # Change to a valid password.
353 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
354
355 # Verify login.
356 Redfish.Logout
357 Redfish.Login ${user_name} UserPwd1
358 Redfish.Logout
359 Redfish.Login
360 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
361
362
Tony Lee94335f42021-02-04 15:16:39 +0800363Verify Standard User Roles Defined By Redfish
364 [Documentation] Verify standard user roles defined by Redfish.
365 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
366
367 ${member_list}= Redfish_Utils.Get Member List
368 ... /redfish/v1/AccountService/Roles
369
370 @{roles}= Create List
371 ... /redfish/v1/AccountService/Roles/Administrator
372 ... /redfish/v1/AccountService/Roles/Operator
373 ... /redfish/v1/AccountService/Roles/ReadOnly
374
375 List Should Contain Sub List ${member_list} ${roles}
376
377 # The standard roles are:
378
379 # | Role name | Assigned privileges |
380 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
381 # | Operator | Login, ConfigureComponents, ConfigureSelf |
382 # | ReadOnly | Login, ConfigureSelf |
383
384 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
385 @{operator}= Create List Login ConfigureComponents ConfigureSelf
386 @{readOnly}= Create List Login ConfigureSelf
387
388 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
389 ... readOnly_privileges=${readOnly}
390
391 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
392 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
393
394 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
395 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
396
397 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
398 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
399
400
manashsarma4910aa22021-07-26 09:12:36 -0500401Verify Error While Deleting Root User
402 [Documentation] Verify error while deleting root user.
403 [Tags] Verify_Error_While_Deleting_Root_User
404
405 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
406
407
manashsarma654cbc12021-09-23 02:28:12 -0500408Verify SSH Login Access With Admin User
409 [Documentation] Verify that admin user does not have SSH login access.
410 [Tags] Verify_SSH_Login_Access_With_Admin_User
411
412 # Create an admin User.
413 Redfish Create User new_admin TestPwd1 Administrator ${True}
414
415 # Attempt SSH login with admin user.
416 SSHLibrary.Open Connection ${OPENBMC_HOST}
417 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
418 Should Be Equal ${status} ${False}
419
420
Sivas SRR6aa101f2019-02-19 22:31:55 -0600421*** Keywords ***
422
Sivas SRR6aa101f2019-02-19 22:31:55 -0600423Test Teardown Execution
424 [Documentation] Do the post test teardown.
425
Anusha Dathatridb769702020-02-12 01:02:30 -0600426 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500427 FFDC On Test Case Fail
428
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600429
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500430Redfish Create User
431 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500432 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500433
434 # Description of argument(s):
435 # username The username to be created.
436 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500437 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500438 # (e.g. "Administrator", "Operator", etc.).
439 # enabled Indicates whether the username being created
440 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500441 # login_check Checks user login for created user.
442 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500443
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500444 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600445 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500446 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
447
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500448 # Create specified user.
449 ${payload}= Create Dictionary
450 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600451 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500452 ... valid_status_codes=[${HTTP_CREATED}]
453
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500454 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600455 # openbmc/phosphor-user-manager#4
nagarjunb2261267e92022-03-30 21:04:16 +0530456 ${cmd}= Catenate test -f /usr/sbin/faillock && /usr/sbin/faillock --user USER --reset
457 ... || /usr/sbin/pam_tally2 -u ${username} --reset
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600458 Bmc Execute Command ${cmd}
459
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500460 # Verify login with created user.
461 ${status}= Run Keyword If '${login_check}' == '${True}'
462 ... Verify Redfish User Login ${username} ${password}
463 Run Keyword If '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500464
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500465 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500466 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600467 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500468 Should Be Equal ${role_id} ${role_config}
469
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500470
471Redfish Verify User
472 [Documentation] Redfish user verification.
473 [Arguments] ${username} ${password} ${role_id} ${enabled}
474
475 # Description of argument(s):
476 # username The username to be created.
477 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500478 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500479 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500480 # enabled Indicates whether the username being created
481 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500482
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500483 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500484 # Doing a check of the returned status.
485 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500486
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500487 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500488 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600489 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500490 Should Be Equal ${role_id} ${role_config}
491
492
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500493Verify Redfish User Login
494 [Documentation] Verify Redfish login with given user id.
495 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
496 [Arguments] ${username} ${password}
497
498 # Description of argument(s):
499 # username Login username.
500 # password Login password.
501
502 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600503 # We don't really care if the current session is flushed out since we are going to login
504 # with new credential in next.
505 Run Keyword And Ignore Error Redfish.Logout
506
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500507 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
508 [Return] ${status}
509
510
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600511Redfish Create And Verify User
512 [Documentation] Redfish create and verify user.
513 [Arguments] ${username} ${password} ${role_id} ${enabled}
514
515 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500516 # username The username to be created.
517 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500518 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500519 # (e.g. "Administrator", "Operator", etc.).
520 # enabled Indicates whether the username being created
521 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600522
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500523 # Example:
524 #{
525 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
526 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
527 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
528 #"Description": "User Account",
529 #"Enabled": true,
530 #"Id": "test1",
531 #"Links": {
532 # "Role": {
533 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
534 # }
535 #},
536
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500537 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600538
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500539 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600540
541 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600542 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500543
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500544Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500545 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500546 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
547
548 # Description of argument(s):
549 # username The username to be created.
550 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500551 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500552 # (e.g. "Administrator", "Operator", etc.).
553 # enabled Indicates whether the username being created
554 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500555 # wrong_password Any invalid password.
556
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500557 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500558
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500559 Redfish.Logout
560
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500561 # Attempt to login with created user with invalid password.
562 Run Keyword And Expect Error InvalidCredentialsError*
563 ... Redfish.Login ${username} ${wrong_password}
564
565 Redfish.Login
566
567 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600568 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500569
570
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500571Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500572 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500573 [Arguments] ${username} ${password} ${role_id} ${enabled}
574
575 # Description of argument(s):
576 # username The username to be created.
577 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500578 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500579 # (e.g. "Administrator", "Operator", etc.).
580 # enabled Indicates whether the username being created
581 # should be enabled (${True}, ${False}).
582
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500583 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500584
585 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600586 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500587
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500588 Redfish.Logout
589
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500590 # Attempt to login with deleted user account.
591 Run Keyword And Expect Error InvalidCredentialsError*
592 ... Redfish.Login ${username} ${password}
593
594 Redfish.Login
595
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500596
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500597Verify Create User Without Enabling
598 [Documentation] Verify Create User Without Enabling.
599 [Arguments] ${username} ${password} ${role_id} ${enabled}
600
601 # Description of argument(s):
602 # username The username to be created.
603 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500604 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500605 # (e.g. "Administrator", "Operator", etc.).
606 # enabled Indicates whether the username being created
607 # should be enabled (${True}, ${False}).
608
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500609 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500610
611 Redfish.Logout
612
613 # Login with created user.
614 Run Keyword And Expect Error InvalidCredentialsError*
615 ... Redfish.Login ${username} ${password}
616
617 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500618
619 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600620 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500621