blob: 3baffe7fef636893f02ac07e59c4912a982b3234 [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
Anusha Dathatri466816f2020-01-30 05:12:36 -0600433Verify Minimum Password Length For Redfish User
434 [Documentation] Verify minimum password length for new and existing user.
435 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
436
437 ${user_name}= Set Variable testUser
438
439 # Make sure the user account in question does not already exist.
440 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
441 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
442
443 # Try to create a user with invalid length password.
444 ${payload}= Create Dictionary
445 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
446 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
447 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
448
449 # Create specified user with valid length password.
450 Set To Dictionary ${payload} Password UserPwd1
451 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
452 ... valid_status_codes=[${HTTP_CREATED}]
453
454 # Try to change to an invalid password.
455 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
456 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
457
458 # Change to a valid password.
459 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
460
461 # Verify login.
462 Redfish.Logout
463 Redfish.Login ${user_name} UserPwd1
464 Redfish.Logout
465 Redfish.Login
466 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
467
468
Tony Lee94335f42021-02-04 15:16:39 +0800469Verify Standard User Roles Defined By Redfish
470 [Documentation] Verify standard user roles defined by Redfish.
471 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
472
473 ${member_list}= Redfish_Utils.Get Member List
474 ... /redfish/v1/AccountService/Roles
475
476 @{roles}= Create List
477 ... /redfish/v1/AccountService/Roles/Administrator
478 ... /redfish/v1/AccountService/Roles/Operator
479 ... /redfish/v1/AccountService/Roles/ReadOnly
480
481 List Should Contain Sub List ${member_list} ${roles}
482
483 # The standard roles are:
484
485 # | Role name | Assigned privileges |
486 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
487 # | Operator | Login, ConfigureComponents, ConfigureSelf |
488 # | ReadOnly | Login, ConfigureSelf |
489
490 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
491 @{operator}= Create List Login ConfigureComponents ConfigureSelf
492 @{readOnly}= Create List Login ConfigureSelf
493
494 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
495 ... readOnly_privileges=${readOnly}
496
497 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
498 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
499
500 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
501 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
502
503 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
504 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
505
506
manashsarma4910aa22021-07-26 09:12:36 -0500507Verify Error While Deleting Root User
508 [Documentation] Verify error while deleting root user.
509 [Tags] Verify_Error_While_Deleting_Root_User
510
511 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
512
513
manashsarma654cbc12021-09-23 02:28:12 -0500514Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530515 [Documentation] Verify that admin user have SSH login access.
516 ... By default, admin should have access but there could be
517 ... case where admin user shell access is restricted by design
518 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500519 [Tags] Verify_SSH_Login_Access_With_Admin_User
520
521 # Create an admin User.
522 Redfish Create User new_admin TestPwd1 Administrator ${True}
523
524 # Attempt SSH login with admin user.
525 SSHLibrary.Open Connection ${OPENBMC_HOST}
526 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
George Keishingf8e18192023-07-05 14:26:27 +0530527
528 # By default ssh_status is True, user can change the status via CLI
529 # -v ssh_status:False
530 Should Be Equal As Strings "${status}" "${ssh_status}"
manashsarma654cbc12021-09-23 02:28:12 -0500531
George Keishinge8015b32022-09-19 09:38:47 -0500532 Redfish.Login
533 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
534
manashsarma654cbc12021-09-23 02:28:12 -0500535
aravinth0510746884b2022-09-29 16:04:07 +0000536Verify Configure BasicAuth Enable And Disable
537 [Documentation] Verify configure basicauth enable and disable
538 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
539 [Template] Template For Configure Auth Methods
540
541 # auth_method
542 BasicAuth
543 XToken
544
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500545
546Redfish Create and Verify Admin User With Invalid Password Format
547 [Documentation] Create a admin user with invalid password format and verify.
548 [Template] Create User With Unsupported Password Format And Verify
549 [Tags] Redfish_Create_and_Verify_Admin_User_With_Invalid_Password_Format
550
551 #username role_id password
552 admin_user Administrator snellens
553 admin_user Administrator 10000001
554 admin_user Administrator 12345678
555 admin_user Administrator abcdefgh
556 admin_user Administrator abf12345
557 admin_user Administrator helloworld
558 admin_user Administrator HELLOWORLD
559 admin_user Administrator &$%**!*@
560 admin_user Administrator Dictation
561
562
563Redfish Create and Verify Readonly User With Invalid Password Format
564 [Documentation] Create a readonly user with invalid password format and verify.
565 [Template] Create User With Unsupported Password Format And Verify
566 [Tags] Redfish_Create_and_Verify_Readonly_User_With_Invalid_Password_Format
567
568 #username role_id password
569 readonly_user ReadOnly snellens
570 readonly_user ReadOnly 10000001
571 readonly_user ReadOnly 12345678
572 readonly_user ReadOnly abcdefgh
573 readonly_user ReadOnly abf12345
574 readonly_user ReadOnly helloworld
575 readonly_user ReadOnly HELLOWORLD
576 readonly_user ReadOnly &$%**!*@
577 readonly_user ReadOnly Dictation
578
579
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500580Verify Admin And Readonly User Password Is Not Same As Username
581 [Documentation] Verify that admin and readonly user creation is failed if
582 ... password is same as username.
583 [Template] Create User With Unsupported Password Format And Verify
584 [Tags] Verify_Admin_And_Readonly_User_Password_Is_Not_Same_As_Username
585
586 #username role_id password
587 AdminUser1 Administrator AdminUser1
588 ReadOnlyUser1 ReadOnly ReadOnlyUser1
589
590
Sivas SRR6aa101f2019-02-19 22:31:55 -0600591*** Keywords ***
592
Sivas SRR6aa101f2019-02-19 22:31:55 -0600593Test Teardown Execution
594 [Documentation] Do the post test teardown.
595
Anusha Dathatridb769702020-02-12 01:02:30 -0600596 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500597 FFDC On Test Case Fail
598
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600599
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500600Redfish Create User
601 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500602 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500603
604 # Description of argument(s):
605 # username The username to be created.
606 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500607 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500608 # (e.g. "Administrator", "Operator", etc.).
609 # enabled Indicates whether the username being created
610 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500611 # login_check Checks user login for created user.
612 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500613
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500614 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600615 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500616 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
617
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500618 # Create specified user.
619 ${payload}= Create Dictionary
620 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600621 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500622 ... valid_status_codes=[${HTTP_CREATED}]
623
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500624 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600625 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500626 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000627
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600628 Bmc Execute Command ${cmd}
629
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500630 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530631 IF '${login_check}' == '${True}'
632 ${status}= Run Keyword And Return Status
633 ... Verify Redfish User Login ${username} ${password}
634 ELSE
635 ${status}= Set Variable ${False}
636 END
637
638 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500639
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500640 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500641 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600642 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500643 Should Be Equal ${role_id} ${role_config}
644
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500645
646Redfish Verify User
647 [Documentation] Redfish user verification.
648 [Arguments] ${username} ${password} ${role_id} ${enabled}
649
650 # Description of argument(s):
651 # username The username to be created.
652 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500653 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500654 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500655 # enabled Indicates whether the username being created
656 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500657
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500658 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500659 # Doing a check of the returned status.
660 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500661
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500662 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500663 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600664 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500665 Should Be Equal ${role_id} ${role_config}
666
667
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500668Verify Redfish User Login
669 [Documentation] Verify Redfish login with given user id.
670 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
671 [Arguments] ${username} ${password}
672
673 # Description of argument(s):
674 # username Login username.
675 # password Login password.
676
677 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600678 # We don't really care if the current session is flushed out since we are going to login
679 # with new credential in next.
680 Run Keyword And Ignore Error Redfish.Logout
681
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500682 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530683 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500684
685
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600686Redfish Create And Verify User
687 [Documentation] Redfish create and verify user.
688 [Arguments] ${username} ${password} ${role_id} ${enabled}
689
690 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500691 # username The username to be created.
692 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500693 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500694 # (e.g. "Administrator", "Operator", etc.).
695 # enabled Indicates whether the username being created
696 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600697
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500698 # Example:
699 #{
700 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
701 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
702 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
703 #"Description": "User Account",
704 #"Enabled": true,
705 #"Id": "test1",
706 #"Links": {
707 # "Role": {
708 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
709 # }
710 #},
711
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500712 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600713
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500714 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600715
716 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600717 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500718
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500719Verify Redfish User Login With Wrong Password
720 [Documentation] Verify Redfish User failed to login with wrong password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500721 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
722
723 # Description of argument(s):
724 # username The username to be created.
725 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500726 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500727 # (e.g. "Administrator", "Operator", etc.).
728 # enabled Indicates whether the username being created
729 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500730 # wrong_password Any invalid password.
731
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500732 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500733
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500734 Redfish.Logout
735
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500736 # Attempt to login with created user with invalid password.
737 Run Keyword And Expect Error InvalidCredentialsError*
738 ... Redfish.Login ${username} ${wrong_password}
739
740 Redfish.Login
741
742 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600743 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500744
745
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500746Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500747 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500748 [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 Somashekaraf402ca2019-03-18 05:59:19 -0500754 # (e.g. "Administrator", "Operator", etc.).
755 # enabled Indicates whether the username being created
756 # should be enabled (${True}, ${False}).
757
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500758 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500759
760 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600761 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500762
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500763 Redfish.Logout
764
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500765 # Attempt to login with deleted user account.
766 Run Keyword And Expect Error InvalidCredentialsError*
767 ... Redfish.Login ${username} ${password}
768
769 Redfish.Login
770
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500771
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500772Verify Create User Without Enabling
773 [Documentation] Verify Create User Without Enabling.
774 [Arguments] ${username} ${password} ${role_id} ${enabled}
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 Somashekare92b1e62019-04-25 05:27:45 -0500780 # (e.g. "Administrator", "Operator", etc.).
781 # enabled Indicates whether the username being created
782 # should be enabled (${True}, ${False}).
783
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500784 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500785
786 Redfish.Logout
787
788 # Login with created user.
789 Run Keyword And Expect Error InvalidCredentialsError*
790 ... Redfish.Login ${username} ${password}
791
792 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500793
794 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600795 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500796
aravinth0510746884b2022-09-29 16:04:07 +0000797Template For Configure Auth Methods
798 [Documentation] Template to configure auth methods.
799 [Arguments] ${auth_method}
800 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
801
802 # Description of Argument(s):
803 # authmethods The authmethod setting which needs to be
804 # set in account service URI.
805 # valid values BasicAuth, XToken.
806
807 Get AuthMethods Default Values ${auth_method}
808
809 # Patch basicauth to TRUE
810 Configure AuthMethods ${auth_method}=${TRUE}
811
George Keishing79fc7f02025-05-02 00:37:49 +0530812 IF "${auth_method}" == "XToken"
813 Check XToken Works Fine ${HTTP_OK}
814 ELSE
815 Check BasicAuth Works Fine ${HTTP_OK}
816 END
aravinth0510746884b2022-09-29 16:04:07 +0000817
818 # Patch basicauth to FALSE
819 Configure AuthMethods ${auth_method}=${FALSE}
820
George Keishing79fc7f02025-05-02 00:37:49 +0530821 IF "${auth_method}" == "BasicAuth"
822 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
823 ELSE
824 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
825 END
aravinth0510746884b2022-09-29 16:04:07 +0000826
827Configure AuthMethods
828 [Documentation] Enable/disable authmethod types.
829 [Arguments] &{authmethods}
830
831 # Description of argument(s):
832 # authmethods The authmethod setting which needs to be
833 # set in account service URI.
834 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
835 # This will set the value of "XToken" and "BasicAuth"
836 # property in accountservice uri to TRUE.
837
838 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
839 ${oem}= Create Dictionary OpenBMC=${openbmc}
840 ${payload}= Create Dictionary Oem=${oem}
841
842 # Setting authmethod properties using Redfish session based auth
843 ${status}= Run Keyword And Return Status
844 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
845 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
846
George Keishingc63bfe62023-11-15 19:09:59 +0530847 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000848 IF ${status}==${FALSE}
849 # Payload dictionary pre-process to match json formatting
850 ${payload}= Convert To String ${payload}
851 ${payload}= Replace String ${payload} ' "
852 ${payload}= Replace String ${payload} False false
853 ${payload}= Replace String ${payload} True true
854
855 # Curl Command Framing for PATCH authmethod
856 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
857 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
858 ... -H 'content-type:application/json' -H 'If-Match:*'
859 ... -d '${payload}'
860 ${rc} ${out}= Run And Return Rc And Output ${cmd}
861
862 # Check the response of curl command is 200 or 204
863 ${check_no_content}=
864 ... Run Keyword and Return Status Should Contain ${out} 204
865 ${check_ok}=
866 ... Run Keyword and Return Status Should Contain ${out} 200
867 Pass Execution If ${check_no_content}==${TRUE}
868 ... OR ${check_ok}==${TRUE}
869 END
870
871
872Get AuthMethods Default Values
873 [Documentation] Get enabled/disabled status of all authmethods
874 ... from Redfish account service URI
875 [Arguments] ${authmethod}
876
877 # Description of argument(s):
878 # authmethod The authmethod property whose value needs to be
879 # retrieved from account service URI.
880 # Usage Example Get AuthMethods Default Values BasicAuth
881 # returns >> ${TRUE}
882 # Example:
883 # {
884 # "@odata.id": "/redfish/v1/AccountService",
885 # (...)
886 # "Oem": {
887 # "OpenBMC": {
888 # "AuthMethods": {
889 # "BasicAuth": true,
890 # "Cookie": true,
891 # "SessionToken": true,
892 # "TLS": true,
893 # "XToken": true
894 # }
895 # }
896 # }
897 # }
898
899 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
900 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
901 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
902 Set Test Variable ${initial_value}
903
904Check XToken Works Fine
905 [Documentation] Verify Xtoken works fine.
906 [Arguments] ${status_code}
907
908 # Description of Argument(s):
909 # status_code : 200, 401.
910
911 # Verify xtoken auth works for xtoken
912 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
913 ... valid_status_codes=[${status_code}]
914
915Check BasicAuth Works Fine
916 [Documentation] Verify Basic Auth works fine.
917 [Arguments] ${status_code}
918
919 # Description of Argument(s):
920 # status_code : 200, 401.
921
922 # Verify basic auth works based on basic auth.
923 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
924 ... ${AUTH_URI}/redfish/v1/AccountService
925 ${rc} ${out}= Run And Return Rc And Output ${cmd}
926
927 # Check the response of curl command is 200/401
928 Should Contain ${out} ${status_code}
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500929
930
931Create User With Unsupported Password Format And Verify
932 [Documentation] Create admin or readonly user with unsupported password format
933 ... and verify.
934 [Arguments] ${username} ${role_id} ${password}
935
936 # Description of argument(s):
937 # username The username to be created.
938 # role_id The role ID of the user to be created
939 # (e.g. "Administrator", "ReadOnly").
940 # password The password to be assigned.
941 # Unsupported password format are sequential characters,
942 # sequential digits, palindrome digits, palindrome characters,
943 # only uppercase letters, only lowercase letters, only digits,
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500944 # only characters, not a dictionary word, username and password
945 # should not be same.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500946
947 # Make sure the user account in question does not already exist.
948 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
949 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
950
951 # Create specified user with invalid password format.
952 ${payload}= Create Dictionary
953 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${True}
954 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
955 ... valid_status_codes=[${HTTP_BAD_REQUEST}]