blob: 93f4e6ec22eb4b4eec2872ac8730cd71fc5e1bf7 [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
Sandhya Somashekar37122b62019-06-18 06:02:02 -050014*** Variables ***
15
16${account_lockout_duration} ${30}
17${account_lockout_threshold} ${3}
George Keishingf8e18192023-07-05 14:26:27 +053018${ssh_status} ${True}
19
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -050020*** Test Cases ***
Sivas SRR6aa101f2019-02-19 22:31:55 -060021
22Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060023 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060024 [Tags] Verify_AccountService_Available
25
George Keishing97c93942019-03-04 12:45:07 -060026 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060027 Should Be Equal As Strings ${resp} ${True}
28
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050029
30Verify Redfish Admin User Persistence After Reboot
31 [Documentation] Verify Redfish admin user persistence after reboot.
32 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
33 [Setup] Run Keywords Redfish.Login AND
34 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
35 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
36 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050037
38 # Reboot BMC.
39 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050040
41 # Verify users after reboot.
42 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050043
44
45Verify Redfish Operator User Persistence After Reboot
46 [Documentation] Verify Redfish operator user persistence after reboot.
47 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
48 [Setup] Run Keywords Redfish.Login AND
49 ... Redfish Create User operator_user TestPwd123 Operator ${True}
50 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
51 ... AND Test Teardown Execution
52
53 # Reboot BMC.
54 Redfish OBMC Reboot (off) stack_mode=normal
55
56 # Verify users after reboot.
Sandhya Somashekara83fb472019-08-29 02:26:21 -050057 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050058
59
60Verify Redfish Readonly User Persistence After Reboot
61 [Documentation] Verify Redfish readonly user persistence after reboot.
62 [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot
63 [Setup] Run Keywords Redfish.Login AND
64 ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
65 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
66 ... AND Test Teardown Execution
67
68 # Reboot BMC.
69 Redfish OBMC Reboot (off) stack_mode=normal
70
71 # Verify users after reboot.
Anusha Dathatri4062b442020-02-03 04:39:15 -060072 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050073
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050074Redfish Create and Verify Admin User
75 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050076 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060077 [Template] Redfish Create And Verify User
78
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050079 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050080 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050081
82
83Redfish Create and Verify Operator User
84 [Documentation] Create a Redfish user with operator role and verify.
85 [Tags] Redfish_Create_and_Verify_Operator_User
86 [Template] Redfish Create And Verify User
87
88 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050089 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050090
91
92Redfish Create and Verify Readonly User
93 [Documentation] Create a Redfish user with readonly role and verify.
94 [Tags] Redfish_Create_and_Verify_Readonly_User
95 [Template] Redfish Create And Verify User
96
97 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -060098 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060099
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500100
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500101Verify Redfish Admin User Login With Wrong Password
102 [Documentation] Verify Redfish create admin user with valid password and make sure
103 ... admin user failed to login with wrong password.
104 [Tags] Verify_Redfish_Admin_User_Login_With_Wrong_Password
105 [Template] Verify Redfish User Login With Wrong Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500106
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500107 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500108 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500109
110
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500111Verify Redfish Operator User Login With Wrong Password
112 [Documentation] Verify Redfish create operator user with valid password and make sure
113 ... operator user failed to login with wrong password.
114 [Tags] Verify_Redfish_Operator_User_Login_With_Wrong_Password
115 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500116
117 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500118 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500119
120
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500121Verify Redfish Readonly User Login With Wrong Password
122 [Documentation] Verify Redfish create readonly user with valid password and make sure
123 ... readonly user failed to login with wrong password.
124 [Tags] Verify_Redfish_Readonly_User_Login_With_Wrong_Password
125 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500126
127 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600128 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500129
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500130
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500131Verify Login with Deleted Redfish Admin User
132 [Documentation] Verify login with deleted Redfish admin user.
133 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500134 [Template] Verify Login with Deleted Redfish User
135
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500136 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500137 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500138
139
140Verify Login with Deleted Redfish Operator User
141 [Documentation] Verify login with deleted Redfish operator user.
142 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
143 [Template] Verify Login with Deleted Redfish User
144
145 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500146 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500147
148
149Verify Login with Deleted Redfish Readonly User
150 [Documentation] Verify login with deleted Redfish readonly user.
151 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
152 [Template] Verify Login with Deleted Redfish User
153
154 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600155 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500156
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500157
158Verify Admin User Creation Without Enabling It
159 [Documentation] Verify admin user creation without enabling it.
160 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500161 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500162
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500163 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500164 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500165
166
167Verify Operator User Creation Without Enabling It
168 [Documentation] Verify operator user creation without enabling it.
169 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
170 [Template] Verify Create User Without Enabling
171
172 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500173 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500174
175
176Verify Readonly User Creation Without Enabling It
177 [Documentation] Verify readonly user creation without enabling it.
178 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
179 [Template] Verify Create User Without Enabling
180
181 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600182 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500183
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500184
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500185Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500186 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500187 [Tags] Verify_User_Creation_With_Invalid_Role_Id
188
189 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600190 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500191 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
192
193 # Create specified user.
194 ${payload}= Create Dictionary
195 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600196 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500197 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
198
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500199Verify Error Upon Creating Same Users With Different Privileges
200 [Documentation] Verify error upon creating same users with different privileges.
201 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
202
203 Redfish Create User test_user TestPwd123 Administrator ${True}
204
205 # Create specified user.
206 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500207 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600208 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500209 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
210
Anusha Dathatri466816f2020-01-30 05:12:36 -0600211 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500212
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500213
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500214Verify Modifying User Attributes
215 [Documentation] Verify modifying user attributes.
216 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500217
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500218 # Create Redfish users.
219 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600220 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500221
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500222 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600223 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500224 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
225
226 # Update admin_user username using Redfish.
227 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600228 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530229 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500230
Anusha Dathatri4062b442020-02-03 04:39:15 -0600231 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500232 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600233 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530234 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500235
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500236 # Verify users after updating
237 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500238 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500239
240 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600241 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600242 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500243
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500244
245Verify Modifying Operator User Attributes
246 [Documentation] Verify modifying operator user attributes.
247 [Tags] Verify_Modifying_Operator_User_Attributes
248 [Setup] Run Keywords Redfish.Login AND
249 ... Redfish Create User operator_user TestPwd123 Operator ${True}
250 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
251 ... AND Test Teardown Execution
252
253 # Update operator_user password using Redfish.
254 ${payload}= Create Dictionary Password=NewTestPwd123
255 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
256
257 # Verify users after updating
258 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
259
260
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500261Verify User Account Locked
262 [Documentation] Verify user account locked upon trying with invalid password.
263 [Tags] Verify_User_Account_Locked
264
265 Redfish Create User admin_user TestPwd123 Administrator ${True}
266
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500267 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
268 ... AccountLockoutDuration=${account_lockout_duration}
269 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530270 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500271
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500272 Redfish.Logout
273
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500274 # Make ${account_lockout_threshold} failed login attempts.
275 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500276 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500277
278 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500279 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500280 ... Redfish.Login admin_user TestPwd123
281
Vidya-Kalasappanavar344c21d2025-07-01 12:21:05 -0500282 # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout
283 # ... then verify that login works.
284 ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5
285 Sleep ${total_wait_duartion}s
286
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500287 Redfish.Login admin_user TestPwd123
288
289 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500290
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500291 Redfish.Login
292
Anusha Dathatri466816f2020-01-30 05:12:36 -0600293 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500294
aravinth0510746884b2022-09-29 16:04:07 +0000295
296Verify User Account Unlock
297 [Documentation] Verify manually unlocking the account before lockout time
298 [Tags] Verify_User_Account_Unlock
George Keishinga36926b2023-05-17 21:54:34 +0530299 [Teardown] Run Keywords Redfish.Logout
300 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000301 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
302 ... AND SSHLibrary.Close All Connections
303
304 Redfish Create User test_user TestPwd123 Administrator ${True}
305
306 ${payload}= Create Dictionary
307 ... AccountLockoutThreshold=${account_lockout_threshold}
308 ... AccountLockoutDuration=${account_lockout_duration}
309 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
310
311 Redfish.Logout
312
313 # Make ${account_lockout_threshold} failed login attempts.
314 Repeat Keyword ${account_lockout_threshold} times
315 ... Run Keyword And Expect Error InvalidCredentialsError*
316 ... Redfish.Login test_user abc123
317
318 # Ensure SSH Login with locked account gets failed
319 SSHLibrary.Open Connection ${OPENBMC_HOST}
320 Run Keyword And Expect Error Authentication failed*
321 ... SSHLibrary.Login test_user TestPwd123
322
323 # Verify that legitimate login fails due to lockout.
324 Run Keyword And Expect Error InvalidCredentialsError*
325 ... Redfish.Login test_user TestPwd123
326
327 ${payload}= Create Dictionary Locked=${FALSE}
328
329 # Manually unlock the account before lockout threshold expires
330 Redfish.Login
331 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
332 Redfish.Logout
333
334 # Try redfish login with the recently unlocked account
335 Redfish.Login test_user TestPwd123
336
337 # Try SSH login with the unlocked account
338 SSHLibrary.Open Connection ${OPENBMC_HOST}
339 SSHLibrary.Login test_user TestPwd123
340
341
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500342Verify Admin User Privilege
343 [Documentation] Verify admin user privilege.
344 [Tags] Verify_Admin_User_Privilege
345
346 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600347 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500348
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500349 Redfish.Logout
350
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500351 Redfish.Login admin_user TestPwd123
352
353 # Change password of 'readonly' user with admin user.
354 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
355
356 # Verify modified user.
357 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
358
359 # Note: Delete user would work here because a root login is
360 # performed as part of "Redfish Verify User" keyword's teardown.
361 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
362 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
363
364
365Verify Operator User Role Change Using Admin Privilege User
366 [Documentation] Verify operator user role change using admin privilege user
367 [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User
368
369 Redfish Create User admin_user TestPwd123 Administrator ${True}
370 Redfish Create User operator_user TestPwd123 Operator ${True}
371
372 Redfish.Logout
373
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500374 # Change role ID of operator user with admin user.
375 # Login with admin user.
376 Redfish.Login admin_user TestPwd123
377
378 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600379 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500380
381 # Verify modified user.
382 Redfish Verify User operator_user TestPwd123 Administrator ${True}
383
Anusha Dathatri466816f2020-01-30 05:12:36 -0600384 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
385 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500386
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500387
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500388Verify Operator User Privilege
389 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600390 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500391
392 Redfish Create User admin_user TestPwd123 Administrator ${True}
393 Redfish Create User operator_user TestPwd123 Operator ${True}
394
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500395 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500396 # Login with operator user.
397 Redfish.Login operator_user TestPwd123
398
George Keishing093c1bd2020-02-10 09:47:34 -0600399 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500400 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500401
402 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600403 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500404 ... valid_status_codes=[${HTTP_FORBIDDEN}]
405
406 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500407
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500408 Redfish.Login
409
Anusha Dathatri466816f2020-01-30 05:12:36 -0600410 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
411 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500412
413
Anusha Dathatri4062b442020-02-03 04:39:15 -0600414Verify ReadOnly User Privilege
415 [Documentation] Verify ReadOnly user privilege.
416 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500417
Anusha Dathatri4062b442020-02-03 04:39:15 -0600418 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500419 Redfish.Logout
420
421 # Login with read_only user.
422 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500423
424 # Read system level data.
425 ${system_model}= Redfish_Utils.Get Attribute
426 ... ${SYSTEM_BASE_URI} Model
427
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500428 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500429 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600430 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500431
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500432
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500433Verify Minimum Password Length For Redfish Admin And Readonly User
434 [Documentation] Verify minimum password length for new and existing admin or
435 ... readonly user.
436 [Template] Verify Minimum Password Length For Redfish User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600437
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500438 #username role_id
439 admin_user Administrator
440 readonly_user ReadOnly
Anusha Dathatri466816f2020-01-30 05:12:36 -0600441
442
Tony Lee94335f42021-02-04 15:16:39 +0800443Verify Standard User Roles Defined By Redfish
444 [Documentation] Verify standard user roles defined by Redfish.
445 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
446
447 ${member_list}= Redfish_Utils.Get Member List
448 ... /redfish/v1/AccountService/Roles
449
450 @{roles}= Create List
451 ... /redfish/v1/AccountService/Roles/Administrator
452 ... /redfish/v1/AccountService/Roles/Operator
453 ... /redfish/v1/AccountService/Roles/ReadOnly
454
455 List Should Contain Sub List ${member_list} ${roles}
456
457 # The standard roles are:
458
459 # | Role name | Assigned privileges |
460 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
461 # | Operator | Login, ConfigureComponents, ConfigureSelf |
462 # | ReadOnly | Login, ConfigureSelf |
463
464 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
465 @{operator}= Create List Login ConfigureComponents ConfigureSelf
466 @{readOnly}= Create List Login ConfigureSelf
467
468 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
469 ... readOnly_privileges=${readOnly}
470
471 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
472 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
473
474 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
475 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
476
477 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
478 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
479
480
manashsarma4910aa22021-07-26 09:12:36 -0500481Verify Error While Deleting Root User
482 [Documentation] Verify error while deleting root user.
483 [Tags] Verify_Error_While_Deleting_Root_User
484
485 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
486
487
manashsarma654cbc12021-09-23 02:28:12 -0500488Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530489 [Documentation] Verify that admin user have SSH login access.
490 ... By default, admin should have access but there could be
491 ... case where admin user shell access is restricted by design
492 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500493 [Tags] Verify_SSH_Login_Access_With_Admin_User
494
495 # Create an admin User.
496 Redfish Create User new_admin TestPwd1 Administrator ${True}
497
498 # Attempt SSH login with admin user.
499 SSHLibrary.Open Connection ${OPENBMC_HOST}
500 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
George Keishingf8e18192023-07-05 14:26:27 +0530501
502 # By default ssh_status is True, user can change the status via CLI
503 # -v ssh_status:False
504 Should Be Equal As Strings "${status}" "${ssh_status}"
manashsarma654cbc12021-09-23 02:28:12 -0500505
George Keishinge8015b32022-09-19 09:38:47 -0500506 Redfish.Login
507 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
508
manashsarma654cbc12021-09-23 02:28:12 -0500509
aravinth0510746884b2022-09-29 16:04:07 +0000510Verify Configure BasicAuth Enable And Disable
511 [Documentation] Verify configure basicauth enable and disable
512 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
513 [Template] Template For Configure Auth Methods
514
515 # auth_method
516 BasicAuth
517 XToken
518
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500519
520Redfish Create and Verify Admin User With Invalid Password Format
521 [Documentation] Create a admin user with invalid password format and verify.
522 [Template] Create User With Unsupported Password Format And Verify
523 [Tags] Redfish_Create_and_Verify_Admin_User_With_Invalid_Password_Format
524
525 #username role_id password
526 admin_user Administrator snellens
527 admin_user Administrator 10000001
528 admin_user Administrator 12345678
529 admin_user Administrator abcdefgh
530 admin_user Administrator abf12345
531 admin_user Administrator helloworld
532 admin_user Administrator HELLOWORLD
533 admin_user Administrator &$%**!*@
534 admin_user Administrator Dictation
535
536
537Redfish Create and Verify Readonly User With Invalid Password Format
538 [Documentation] Create a readonly user with invalid password format and verify.
539 [Template] Create User With Unsupported Password Format And Verify
540 [Tags] Redfish_Create_and_Verify_Readonly_User_With_Invalid_Password_Format
541
542 #username role_id password
543 readonly_user ReadOnly snellens
544 readonly_user ReadOnly 10000001
545 readonly_user ReadOnly 12345678
546 readonly_user ReadOnly abcdefgh
547 readonly_user ReadOnly abf12345
548 readonly_user ReadOnly helloworld
549 readonly_user ReadOnly HELLOWORLD
550 readonly_user ReadOnly &$%**!*@
551 readonly_user ReadOnly Dictation
552
553
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500554Verify Admin And Readonly User Password Is Not Same As Username
555 [Documentation] Verify that admin and readonly user creation is failed if
556 ... password is same as username.
557 [Template] Create User With Unsupported Password Format And Verify
558 [Tags] Verify_Admin_And_Readonly_User_Password_Is_Not_Same_As_Username
559
560 #username role_id password
561 AdminUser1 Administrator AdminUser1
562 ReadOnlyUser1 ReadOnly ReadOnlyUser1
563
564
Sivas SRR6aa101f2019-02-19 22:31:55 -0600565*** Keywords ***
566
Sivas SRR6aa101f2019-02-19 22:31:55 -0600567Test Teardown Execution
568 [Documentation] Do the post test teardown.
569
Anusha Dathatridb769702020-02-12 01:02:30 -0600570 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500571 FFDC On Test Case Fail
572
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600573
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500574Redfish Create User
575 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500576 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500577
578 # Description of argument(s):
579 # username The username to be created.
580 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500581 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500582 # (e.g. "Administrator", "Operator", etc.).
583 # enabled Indicates whether the username being created
584 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500585 # login_check Checks user login for created user.
586 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500587
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500588 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600589 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500590 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
591
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500592 # Create specified user.
593 ${payload}= Create Dictionary
594 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600595 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500596 ... valid_status_codes=[${HTTP_CREATED}]
597
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500598 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600599 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500600 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000601
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600602 Bmc Execute Command ${cmd}
603
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500604 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530605 IF '${login_check}' == '${True}'
606 ${status}= Run Keyword And Return Status
607 ... Verify Redfish User Login ${username} ${password}
608 ELSE
609 ${status}= Set Variable ${False}
610 END
611
612 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500613
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500614 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500615 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600616 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500617 Should Be Equal ${role_id} ${role_config}
618
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500619
620Redfish Verify User
621 [Documentation] Redfish user verification.
622 [Arguments] ${username} ${password} ${role_id} ${enabled}
623
624 # Description of argument(s):
625 # username The username to be created.
626 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500627 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500628 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500629 # enabled Indicates whether the username being created
630 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500631
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500632 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500633 # Doing a check of the returned status.
634 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500635
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500636 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500637 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600638 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500639 Should Be Equal ${role_id} ${role_config}
640
641
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500642Verify Redfish User Login
643 [Documentation] Verify Redfish login with given user id.
644 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
645 [Arguments] ${username} ${password}
646
647 # Description of argument(s):
648 # username Login username.
649 # password Login password.
650
651 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600652 # We don't really care if the current session is flushed out since we are going to login
653 # with new credential in next.
654 Run Keyword And Ignore Error Redfish.Logout
655
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500656 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530657 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500658
659
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600660Redfish Create And Verify User
661 [Documentation] Redfish create and verify user.
662 [Arguments] ${username} ${password} ${role_id} ${enabled}
663
664 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500665 # username The username to be created.
666 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500667 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500668 # (e.g. "Administrator", "Operator", etc.).
669 # enabled Indicates whether the username being created
670 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600671
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500672 # Example:
673 #{
674 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
675 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
676 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
677 #"Description": "User Account",
678 #"Enabled": true,
679 #"Id": "test1",
680 #"Links": {
681 # "Role": {
682 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
683 # }
684 #},
685
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500686 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600687
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500688 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600689
690 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600691 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500692
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500693Verify Redfish User Login With Wrong Password
694 [Documentation] Verify Redfish User failed to login with wrong password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500695 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
696
697 # Description of argument(s):
698 # username The username to be created.
699 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500700 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500701 # (e.g. "Administrator", "Operator", etc.).
702 # enabled Indicates whether the username being created
703 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500704 # wrong_password Any invalid password.
705
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500706 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500707
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500708 Redfish.Logout
709
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500710 # Attempt to login with created user with invalid password.
711 Run Keyword And Expect Error InvalidCredentialsError*
712 ... Redfish.Login ${username} ${wrong_password}
713
714 Redfish.Login
715
716 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600717 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500718
719
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500720Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500721 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500722 [Arguments] ${username} ${password} ${role_id} ${enabled}
723
724 # Description of argument(s):
725 # username The username to be created.
726 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500727 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500728 # (e.g. "Administrator", "Operator", etc.).
729 # enabled Indicates whether the username being created
730 # should be enabled (${True}, ${False}).
731
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500732 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500733
734 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600735 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500736
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500737 Redfish.Logout
738
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500739 # Attempt to login with deleted user account.
740 Run Keyword And Expect Error InvalidCredentialsError*
741 ... Redfish.Login ${username} ${password}
742
743 Redfish.Login
744
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500745
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500746Verify Create User Without Enabling
747 [Documentation] Verify Create User Without Enabling.
748 [Arguments] ${username} ${password} ${role_id} ${enabled}
749
750 # Description of argument(s):
751 # username The username to be created.
752 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500753 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500754 # (e.g. "Administrator", "Operator", etc.).
755 # enabled Indicates whether the username being created
756 # should be enabled (${True}, ${False}).
757
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500758 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500759
760 Redfish.Logout
761
762 # Login with created user.
763 Run Keyword And Expect Error InvalidCredentialsError*
764 ... Redfish.Login ${username} ${password}
765
766 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500767
768 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600769 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500770
aravinth0510746884b2022-09-29 16:04:07 +0000771Template For Configure Auth Methods
772 [Documentation] Template to configure auth methods.
773 [Arguments] ${auth_method}
774 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
775
776 # Description of Argument(s):
777 # authmethods The authmethod setting which needs to be
778 # set in account service URI.
779 # valid values BasicAuth, XToken.
780
781 Get AuthMethods Default Values ${auth_method}
782
783 # Patch basicauth to TRUE
784 Configure AuthMethods ${auth_method}=${TRUE}
785
George Keishing79fc7f02025-05-02 00:37:49 +0530786 IF "${auth_method}" == "XToken"
787 Check XToken Works Fine ${HTTP_OK}
788 ELSE
789 Check BasicAuth Works Fine ${HTTP_OK}
790 END
aravinth0510746884b2022-09-29 16:04:07 +0000791
792 # Patch basicauth to FALSE
793 Configure AuthMethods ${auth_method}=${FALSE}
794
George Keishing79fc7f02025-05-02 00:37:49 +0530795 IF "${auth_method}" == "BasicAuth"
796 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
797 ELSE
798 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
799 END
aravinth0510746884b2022-09-29 16:04:07 +0000800
801Configure AuthMethods
802 [Documentation] Enable/disable authmethod types.
803 [Arguments] &{authmethods}
804
805 # Description of argument(s):
806 # authmethods The authmethod setting which needs to be
807 # set in account service URI.
808 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
809 # This will set the value of "XToken" and "BasicAuth"
810 # property in accountservice uri to TRUE.
811
812 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
813 ${oem}= Create Dictionary OpenBMC=${openbmc}
814 ${payload}= Create Dictionary Oem=${oem}
815
816 # Setting authmethod properties using Redfish session based auth
817 ${status}= Run Keyword And Return Status
818 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
819 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
820
George Keishingc63bfe62023-11-15 19:09:59 +0530821 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000822 IF ${status}==${FALSE}
823 # Payload dictionary pre-process to match json formatting
824 ${payload}= Convert To String ${payload}
825 ${payload}= Replace String ${payload} ' "
826 ${payload}= Replace String ${payload} False false
827 ${payload}= Replace String ${payload} True true
828
829 # Curl Command Framing for PATCH authmethod
830 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
831 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
832 ... -H 'content-type:application/json' -H 'If-Match:*'
833 ... -d '${payload}'
834 ${rc} ${out}= Run And Return Rc And Output ${cmd}
835
836 # Check the response of curl command is 200 or 204
837 ${check_no_content}=
838 ... Run Keyword and Return Status Should Contain ${out} 204
839 ${check_ok}=
840 ... Run Keyword and Return Status Should Contain ${out} 200
841 Pass Execution If ${check_no_content}==${TRUE}
842 ... OR ${check_ok}==${TRUE}
843 END
844
845
846Get AuthMethods Default Values
847 [Documentation] Get enabled/disabled status of all authmethods
848 ... from Redfish account service URI
849 [Arguments] ${authmethod}
850
851 # Description of argument(s):
852 # authmethod The authmethod property whose value needs to be
853 # retrieved from account service URI.
854 # Usage Example Get AuthMethods Default Values BasicAuth
855 # returns >> ${TRUE}
856 # Example:
857 # {
858 # "@odata.id": "/redfish/v1/AccountService",
859 # (...)
860 # "Oem": {
861 # "OpenBMC": {
862 # "AuthMethods": {
863 # "BasicAuth": true,
864 # "Cookie": true,
865 # "SessionToken": true,
866 # "TLS": true,
867 # "XToken": true
868 # }
869 # }
870 # }
871 # }
872
873 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
874 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
875 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
876 Set Test Variable ${initial_value}
877
878Check XToken Works Fine
879 [Documentation] Verify Xtoken works fine.
880 [Arguments] ${status_code}
881
882 # Description of Argument(s):
883 # status_code : 200, 401.
884
885 # Verify xtoken auth works for xtoken
886 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
887 ... valid_status_codes=[${status_code}]
888
889Check BasicAuth Works Fine
890 [Documentation] Verify Basic Auth works fine.
891 [Arguments] ${status_code}
892
893 # Description of Argument(s):
894 # status_code : 200, 401.
895
896 # Verify basic auth works based on basic auth.
897 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
898 ... ${AUTH_URI}/redfish/v1/AccountService
899 ${rc} ${out}= Run And Return Rc And Output ${cmd}
900
901 # Check the response of curl command is 200/401
902 Should Contain ${out} ${status_code}
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500903
904
905Create User With Unsupported Password Format And Verify
906 [Documentation] Create admin or readonly user with unsupported password format
907 ... and verify.
908 [Arguments] ${username} ${role_id} ${password}
909
910 # Description of argument(s):
911 # username The username to be created.
912 # role_id The role ID of the user to be created
913 # (e.g. "Administrator", "ReadOnly").
914 # password The password to be assigned.
915 # Unsupported password format are sequential characters,
916 # sequential digits, palindrome digits, palindrome characters,
917 # only uppercase letters, only lowercase letters, only digits,
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500918 # only characters, not a dictionary word, username and password
919 # should not be same.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500920
921 # Make sure the user account in question does not already exist.
922 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
923 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
924
925 # Create specified user with invalid password format.
926 ${payload}= Create Dictionary
927 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${True}
928 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
929 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500930
931
932Verify Minimum Password Length For Redfish User
933 [Documentation] Verify minimum password length for new and existing admin or
934 ... readonly user.
935 [Arguments] ${user_name} ${role_id}
936
937 # Description of argument(s):
938 # user_name The username to be created.
939 # role_id The role ID of the user to be created.
940
941 # Make sure the user account in question does not already exist.
942 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
943 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
944
945 # Try to create a user with invalid length password.
946 ${payload}= Create Dictionary
947 ... UserName=${user_name} Password=UserPwd RoleId=${role_id} Enabled=${True}
948 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
949 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
950
951 # Create specified user with valid length password.
952 Set To Dictionary ${payload} Password UserPwd1
953 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
954 ... valid_status_codes=[${HTTP_CREATED}]
955
956 # Try to change to an invalid password.
957 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
958 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
959
960 # Change to a valid password.
961 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
962
963 # Verify login.
964 Redfish.Logout
965 Redfish.Login ${user_name} UserPwd1
966 Redfish.Logout
967 Redfish.Login
968 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}