blob: dc97acdb3c7c5c0bb206dc702e4156781318450f [file] [log] [blame]
Sivas SRR6aa101f2019-02-19 22:31:55 -06001*** Settings ***
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05002Documentation Test suite for verifying Redfish admin, readonly operation user accounts.
Sivas SRR6aa101f2019-02-19 22:31:55 -06003
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
Sridevi Rameshcf0c8b02025-09-17 06:22:35 -050014Test Tags User_Account
15
Sandhya Somashekar37122b62019-06-18 06:02:02 -050016*** Variables ***
17
18${account_lockout_duration} ${30}
19${account_lockout_threshold} ${3}
George Keishingf8e18192023-07-05 14:26:27 +053020${ssh_status} ${True}
21
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -050022*** Test Cases ***
Sivas SRR6aa101f2019-02-19 22:31:55 -060023
24Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060025 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060026 [Tags] Verify_AccountService_Available
27
George Keishing97c93942019-03-04 12:45:07 -060028 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060029 Should Be Equal As Strings ${resp} ${True}
30
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050031
32Verify Redfish Admin User Persistence After Reboot
33 [Documentation] Verify Redfish admin user persistence after reboot.
34 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
35 [Setup] Run Keywords Redfish.Login AND
36 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
37 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
38 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050039
40 # Reboot BMC.
41 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050042
43 # Verify users after reboot.
44 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050045
46
47Verify Redfish Operator User Persistence After Reboot
48 [Documentation] Verify Redfish operator user persistence after reboot.
49 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
50 [Setup] Run Keywords Redfish.Login AND
51 ... Redfish Create User operator_user TestPwd123 Operator ${True}
52 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
53 ... AND Test Teardown Execution
54
55 # Reboot BMC.
56 Redfish OBMC Reboot (off) stack_mode=normal
57
58 # Verify users after reboot.
Sandhya Somashekara83fb472019-08-29 02:26:21 -050059 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050060
61
62Verify Redfish Readonly User Persistence After Reboot
63 [Documentation] Verify Redfish readonly user persistence after reboot.
64 [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot
65 [Setup] Run Keywords Redfish.Login AND
66 ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
67 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
68 ... AND Test Teardown Execution
69
70 # Reboot BMC.
71 Redfish OBMC Reboot (off) stack_mode=normal
72
73 # Verify users after reboot.
Anusha Dathatri4062b442020-02-03 04:39:15 -060074 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050075
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050076Redfish Create and Verify Admin User
77 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050078 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060079 [Template] Redfish Create And Verify User
80
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050081 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050082 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050083
84
85Redfish Create and Verify Operator User
86 [Documentation] Create a Redfish user with operator role and verify.
87 [Tags] Redfish_Create_and_Verify_Operator_User
88 [Template] Redfish Create And Verify User
89
90 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050091 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050092
93
94Redfish Create and Verify Readonly User
95 [Documentation] Create a Redfish user with readonly role and verify.
96 [Tags] Redfish_Create_and_Verify_Readonly_User
97 [Template] Redfish Create And Verify User
98
99 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600100 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -0600101
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500102
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500103Verify Redfish Admin User Login With Wrong Password
104 [Documentation] Verify Redfish create admin user with valid password and make sure
105 ... admin user failed to login with wrong password.
106 [Tags] Verify_Redfish_Admin_User_Login_With_Wrong_Password
107 [Template] Verify Redfish User Login With Wrong Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500108
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500109 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500110 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500111
112
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500113Verify Redfish Operator User Login With Wrong Password
114 [Documentation] Verify Redfish create operator user with valid password and make sure
George Keishingeeec7352025-10-14 09:58:59 +0530115 ... operator user failed to login with wrong password.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500116 [Tags] Verify_Redfish_Operator_User_Login_With_Wrong_Password
117 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500118
119 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500120 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500121
122
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500123Verify Redfish Readonly User Login With Wrong Password
124 [Documentation] Verify Redfish create readonly user with valid password and make sure
125 ... readonly user failed to login with wrong password.
126 [Tags] Verify_Redfish_Readonly_User_Login_With_Wrong_Password
127 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500128
129 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600130 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500131
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500132
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500133Verify Login with Deleted Redfish Admin User
134 [Documentation] Verify login with deleted Redfish admin user.
135 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500136 [Template] Verify Login with Deleted Redfish User
137
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500138 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500139 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500140
141
142Verify Login with Deleted Redfish Operator User
143 [Documentation] Verify login with deleted Redfish operator user.
144 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
145 [Template] Verify Login with Deleted Redfish User
146
147 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500148 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500149
150
151Verify Login with Deleted Redfish Readonly User
152 [Documentation] Verify login with deleted Redfish readonly user.
153 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
154 [Template] Verify Login with Deleted Redfish User
155
156 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600157 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500158
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500159
160Verify Admin User Creation Without Enabling It
161 [Documentation] Verify admin user creation without enabling it.
162 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500163 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500164
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500165 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500166 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500167
168
169Verify Operator User Creation Without Enabling It
170 [Documentation] Verify operator user creation without enabling it.
171 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
172 [Template] Verify Create User Without Enabling
173
174 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500175 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500176
177
178Verify Readonly User Creation Without Enabling It
179 [Documentation] Verify readonly user creation without enabling it.
180 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
181 [Template] Verify Create User Without Enabling
182
183 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600184 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500185
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500186
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500187Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500188 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500189 [Tags] Verify_User_Creation_With_Invalid_Role_Id
190
191 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600192 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500193 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
194
195 # Create specified user.
196 ${payload}= Create Dictionary
197 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600198 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500199 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
200
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500201Verify Error Upon Creating Same Users With Different Privileges
202 [Documentation] Verify error upon creating same users with different privileges.
203 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
204
205 Redfish Create User test_user TestPwd123 Administrator ${True}
206
207 # Create specified user.
208 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500209 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600210 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500211 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
212
Anusha Dathatri466816f2020-01-30 05:12:36 -0600213 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500214
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500215
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500216Verify Modifying User Attributes
217 [Documentation] Verify modifying user attributes.
218 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500219
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500220 # Create Redfish users.
221 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600222 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500223
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500224 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600225 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500226 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
227
228 # Update admin_user username using Redfish.
229 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600230 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530231 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500232
Anusha Dathatri4062b442020-02-03 04:39:15 -0600233 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500234 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600235 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530236 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500237
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500238 # Verify users after updating
239 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500240 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500241
242 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600243 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600244 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500245
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500246
247Verify Modifying Operator User Attributes
248 [Documentation] Verify modifying operator user attributes.
249 [Tags] Verify_Modifying_Operator_User_Attributes
250 [Setup] Run Keywords Redfish.Login AND
251 ... Redfish Create User operator_user TestPwd123 Operator ${True}
252 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
253 ... AND Test Teardown Execution
254
255 # Update operator_user password using Redfish.
256 ${payload}= Create Dictionary Password=NewTestPwd123
257 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
258
259 # Verify users after updating
260 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
261
262
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500263Verify User Account Locked
264 [Documentation] Verify user account locked upon trying with invalid password.
265 [Tags] Verify_User_Account_Locked
266
267 Redfish Create User admin_user TestPwd123 Administrator ${True}
268
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500269 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
270 ... AccountLockoutDuration=${account_lockout_duration}
271 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530272 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500273
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500274 Redfish.Logout
275
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500276 # Make ${account_lockout_threshold} failed login attempts.
277 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500278 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500279
280 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500281 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500282 ... Redfish.Login admin_user TestPwd123
283
Vidya-Kalasappanavar344c21d2025-07-01 12:21:05 -0500284 # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout
285 # ... then verify that login works.
286 ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5
287 Sleep ${total_wait_duartion}s
288
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500289 Redfish.Login admin_user TestPwd123
290
291 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500292
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500293 Redfish.Login
294
Anusha Dathatri466816f2020-01-30 05:12:36 -0600295 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500296
aravinth0510746884b2022-09-29 16:04:07 +0000297
298Verify User Account Unlock
299 [Documentation] Verify manually unlocking the account before lockout time
300 [Tags] Verify_User_Account_Unlock
George Keishinga36926b2023-05-17 21:54:34 +0530301 [Teardown] Run Keywords Redfish.Logout
302 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000303 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
304 ... AND SSHLibrary.Close All Connections
305
306 Redfish Create User test_user TestPwd123 Administrator ${True}
307
308 ${payload}= Create Dictionary
309 ... AccountLockoutThreshold=${account_lockout_threshold}
310 ... AccountLockoutDuration=${account_lockout_duration}
311 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
312
313 Redfish.Logout
314
315 # Make ${account_lockout_threshold} failed login attempts.
316 Repeat Keyword ${account_lockout_threshold} times
317 ... Run Keyword And Expect Error InvalidCredentialsError*
318 ... Redfish.Login test_user abc123
319
320 # Ensure SSH Login with locked account gets failed
321 SSHLibrary.Open Connection ${OPENBMC_HOST}
322 Run Keyword And Expect Error Authentication failed*
323 ... SSHLibrary.Login test_user TestPwd123
324
325 # Verify that legitimate login fails due to lockout.
326 Run Keyword And Expect Error InvalidCredentialsError*
327 ... Redfish.Login test_user TestPwd123
328
329 ${payload}= Create Dictionary Locked=${FALSE}
330
331 # Manually unlock the account before lockout threshold expires
332 Redfish.Login
333 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
334 Redfish.Logout
335
336 # Try redfish login with the recently unlocked account
337 Redfish.Login test_user TestPwd123
338
339 # Try SSH login with the unlocked account
340 SSHLibrary.Open Connection ${OPENBMC_HOST}
341 SSHLibrary.Login test_user TestPwd123
342
343
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500344Verify Admin User Privilege
345 [Documentation] Verify admin user privilege.
346 [Tags] Verify_Admin_User_Privilege
347
348 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600349 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500350
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500351 Redfish.Logout
352
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500353 Redfish.Login admin_user TestPwd123
354
355 # Change password of 'readonly' user with admin user.
356 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
357
358 # Verify modified user.
359 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
360
361 # Note: Delete user would work here because a root login is
362 # performed as part of "Redfish Verify User" keyword's teardown.
363 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
364 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
365
366
367Verify Operator User Role Change Using Admin Privilege User
368 [Documentation] Verify operator user role change using admin privilege user
369 [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User
370
371 Redfish Create User admin_user TestPwd123 Administrator ${True}
372 Redfish Create User operator_user TestPwd123 Operator ${True}
373
374 Redfish.Logout
375
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500376 # Change role ID of operator user with admin user.
377 # Login with admin user.
378 Redfish.Login admin_user TestPwd123
379
380 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600381 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500382
383 # Verify modified user.
384 Redfish Verify User operator_user TestPwd123 Administrator ${True}
385
Anusha Dathatri466816f2020-01-30 05:12:36 -0600386 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
387 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500388
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500389
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500390Verify Operator User Privilege
391 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600392 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500393
394 Redfish Create User admin_user TestPwd123 Administrator ${True}
395 Redfish Create User operator_user TestPwd123 Operator ${True}
396
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500397 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500398 # Login with operator user.
399 Redfish.Login operator_user TestPwd123
400
George Keishing093c1bd2020-02-10 09:47:34 -0600401 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500402 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500403
404 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600405 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500406 ... valid_status_codes=[${HTTP_FORBIDDEN}]
407
408 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500409
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500410 Redfish.Login
411
Anusha Dathatri466816f2020-01-30 05:12:36 -0600412 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
413 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500414
415
Anusha Dathatri4062b442020-02-03 04:39:15 -0600416Verify ReadOnly User Privilege
417 [Documentation] Verify ReadOnly user privilege.
418 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500419
Anusha Dathatri4062b442020-02-03 04:39:15 -0600420 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500421 Redfish.Logout
422
423 # Login with read_only user.
424 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500425
426 # Read system level data.
427 ${system_model}= Redfish_Utils.Get Attribute
428 ... ${SYSTEM_BASE_URI} Model
429
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500430 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500431 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600432 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500433
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500434
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500435Verify Minimum Password Length For Redfish Admin And Readonly User
436 [Documentation] Verify minimum password length for new and existing admin or
437 ... readonly user.
438 [Template] Verify Minimum Password Length For Redfish User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600439
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500440 #username role_id
441 admin_user Administrator
442 readonly_user ReadOnly
Anusha Dathatri466816f2020-01-30 05:12:36 -0600443
444
Tony Lee94335f42021-02-04 15:16:39 +0800445Verify Standard User Roles Defined By Redfish
446 [Documentation] Verify standard user roles defined by Redfish.
447 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
448
449 ${member_list}= Redfish_Utils.Get Member List
450 ... /redfish/v1/AccountService/Roles
451
452 @{roles}= Create List
453 ... /redfish/v1/AccountService/Roles/Administrator
454 ... /redfish/v1/AccountService/Roles/Operator
455 ... /redfish/v1/AccountService/Roles/ReadOnly
456
457 List Should Contain Sub List ${member_list} ${roles}
458
459 # The standard roles are:
460
461 # | Role name | Assigned privileges |
462 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
463 # | Operator | Login, ConfigureComponents, ConfigureSelf |
464 # | ReadOnly | Login, ConfigureSelf |
465
466 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
467 @{operator}= Create List Login ConfigureComponents ConfigureSelf
468 @{readOnly}= Create List Login ConfigureSelf
469
470 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
471 ... readOnly_privileges=${readOnly}
472
473 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
474 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
475
476 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
477 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
478
479 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
480 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
481
482
manashsarma4910aa22021-07-26 09:12:36 -0500483Verify Error While Deleting Root User
484 [Documentation] Verify error while deleting root user.
485 [Tags] Verify_Error_While_Deleting_Root_User
486
487 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
488
489
manashsarma654cbc12021-09-23 02:28:12 -0500490Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530491 [Documentation] Verify that admin user have SSH login access.
492 ... By default, admin should have access but there could be
493 ... case where admin user shell access is restricted by design
494 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500495 [Tags] Verify_SSH_Login_Access_With_Admin_User
496
Nandakumar Ba4887be2025-11-05 19:27:31 +0530497 #Create an admin user and verify SSH login.
498 Create Admin User And Verify SSH Login
manashsarma654cbc12021-09-23 02:28:12 -0500499
George Keishinge8015b32022-09-19 09:38:47 -0500500 Redfish.Login
501 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
502
Nandakumar-AMI45830792025-10-30 13:15:15 +0530503Verify SSH Login Is Revoked For Deleted User
504 [Documentation] Verify SSH login access is revoked for deleted User.
505 [Tags] Verify_SSH_Login_Is_Revoked_For_Deleted_User
506
507 #Create an admin user and verify SSH login.
508 Create Admin User And Verify SSH Login
509
510 #Login with root user.
511 Redfish.Login
512
513 # Delete the admin user.
514 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
515 ... valid_status_codes=[${HTTP_OK}]
516
517 # Attempt SSH login with Deleted user.
518 SSHLibrary.Open Connection ${OPENBMC_HOST}
519 Run Keyword And Expect Error Authentication failed*
520 ... SSHLibrary.Login new_admin TestPwd1
manashsarma654cbc12021-09-23 02:28:12 -0500521
aravinth0510746884b2022-09-29 16:04:07 +0000522Verify Configure BasicAuth Enable And Disable
523 [Documentation] Verify configure basicauth enable and disable
524 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
525 [Template] Template For Configure Auth Methods
526
527 # auth_method
528 BasicAuth
529 XToken
530
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500531
532Redfish Create and Verify Admin User With Invalid Password Format
533 [Documentation] Create a admin user with invalid password format and verify.
534 [Template] Create User With Unsupported Password Format And Verify
535 [Tags] Redfish_Create_and_Verify_Admin_User_With_Invalid_Password_Format
536
537 #username role_id password
538 admin_user Administrator snellens
539 admin_user Administrator 10000001
540 admin_user Administrator 12345678
541 admin_user Administrator abcdefgh
542 admin_user Administrator abf12345
543 admin_user Administrator helloworld
544 admin_user Administrator HELLOWORLD
545 admin_user Administrator &$%**!*@
546 admin_user Administrator Dictation
547
548
549Redfish Create and Verify Readonly User With Invalid Password Format
550 [Documentation] Create a readonly user with invalid password format and verify.
551 [Template] Create User With Unsupported Password Format And Verify
552 [Tags] Redfish_Create_and_Verify_Readonly_User_With_Invalid_Password_Format
553
554 #username role_id password
555 readonly_user ReadOnly snellens
556 readonly_user ReadOnly 10000001
557 readonly_user ReadOnly 12345678
558 readonly_user ReadOnly abcdefgh
559 readonly_user ReadOnly abf12345
560 readonly_user ReadOnly helloworld
561 readonly_user ReadOnly HELLOWORLD
562 readonly_user ReadOnly &$%**!*@
563 readonly_user ReadOnly Dictation
564
565
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500566Verify Admin And Readonly User Password Is Not Same As Username
567 [Documentation] Verify that admin and readonly user creation is failed if
568 ... password is same as username.
569 [Template] Create User With Unsupported Password Format And Verify
570 [Tags] Verify_Admin_And_Readonly_User_Password_Is_Not_Same_As_Username
571
572 #username role_id password
573 AdminUser1 Administrator AdminUser1
574 ReadOnlyUser1 ReadOnly ReadOnlyUser1
575
IanLaiAMI597181e2025-10-07 12:03:59 +0800576Verify AccountService Unsupported Methods
577 [Documentation] Verify Unsupported methods of AccountService
578 [Tags] Verify_AccountService_Unsupported_Methods
579
580 # Put operation on Account Services
581 Redfish.Put /redfish/v1/AccountService
582 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
583
584 # Post operation on Account Services
585 Redfish.Post /redfish/v1/AccountService
586 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
587
588 # Delete operation on Account Services
589 Redfish.Delete /redfish/v1/AccountService
590 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
591
Ian Lai63c31422025-10-27 12:32:24 +0800592Verify AccountService Roles Unsupported Methods
593 [Documentation] Verify Unsupported methods of AccountService/Roles
594 [Tags] Verify_AccountService_Roles_Unsupported_Methods
595
596 # Put operation on Account Services Roles
597 Redfish.Put /redfish/v1/AccountService/Roles
598 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
599
600 # Post operation on Account Services Roles
601 Redfish.Post /redfish/v1/AccountService/Roles
602 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
603
604 # Delete operation on Account Services Roles
605 Redfish.Delete /redfish/v1/AccountService/Roles
606 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
607
608 # Patch operation on Account Services Roles
609 Redfish.Patch /redfish/v1/AccountService/Roles
610 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
611
Nandakumar-AMI45830792025-10-30 13:15:15 +0530612Verify AccountService Roles Instance With Unsupported Methods
613 [Documentation] Verify Instance Roles for AccountService and Unsupported Methods
614 [Tags] Verify_AccountService_Roles_Instance_With_Unsupported_Methods
615
616 # GET Administrator Role Instance
617 Redfish.Get /redfish/v1/AccountService/Roles/Administrator
618 ... valid_status_codes=[${HTTP_OK}]
619
620 # GET Operator Role Instance
621 Redfish.Get /redfish/v1/AccountService/Roles/Operator
622 ... valid_status_codes=[${HTTP_OK}]
623
624 # GET ReadOnly RoleInstance
625 Redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
626 ... valid_status_codes=[${HTTP_OK}]
627
628 # Post operation on Account Service Roles Instance
629 Redfish.Post /redfish/v1/AccountService/Roles/Administrator
630 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
631
632 # Put operation on Account Service Roles Instance
633 Redfish.Put /redfish/v1/AccountService/Roles/Administrator
634 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
635
636 # Patch operation on Account Service Roles Instance
637 Redfish.Patch /redfish/v1/AccountService/Roles/Administrator
638 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
639
640 #Delete operation on Account Service Roles Instance
641 Redfish.Delete /redfish/v1/AccountService/Roles/Administrator
642 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500643
Sivas SRR6aa101f2019-02-19 22:31:55 -0600644*** Keywords ***
645
Sivas SRR6aa101f2019-02-19 22:31:55 -0600646Test Teardown Execution
647 [Documentation] Do the post test teardown.
648
Anusha Dathatridb769702020-02-12 01:02:30 -0600649 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500650 FFDC On Test Case Fail
651
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600652
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500653Redfish Create User
654 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500655 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500656
657 # Description of argument(s):
658 # username The username to be created.
659 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500660 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500661 # (e.g. "Administrator", "Operator", etc.).
662 # enabled Indicates whether the username being created
663 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500664 # login_check Checks user login for created user.
665 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500666
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500667 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600668 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500669 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
670
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500671 # Create specified user.
672 ${payload}= Create Dictionary
673 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600674 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500675 ... valid_status_codes=[${HTTP_CREATED}]
676
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500677 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600678 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500679 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000680
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600681 Bmc Execute Command ${cmd}
682
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500683 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530684 IF '${login_check}' == '${True}'
685 ${status}= Run Keyword And Return Status
686 ... Verify Redfish User Login ${username} ${password}
687 ELSE
688 ${status}= Set Variable ${False}
689 END
690
691 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500692
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500693 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500694 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600695 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500696 Should Be Equal ${role_id} ${role_config}
697
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500698
699Redfish Verify User
700 [Documentation] Redfish user verification.
701 [Arguments] ${username} ${password} ${role_id} ${enabled}
702
703 # Description of argument(s):
704 # username The username to be created.
705 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500706 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500707 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500708 # enabled Indicates whether the username being created
709 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500710
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500711 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500712 # Doing a check of the returned status.
713 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500714
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500715 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500716 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600717 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500718 Should Be Equal ${role_id} ${role_config}
719
720
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500721Verify Redfish User Login
722 [Documentation] Verify Redfish login with given user id.
723 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
724 [Arguments] ${username} ${password}
725
726 # Description of argument(s):
727 # username Login username.
728 # password Login password.
729
730 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600731 # We don't really care if the current session is flushed out since we are going to login
732 # with new credential in next.
733 Run Keyword And Ignore Error Redfish.Logout
734
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500735 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530736 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500737
738
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600739Redfish Create And Verify User
740 [Documentation] Redfish create and verify user.
741 [Arguments] ${username} ${password} ${role_id} ${enabled}
742
743 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500744 # username The username to be created.
745 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500746 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500747 # (e.g. "Administrator", "Operator", etc.).
748 # enabled Indicates whether the username being created
749 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600750
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500751 # Example:
752 #{
753 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
754 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
755 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
756 #"Description": "User Account",
757 #"Enabled": true,
758 #"Id": "test1",
759 #"Links": {
760 # "Role": {
761 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
762 # }
763 #},
764
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500765 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600766
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500767 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600768
769 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600770 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500771
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500772Verify Redfish User Login With Wrong Password
773 [Documentation] Verify Redfish User failed to login with wrong password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500774 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
775
776 # Description of argument(s):
777 # username The username to be created.
778 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500779 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500780 # (e.g. "Administrator", "Operator", etc.).
781 # enabled Indicates whether the username being created
782 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500783 # wrong_password Any invalid password.
784
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500785 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500786
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500787 Redfish.Logout
788
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500789 # Attempt to login with created user with invalid password.
790 Run Keyword And Expect Error InvalidCredentialsError*
791 ... Redfish.Login ${username} ${wrong_password}
792
793 Redfish.Login
794
795 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600796 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500797
798
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500799Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500800 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500801 [Arguments] ${username} ${password} ${role_id} ${enabled}
802
803 # Description of argument(s):
804 # username The username to be created.
805 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500806 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500807 # (e.g. "Administrator", "Operator", etc.).
808 # enabled Indicates whether the username being created
809 # should be enabled (${True}, ${False}).
810
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500811 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500812
813 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600814 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500815
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500816 Redfish.Logout
817
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500818 # Attempt to login with deleted user account.
819 Run Keyword And Expect Error InvalidCredentialsError*
820 ... Redfish.Login ${username} ${password}
821
822 Redfish.Login
823
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500824
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500825Verify Create User Without Enabling
826 [Documentation] Verify Create User Without Enabling.
827 [Arguments] ${username} ${password} ${role_id} ${enabled}
828
829 # Description of argument(s):
830 # username The username to be created.
831 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500832 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500833 # (e.g. "Administrator", "Operator", etc.).
834 # enabled Indicates whether the username being created
835 # should be enabled (${True}, ${False}).
836
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500837 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500838
839 Redfish.Logout
840
841 # Login with created user.
842 Run Keyword And Expect Error InvalidCredentialsError*
843 ... Redfish.Login ${username} ${password}
844
845 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500846
847 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600848 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500849
aravinth0510746884b2022-09-29 16:04:07 +0000850Template For Configure Auth Methods
851 [Documentation] Template to configure auth methods.
852 [Arguments] ${auth_method}
853 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
854
855 # Description of Argument(s):
856 # authmethods The authmethod setting which needs to be
857 # set in account service URI.
858 # valid values BasicAuth, XToken.
859
860 Get AuthMethods Default Values ${auth_method}
861
862 # Patch basicauth to TRUE
863 Configure AuthMethods ${auth_method}=${TRUE}
864
George Keishing79fc7f02025-05-02 00:37:49 +0530865 IF "${auth_method}" == "XToken"
866 Check XToken Works Fine ${HTTP_OK}
867 ELSE
868 Check BasicAuth Works Fine ${HTTP_OK}
869 END
aravinth0510746884b2022-09-29 16:04:07 +0000870
871 # Patch basicauth to FALSE
872 Configure AuthMethods ${auth_method}=${FALSE}
873
George Keishing79fc7f02025-05-02 00:37:49 +0530874 IF "${auth_method}" == "BasicAuth"
875 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
876 ELSE
877 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
878 END
aravinth0510746884b2022-09-29 16:04:07 +0000879
880Configure AuthMethods
881 [Documentation] Enable/disable authmethod types.
882 [Arguments] &{authmethods}
883
884 # Description of argument(s):
885 # authmethods The authmethod setting which needs to be
886 # set in account service URI.
887 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
888 # This will set the value of "XToken" and "BasicAuth"
889 # property in accountservice uri to TRUE.
890
891 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
892 ${oem}= Create Dictionary OpenBMC=${openbmc}
893 ${payload}= Create Dictionary Oem=${oem}
894
895 # Setting authmethod properties using Redfish session based auth
896 ${status}= Run Keyword And Return Status
897 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
898 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
899
George Keishingc63bfe62023-11-15 19:09:59 +0530900 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000901 IF ${status}==${FALSE}
902 # Payload dictionary pre-process to match json formatting
903 ${payload}= Convert To String ${payload}
904 ${payload}= Replace String ${payload} ' "
905 ${payload}= Replace String ${payload} False false
906 ${payload}= Replace String ${payload} True true
907
908 # Curl Command Framing for PATCH authmethod
909 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
910 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
911 ... -H 'content-type:application/json' -H 'If-Match:*'
912 ... -d '${payload}'
913 ${rc} ${out}= Run And Return Rc And Output ${cmd}
914
915 # Check the response of curl command is 200 or 204
916 ${check_no_content}=
917 ... Run Keyword and Return Status Should Contain ${out} 204
918 ${check_ok}=
919 ... Run Keyword and Return Status Should Contain ${out} 200
920 Pass Execution If ${check_no_content}==${TRUE}
921 ... OR ${check_ok}==${TRUE}
922 END
923
924
925Get AuthMethods Default Values
926 [Documentation] Get enabled/disabled status of all authmethods
927 ... from Redfish account service URI
928 [Arguments] ${authmethod}
929
930 # Description of argument(s):
931 # authmethod The authmethod property whose value needs to be
932 # retrieved from account service URI.
933 # Usage Example Get AuthMethods Default Values BasicAuth
934 # returns >> ${TRUE}
935 # Example:
936 # {
937 # "@odata.id": "/redfish/v1/AccountService",
938 # (...)
939 # "Oem": {
940 # "OpenBMC": {
941 # "AuthMethods": {
942 # "BasicAuth": true,
943 # "Cookie": true,
944 # "SessionToken": true,
945 # "TLS": true,
946 # "XToken": true
947 # }
948 # }
949 # }
950 # }
951
952 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
953 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
954 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
955 Set Test Variable ${initial_value}
956
957Check XToken Works Fine
958 [Documentation] Verify Xtoken works fine.
959 [Arguments] ${status_code}
960
961 # Description of Argument(s):
962 # status_code : 200, 401.
963
964 # Verify xtoken auth works for xtoken
965 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
966 ... valid_status_codes=[${status_code}]
967
968Check BasicAuth Works Fine
969 [Documentation] Verify Basic Auth works fine.
970 [Arguments] ${status_code}
971
972 # Description of Argument(s):
973 # status_code : 200, 401.
974
975 # Verify basic auth works based on basic auth.
976 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
977 ... ${AUTH_URI}/redfish/v1/AccountService
978 ${rc} ${out}= Run And Return Rc And Output ${cmd}
979
980 # Check the response of curl command is 200/401
981 Should Contain ${out} ${status_code}
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500982
983
984Create User With Unsupported Password Format And Verify
985 [Documentation] Create admin or readonly user with unsupported password format
986 ... and verify.
987 [Arguments] ${username} ${role_id} ${password}
988
989 # Description of argument(s):
990 # username The username to be created.
991 # role_id The role ID of the user to be created
992 # (e.g. "Administrator", "ReadOnly").
993 # password The password to be assigned.
994 # Unsupported password format are sequential characters,
995 # sequential digits, palindrome digits, palindrome characters,
996 # only uppercase letters, only lowercase letters, only digits,
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500997 # only characters, not a dictionary word, username and password
998 # should not be same.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500999
1000 # Make sure the user account in question does not already exist.
1001 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
1002 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1003
1004 # Create specified user with invalid password format.
1005 ${payload}= Create Dictionary
1006 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${True}
1007 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1008 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -05001009
1010
1011Verify Minimum Password Length For Redfish User
1012 [Documentation] Verify minimum password length for new and existing admin or
1013 ... readonly user.
1014 [Arguments] ${user_name} ${role_id}
1015
1016 # Description of argument(s):
1017 # user_name The username to be created.
1018 # role_id The role ID of the user to be created.
1019
1020 # Make sure the user account in question does not already exist.
1021 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
1022 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1023
1024 # Try to create a user with invalid length password.
1025 ${payload}= Create Dictionary
1026 ... UserName=${user_name} Password=UserPwd RoleId=${role_id} Enabled=${True}
1027 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1028 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1029
1030 # Create specified user with valid length password.
1031 Set To Dictionary ${payload} Password UserPwd1
1032 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1033 ... valid_status_codes=[${HTTP_CREATED}]
1034
1035 # Try to change to an invalid password.
1036 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
1037 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1038
1039 # Change to a valid password.
1040 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
1041
1042 # Verify login.
1043 Redfish.Logout
1044 Redfish.Login ${user_name} UserPwd1
1045 Redfish.Logout
1046 Redfish.Login
1047 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
Nandakumar-AMI45830792025-10-30 13:15:15 +05301048
1049Create Admin User And Verify SSH Login
1050 [Documentation] Create admin user and verify SSH login & logout.
1051
1052 # Create an admin User.
1053 Redfish Create User new_admin TestPwd1 Administrator ${True}
1054
1055 # Attempt SSH login with admin user.
1056 SSHLibrary.Open Connection ${OPENBMC_HOST}
1057 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
1058
1059 # By default ssh_status is True, user can change the status via CLI
1060 # -v ssh_status:False
1061 Should Be Equal As Strings "${status}" "${ssh_status}"
1062
1063 # Close SSH connection for admin user.
1064 SSHLibrary.Close Connection