blob: 30fba2d004f4c45dbaf6709a1f6d8d1b64870177 [file] [log] [blame]
Sivas SRR6aa101f2019-02-19 22:31:55 -06001*** Settings ***
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05002Documentation Test suite for verifying Redfish admin, readonly operation user accounts.
Sivas SRR6aa101f2019-02-19 22:31:55 -06003
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -05007Resource ../../lib/bmc_redfish_utils.robot
Sivas SRR6aa101f2019-02-19 22:31:55 -06008
manashsarma654cbc12021-09-23 02:28:12 -05009Library SSHLibrary
10
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -050011Test Setup Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -060012Test Teardown Test Teardown Execution
13
Sridevi Rameshcf0c8b02025-09-17 06:22:35 -050014Test Tags User_Account
15
Sandhya Somashekar37122b62019-06-18 06:02:02 -050016*** Variables ***
17
18${account_lockout_duration} ${30}
19${account_lockout_threshold} ${3}
George Keishingf8e18192023-07-05 14:26:27 +053020${ssh_status} ${True}
21
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -050022*** Test Cases ***
Sivas SRR6aa101f2019-02-19 22:31:55 -060023
24Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060025 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060026 [Tags] Verify_AccountService_Available
27
George Keishing97c93942019-03-04 12:45:07 -060028 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060029 Should Be Equal As Strings ${resp} ${True}
30
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050031
32Verify Redfish Admin User Persistence After Reboot
33 [Documentation] Verify Redfish admin user persistence after reboot.
34 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
35 [Setup] Run Keywords Redfish.Login AND
36 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
37 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
38 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050039
40 # Reboot BMC.
41 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050042
43 # Verify users after reboot.
44 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050045
46
47Verify Redfish Operator User Persistence After Reboot
48 [Documentation] Verify Redfish operator user persistence after reboot.
49 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
50 [Setup] Run Keywords Redfish.Login AND
51 ... Redfish Create User operator_user TestPwd123 Operator ${True}
52 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
53 ... AND Test Teardown Execution
54
55 # Reboot BMC.
56 Redfish OBMC Reboot (off) stack_mode=normal
57
58 # Verify users after reboot.
Sandhya Somashekara83fb472019-08-29 02:26:21 -050059 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050060
61
62Verify Redfish Readonly User Persistence After Reboot
63 [Documentation] Verify Redfish readonly user persistence after reboot.
64 [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot
65 [Setup] Run Keywords Redfish.Login AND
66 ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
67 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
68 ... AND Test Teardown Execution
69
70 # Reboot BMC.
71 Redfish OBMC Reboot (off) stack_mode=normal
72
73 # Verify users after reboot.
Anusha Dathatri4062b442020-02-03 04:39:15 -060074 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050075
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050076Redfish Create and Verify Admin User
77 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050078 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060079 [Template] Redfish Create And Verify User
80
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050081 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050082 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050083
84
85Redfish Create and Verify Operator User
86 [Documentation] Create a Redfish user with operator role and verify.
87 [Tags] Redfish_Create_and_Verify_Operator_User
88 [Template] Redfish Create And Verify User
89
90 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050091 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050092
93
94Redfish Create and Verify Readonly User
95 [Documentation] Create a Redfish user with readonly role and verify.
96 [Tags] Redfish_Create_and_Verify_Readonly_User
97 [Template] Redfish Create And Verify User
98
99 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600100 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -0600101
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500102
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500103Verify Redfish Admin User Login With Wrong Password
104 [Documentation] Verify Redfish create admin user with valid password and make sure
105 ... admin user failed to login with wrong password.
106 [Tags] Verify_Redfish_Admin_User_Login_With_Wrong_Password
107 [Template] Verify Redfish User Login With Wrong Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500108
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500109 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500110 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500111
112
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500113Verify Redfish Operator User Login With Wrong Password
114 [Documentation] Verify Redfish create operator user with valid password and make sure
George Keishingeeec7352025-10-14 09:58:59 +0530115 ... operator user failed to login with wrong password.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500116 [Tags] Verify_Redfish_Operator_User_Login_With_Wrong_Password
117 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500118
119 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500120 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500121
122
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500123Verify Redfish Readonly User Login With Wrong Password
124 [Documentation] Verify Redfish create readonly user with valid password and make sure
125 ... readonly user failed to login with wrong password.
126 [Tags] Verify_Redfish_Readonly_User_Login_With_Wrong_Password
127 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500128
129 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600130 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500131
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500132
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500133Verify Login with Deleted Redfish Admin User
134 [Documentation] Verify login with deleted Redfish admin user.
135 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500136 [Template] Verify Login with Deleted Redfish User
137
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500138 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500139 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500140
141
142Verify Login with Deleted Redfish Operator User
143 [Documentation] Verify login with deleted Redfish operator user.
144 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
145 [Template] Verify Login with Deleted Redfish User
146
147 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500148 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500149
150
151Verify Login with Deleted Redfish Readonly User
152 [Documentation] Verify login with deleted Redfish readonly user.
153 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
154 [Template] Verify Login with Deleted Redfish User
155
156 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600157 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500158
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500159
160Verify Admin User Creation Without Enabling It
161 [Documentation] Verify admin user creation without enabling it.
162 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500163 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500164
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500165 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500166 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500167
168
169Verify Operator User Creation Without Enabling It
170 [Documentation] Verify operator user creation without enabling it.
171 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
172 [Template] Verify Create User Without Enabling
173
174 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500175 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500176
177
178Verify Readonly User Creation Without Enabling It
179 [Documentation] Verify readonly user creation without enabling it.
180 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
181 [Template] Verify Create User Without Enabling
182
183 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600184 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500185
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500186
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500187Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500188 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500189 [Tags] Verify_User_Creation_With_Invalid_Role_Id
190
191 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600192 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500193 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
194
195 # Create specified user.
196 ${payload}= Create Dictionary
197 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600198 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500199 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
200
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500201Verify Error Upon Creating Same Users With Different Privileges
202 [Documentation] Verify error upon creating same users with different privileges.
203 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
204
205 Redfish Create User test_user TestPwd123 Administrator ${True}
206
207 # Create specified user.
208 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500209 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600210 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500211 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
212
Anusha Dathatri466816f2020-01-30 05:12:36 -0600213 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500214
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500215
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500216Verify Modifying User Attributes
217 [Documentation] Verify modifying user attributes.
218 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500219
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500220 # Create Redfish users.
221 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600222 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500223
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500224 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600225 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500226 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
227
228 # Update admin_user username using Redfish.
229 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600230 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530231 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500232
Anusha Dathatri4062b442020-02-03 04:39:15 -0600233 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500234 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600235 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530236 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500237
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500238 # Verify users after updating
239 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500240 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500241
242 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600243 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600244 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500245
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500246
247Verify Modifying Operator User Attributes
248 [Documentation] Verify modifying operator user attributes.
249 [Tags] Verify_Modifying_Operator_User_Attributes
250 [Setup] Run Keywords Redfish.Login AND
251 ... Redfish Create User operator_user TestPwd123 Operator ${True}
252 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
253 ... AND Test Teardown Execution
254
255 # Update operator_user password using Redfish.
256 ${payload}= Create Dictionary Password=NewTestPwd123
257 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800258 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500259
260 # Verify users after updating
261 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
262
263
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500264Verify User Account Locked
265 [Documentation] Verify user account locked upon trying with invalid password.
266 [Tags] Verify_User_Account_Locked
267
268 Redfish Create User admin_user TestPwd123 Administrator ${True}
269
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500270 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
271 ... AccountLockoutDuration=${account_lockout_duration}
272 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530273 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500274
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500275 Redfish.Logout
276
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500277 # Make ${account_lockout_threshold} failed login attempts.
278 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500279 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500280
281 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500282 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500283 ... Redfish.Login admin_user TestPwd123
284
Vidya-Kalasappanavar344c21d2025-07-01 12:21:05 -0500285 # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout
286 # ... then verify that login works.
287 ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5
288 Sleep ${total_wait_duartion}s
289
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500290 Redfish.Login admin_user TestPwd123
291
292 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500293
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500294 Redfish.Login
295
Anusha Dathatri466816f2020-01-30 05:12:36 -0600296 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500297
aravinth0510746884b2022-09-29 16:04:07 +0000298
299Verify User Account Unlock
300 [Documentation] Verify manually unlocking the account before lockout time
301 [Tags] Verify_User_Account_Unlock
Igor Kanyuka0e81d992025-11-24 10:59:14 +0000302 [Teardown] Run Keywords SSHLibrary.Close All Connections
303 ... AND Redfish.Logout
George Keishinga36926b2023-05-17 21:54:34 +0530304 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000305 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
aravinth0510746884b2022-09-29 16:04:07 +0000306
307 Redfish Create User test_user TestPwd123 Administrator ${True}
308
309 ${payload}= Create Dictionary
310 ... AccountLockoutThreshold=${account_lockout_threshold}
311 ... AccountLockoutDuration=${account_lockout_duration}
312 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800313 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
aravinth0510746884b2022-09-29 16:04:07 +0000314
315 Redfish.Logout
316
317 # Make ${account_lockout_threshold} failed login attempts.
318 Repeat Keyword ${account_lockout_threshold} times
319 ... Run Keyword And Expect Error InvalidCredentialsError*
320 ... Redfish.Login test_user abc123
321
322 # Ensure SSH Login with locked account gets failed
323 SSHLibrary.Open Connection ${OPENBMC_HOST}
324 Run Keyword And Expect Error Authentication failed*
325 ... SSHLibrary.Login test_user TestPwd123
326
327 # Verify that legitimate login fails due to lockout.
328 Run Keyword And Expect Error InvalidCredentialsError*
329 ... Redfish.Login test_user TestPwd123
330
331 ${payload}= Create Dictionary Locked=${FALSE}
332
333 # Manually unlock the account before lockout threshold expires
334 Redfish.Login
335 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800336 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
aravinth0510746884b2022-09-29 16:04:07 +0000337 Redfish.Logout
338
339 # Try redfish login with the recently unlocked account
340 Redfish.Login test_user TestPwd123
341
342 # Try SSH login with the unlocked account
343 SSHLibrary.Open Connection ${OPENBMC_HOST}
344 SSHLibrary.Login test_user TestPwd123
345
346
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500347Verify Admin User Privilege
348 [Documentation] Verify admin user privilege.
349 [Tags] Verify_Admin_User_Privilege
350
351 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600352 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500353
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500354 Redfish.Logout
355
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500356 Redfish.Login admin_user TestPwd123
357
358 # Change password of 'readonly' user with admin user.
359 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800360 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500361
362 # Verify modified user.
363 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
364
365 # Note: Delete user would work here because a root login is
366 # performed as part of "Redfish Verify User" keyword's teardown.
367 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
368 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
369
370
371Verify Operator User Role Change Using Admin Privilege User
372 [Documentation] Verify operator user role change using admin privilege user
373 [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User
374
375 Redfish Create User admin_user TestPwd123 Administrator ${True}
376 Redfish Create User operator_user TestPwd123 Operator ${True}
377
378 Redfish.Logout
379
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500380 # Change role ID of operator user with admin user.
381 # Login with admin user.
382 Redfish.Login admin_user TestPwd123
383
384 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600385 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800386 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500387
388 # Verify modified user.
389 Redfish Verify User operator_user TestPwd123 Administrator ${True}
390
Anusha Dathatri466816f2020-01-30 05:12:36 -0600391 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
392 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500393
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500394
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500395Verify Operator User Privilege
396 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600397 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500398
399 Redfish Create User admin_user TestPwd123 Administrator ${True}
400 Redfish Create User operator_user TestPwd123 Operator ${True}
401
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500402 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500403 # Login with operator user.
404 Redfish.Login operator_user TestPwd123
405
George Keishing093c1bd2020-02-10 09:47:34 -0600406 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500407 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500408
409 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600410 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500411 ... valid_status_codes=[${HTTP_FORBIDDEN}]
412
413 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500414
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500415 Redfish.Login
416
Anusha Dathatri466816f2020-01-30 05:12:36 -0600417 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
418 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500419
420
Anusha Dathatri4062b442020-02-03 04:39:15 -0600421Verify ReadOnly User Privilege
422 [Documentation] Verify ReadOnly user privilege.
423 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500424
Anusha Dathatri4062b442020-02-03 04:39:15 -0600425 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500426 Redfish.Logout
427
428 # Login with read_only user.
429 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500430
431 # Read system level data.
432 ${system_model}= Redfish_Utils.Get Attribute
433 ... ${SYSTEM_BASE_URI} Model
434
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500435 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500436 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600437 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500438
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500439
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500440Verify Minimum Password Length For Redfish Admin And Readonly User
441 [Documentation] Verify minimum password length for new and existing admin or
442 ... readonly user.
443 [Template] Verify Minimum Password Length For Redfish User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600444
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500445 #username role_id
446 admin_user Administrator
447 readonly_user ReadOnly
Anusha Dathatri466816f2020-01-30 05:12:36 -0600448
449
Tony Lee94335f42021-02-04 15:16:39 +0800450Verify Standard User Roles Defined By Redfish
451 [Documentation] Verify standard user roles defined by Redfish.
452 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
453
454 ${member_list}= Redfish_Utils.Get Member List
455 ... /redfish/v1/AccountService/Roles
456
457 @{roles}= Create List
458 ... /redfish/v1/AccountService/Roles/Administrator
459 ... /redfish/v1/AccountService/Roles/Operator
460 ... /redfish/v1/AccountService/Roles/ReadOnly
461
462 List Should Contain Sub List ${member_list} ${roles}
463
464 # The standard roles are:
465
466 # | Role name | Assigned privileges |
467 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
468 # | Operator | Login, ConfigureComponents, ConfigureSelf |
469 # | ReadOnly | Login, ConfigureSelf |
470
471 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
472 @{operator}= Create List Login ConfigureComponents ConfigureSelf
473 @{readOnly}= Create List Login ConfigureSelf
474
475 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
476 ... readOnly_privileges=${readOnly}
477
478 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
479 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
480
481 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
482 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
483
484 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
485 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
486
487
manashsarma4910aa22021-07-26 09:12:36 -0500488Verify Error While Deleting Root User
489 [Documentation] Verify error while deleting root user.
490 [Tags] Verify_Error_While_Deleting_Root_User
491
492 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
493
494
manashsarma654cbc12021-09-23 02:28:12 -0500495Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530496 [Documentation] Verify that admin user have SSH login access.
497 ... By default, admin should have access but there could be
498 ... case where admin user shell access is restricted by design
499 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500500 [Tags] Verify_SSH_Login_Access_With_Admin_User
501
Nandakumar Ba4887be2025-11-05 19:27:31 +0530502 #Create an admin user and verify SSH login.
503 Create Admin User And Verify SSH Login
manashsarma654cbc12021-09-23 02:28:12 -0500504
George Keishinge8015b32022-09-19 09:38:47 -0500505 Redfish.Login
506 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
507
Nandakumar-AMI45830792025-10-30 13:15:15 +0530508Verify SSH Login Is Revoked For Deleted User
509 [Documentation] Verify SSH login access is revoked for deleted User.
510 [Tags] Verify_SSH_Login_Is_Revoked_For_Deleted_User
511
512 #Create an admin user and verify SSH login.
513 Create Admin User And Verify SSH Login
514
515 #Login with root user.
516 Redfish.Login
517
518 # Delete the admin user.
519 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
520 ... valid_status_codes=[${HTTP_OK}]
521
522 # Attempt SSH login with Deleted user.
523 SSHLibrary.Open Connection ${OPENBMC_HOST}
524 Run Keyword And Expect Error Authentication failed*
525 ... SSHLibrary.Login new_admin TestPwd1
manashsarma654cbc12021-09-23 02:28:12 -0500526
aravinth0510746884b2022-09-29 16:04:07 +0000527Verify Configure BasicAuth Enable And Disable
528 [Documentation] Verify configure basicauth enable and disable
529 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
530 [Template] Template For Configure Auth Methods
531
532 # auth_method
533 BasicAuth
534 XToken
535
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500536
537Redfish Create and Verify Admin User With Invalid Password Format
538 [Documentation] Create a admin user with invalid password format and verify.
539 [Template] Create User With Unsupported Password Format And Verify
540 [Tags] Redfish_Create_and_Verify_Admin_User_With_Invalid_Password_Format
541
542 #username role_id password
543 admin_user Administrator snellens
544 admin_user Administrator 10000001
545 admin_user Administrator 12345678
546 admin_user Administrator abcdefgh
547 admin_user Administrator abf12345
548 admin_user Administrator helloworld
549 admin_user Administrator HELLOWORLD
550 admin_user Administrator &$%**!*@
551 admin_user Administrator Dictation
552
553
554Redfish Create and Verify Readonly User With Invalid Password Format
555 [Documentation] Create a readonly user with invalid password format and verify.
556 [Template] Create User With Unsupported Password Format And Verify
557 [Tags] Redfish_Create_and_Verify_Readonly_User_With_Invalid_Password_Format
558
559 #username role_id password
560 readonly_user ReadOnly snellens
561 readonly_user ReadOnly 10000001
562 readonly_user ReadOnly 12345678
563 readonly_user ReadOnly abcdefgh
564 readonly_user ReadOnly abf12345
565 readonly_user ReadOnly helloworld
566 readonly_user ReadOnly HELLOWORLD
567 readonly_user ReadOnly &$%**!*@
568 readonly_user ReadOnly Dictation
569
570
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500571Verify Admin And Readonly User Password Is Not Same As Username
572 [Documentation] Verify that admin and readonly user creation is failed if
573 ... password is same as username.
574 [Template] Create User With Unsupported Password Format And Verify
575 [Tags] Verify_Admin_And_Readonly_User_Password_Is_Not_Same_As_Username
576
577 #username role_id password
578 AdminUser1 Administrator AdminUser1
579 ReadOnlyUser1 ReadOnly ReadOnlyUser1
580
IanLaiAMI597181e2025-10-07 12:03:59 +0800581Verify AccountService Unsupported Methods
582 [Documentation] Verify Unsupported methods of AccountService
583 [Tags] Verify_AccountService_Unsupported_Methods
584
585 # Put operation on Account Services
586 Redfish.Put /redfish/v1/AccountService
587 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
588
589 # Post operation on Account Services
590 Redfish.Post /redfish/v1/AccountService
591 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
592
593 # Delete operation on Account Services
594 Redfish.Delete /redfish/v1/AccountService
595 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
596
Ian Lai63c31422025-10-27 12:32:24 +0800597Verify AccountService Roles Unsupported Methods
598 [Documentation] Verify Unsupported methods of AccountService/Roles
599 [Tags] Verify_AccountService_Roles_Unsupported_Methods
600
601 # Put operation on Account Services Roles
602 Redfish.Put /redfish/v1/AccountService/Roles
603 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
604
605 # Post operation on Account Services Roles
606 Redfish.Post /redfish/v1/AccountService/Roles
607 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
608
609 # Delete operation on Account Services Roles
610 Redfish.Delete /redfish/v1/AccountService/Roles
611 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
612
613 # Patch operation on Account Services Roles
614 Redfish.Patch /redfish/v1/AccountService/Roles
615 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
616
Nandakumar-AMI45830792025-10-30 13:15:15 +0530617Verify AccountService Roles Instance With Unsupported Methods
618 [Documentation] Verify Instance Roles for AccountService and Unsupported Methods
619 [Tags] Verify_AccountService_Roles_Instance_With_Unsupported_Methods
620
621 # GET Administrator Role Instance
622 Redfish.Get /redfish/v1/AccountService/Roles/Administrator
623 ... valid_status_codes=[${HTTP_OK}]
624
625 # GET Operator Role Instance
626 Redfish.Get /redfish/v1/AccountService/Roles/Operator
627 ... valid_status_codes=[${HTTP_OK}]
628
629 # GET ReadOnly RoleInstance
630 Redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
631 ... valid_status_codes=[${HTTP_OK}]
632
633 # Post operation on Account Service Roles Instance
634 Redfish.Post /redfish/v1/AccountService/Roles/Administrator
635 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
636
637 # Put operation on Account Service Roles Instance
638 Redfish.Put /redfish/v1/AccountService/Roles/Administrator
639 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
640
641 # Patch operation on Account Service Roles Instance
642 Redfish.Patch /redfish/v1/AccountService/Roles/Administrator
643 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
644
645 #Delete operation on Account Service Roles Instance
646 Redfish.Delete /redfish/v1/AccountService/Roles/Administrator
647 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500648
George Keishingbf1bc712025-11-26 05:09:48 +0000649Verify Account Lockout With Invalid Configuration
kirubakaranbe907fcd2025-11-21 10:19:58 +0000650 [Documentation] Verify Account Lockout configuration with invalid values.
651 [Tags] Verify_Account_Lockout_With_Invalid_Configuration
652
653 @{invalid_values_list}= Create List -1 abc 3.5 ${EMPTY}
654
655 FOR ${invalid_value} IN @{invalid_values_list}
656 ${payload}= Create Dictionary AccountLockoutThreshold=${invalid_value}
657 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
658 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
659
660 ${payload}= Create Dictionary AccountLockoutDuration=${invalid_value}
661 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
662 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
663
664 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
665 ... AccountLockoutDuration=${invalid_value}
666 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
667 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
668
669 ${payload}= Create Dictionary AccountLockoutThreshold=${invalid_value}
670 ... AccountLockoutDuration=${account_lockout_duration}
671 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
672 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
673 END
674
Sivas SRR6aa101f2019-02-19 22:31:55 -0600675*** Keywords ***
676
Sivas SRR6aa101f2019-02-19 22:31:55 -0600677Test Teardown Execution
678 [Documentation] Do the post test teardown.
679
Anusha Dathatridb769702020-02-12 01:02:30 -0600680 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500681 FFDC On Test Case Fail
682
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600683
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500684Redfish Create User
685 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500686 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500687
688 # Description of argument(s):
689 # username The username to be created.
690 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500691 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500692 # (e.g. "Administrator", "Operator", etc.).
693 # enabled Indicates whether the username being created
694 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500695 # login_check Checks user login for created user.
696 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500697
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500698 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600699 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500700 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
701
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500702 # Create specified user.
703 ${payload}= Create Dictionary
704 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600705 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500706 ... valid_status_codes=[${HTTP_CREATED}]
707
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500708 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600709 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500710 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000711
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600712 Bmc Execute Command ${cmd}
713
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500714 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530715 IF '${login_check}' == '${True}'
716 ${status}= Run Keyword And Return Status
717 ... Verify Redfish User Login ${username} ${password}
718 ELSE
719 ${status}= Set Variable ${False}
720 END
721
722 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500723
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500724 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500725 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600726 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500727 Should Be Equal ${role_id} ${role_config}
728
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500729
730Redfish Verify User
731 [Documentation] Redfish user verification.
732 [Arguments] ${username} ${password} ${role_id} ${enabled}
733
734 # Description of argument(s):
735 # username The username to be created.
736 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500737 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500738 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500739 # enabled Indicates whether the username being created
740 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500741
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500742 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500743 # Doing a check of the returned status.
744 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500745
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500746 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500747 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600748 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500749 Should Be Equal ${role_id} ${role_config}
750
751
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500752Verify Redfish User Login
753 [Documentation] Verify Redfish login with given user id.
754 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
755 [Arguments] ${username} ${password}
756
757 # Description of argument(s):
758 # username Login username.
759 # password Login password.
760
761 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600762 # We don't really care if the current session is flushed out since we are going to login
763 # with new credential in next.
764 Run Keyword And Ignore Error Redfish.Logout
765
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500766 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530767 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500768
769
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600770Redfish Create And Verify User
771 [Documentation] Redfish create and verify user.
772 [Arguments] ${username} ${password} ${role_id} ${enabled}
773
774 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500775 # username The username to be created.
776 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500777 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500778 # (e.g. "Administrator", "Operator", etc.).
779 # enabled Indicates whether the username being created
780 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600781
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500782 # Example:
783 #{
784 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
785 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
786 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
787 #"Description": "User Account",
788 #"Enabled": true,
789 #"Id": "test1",
790 #"Links": {
791 # "Role": {
792 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
793 # }
794 #},
795
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500796 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600797
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500798 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600799
800 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600801 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500802
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500803Verify Redfish User Login With Wrong Password
804 [Documentation] Verify Redfish User failed to login with wrong password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500805 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
806
807 # Description of argument(s):
808 # username The username to be created.
809 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500810 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500811 # (e.g. "Administrator", "Operator", etc.).
812 # enabled Indicates whether the username being created
813 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500814 # wrong_password Any invalid password.
815
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500816 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500817
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500818 Redfish.Logout
819
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500820 # Attempt to login with created user with invalid password.
821 Run Keyword And Expect Error InvalidCredentialsError*
822 ... Redfish.Login ${username} ${wrong_password}
823
824 Redfish.Login
825
826 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600827 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500828
829
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500830Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500831 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500832 [Arguments] ${username} ${password} ${role_id} ${enabled}
833
834 # Description of argument(s):
835 # username The username to be created.
836 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500837 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500838 # (e.g. "Administrator", "Operator", etc.).
839 # enabled Indicates whether the username being created
840 # should be enabled (${True}, ${False}).
841
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500842 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500843
844 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600845 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500846
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500847 Redfish.Logout
848
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500849 # Attempt to login with deleted user account.
850 Run Keyword And Expect Error InvalidCredentialsError*
851 ... Redfish.Login ${username} ${password}
852
853 Redfish.Login
854
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500855
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500856Verify Create User Without Enabling
857 [Documentation] Verify Create User Without Enabling.
858 [Arguments] ${username} ${password} ${role_id} ${enabled}
859
860 # Description of argument(s):
861 # username The username to be created.
862 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500863 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500864 # (e.g. "Administrator", "Operator", etc.).
865 # enabled Indicates whether the username being created
866 # should be enabled (${True}, ${False}).
867
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500868 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500869
870 Redfish.Logout
871
872 # Login with created user.
873 Run Keyword And Expect Error InvalidCredentialsError*
874 ... Redfish.Login ${username} ${password}
875
876 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500877
878 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600879 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500880
aravinth0510746884b2022-09-29 16:04:07 +0000881Template For Configure Auth Methods
882 [Documentation] Template to configure auth methods.
883 [Arguments] ${auth_method}
884 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
885
886 # Description of Argument(s):
887 # authmethods The authmethod setting which needs to be
888 # set in account service URI.
889 # valid values BasicAuth, XToken.
890
891 Get AuthMethods Default Values ${auth_method}
892
893 # Patch basicauth to TRUE
894 Configure AuthMethods ${auth_method}=${TRUE}
895
George Keishing79fc7f02025-05-02 00:37:49 +0530896 IF "${auth_method}" == "XToken"
897 Check XToken Works Fine ${HTTP_OK}
898 ELSE
899 Check BasicAuth Works Fine ${HTTP_OK}
900 END
aravinth0510746884b2022-09-29 16:04:07 +0000901
902 # Patch basicauth to FALSE
903 Configure AuthMethods ${auth_method}=${FALSE}
904
George Keishing79fc7f02025-05-02 00:37:49 +0530905 IF "${auth_method}" == "BasicAuth"
906 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
907 ELSE
908 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
909 END
aravinth0510746884b2022-09-29 16:04:07 +0000910
911Configure AuthMethods
912 [Documentation] Enable/disable authmethod types.
913 [Arguments] &{authmethods}
914
915 # Description of argument(s):
916 # authmethods The authmethod setting which needs to be
917 # set in account service URI.
918 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
919 # This will set the value of "XToken" and "BasicAuth"
920 # property in accountservice uri to TRUE.
921
922 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
923 ${oem}= Create Dictionary OpenBMC=${openbmc}
924 ${payload}= Create Dictionary Oem=${oem}
925
926 # Setting authmethod properties using Redfish session based auth
927 ${status}= Run Keyword And Return Status
928 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
929 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
930
George Keishingc63bfe62023-11-15 19:09:59 +0530931 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000932 IF ${status}==${FALSE}
933 # Payload dictionary pre-process to match json formatting
934 ${payload}= Convert To String ${payload}
935 ${payload}= Replace String ${payload} ' "
936 ${payload}= Replace String ${payload} False false
937 ${payload}= Replace String ${payload} True true
938
939 # Curl Command Framing for PATCH authmethod
940 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
941 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
942 ... -H 'content-type:application/json' -H 'If-Match:*'
943 ... -d '${payload}'
944 ${rc} ${out}= Run And Return Rc And Output ${cmd}
945
946 # Check the response of curl command is 200 or 204
947 ${check_no_content}=
948 ... Run Keyword and Return Status Should Contain ${out} 204
949 ${check_ok}=
950 ... Run Keyword and Return Status Should Contain ${out} 200
951 Pass Execution If ${check_no_content}==${TRUE}
952 ... OR ${check_ok}==${TRUE}
953 END
954
955
956Get AuthMethods Default Values
957 [Documentation] Get enabled/disabled status of all authmethods
958 ... from Redfish account service URI
959 [Arguments] ${authmethod}
960
961 # Description of argument(s):
962 # authmethod The authmethod property whose value needs to be
963 # retrieved from account service URI.
964 # Usage Example Get AuthMethods Default Values BasicAuth
965 # returns >> ${TRUE}
966 # Example:
967 # {
968 # "@odata.id": "/redfish/v1/AccountService",
969 # (...)
970 # "Oem": {
971 # "OpenBMC": {
972 # "AuthMethods": {
973 # "BasicAuth": true,
974 # "Cookie": true,
975 # "SessionToken": true,
976 # "TLS": true,
977 # "XToken": true
978 # }
979 # }
980 # }
981 # }
982
983 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
984 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
985 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
986 Set Test Variable ${initial_value}
987
988Check XToken Works Fine
989 [Documentation] Verify Xtoken works fine.
990 [Arguments] ${status_code}
991
992 # Description of Argument(s):
993 # status_code : 200, 401.
994
995 # Verify xtoken auth works for xtoken
996 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
997 ... valid_status_codes=[${status_code}]
998
999Check BasicAuth Works Fine
1000 [Documentation] Verify Basic Auth works fine.
1001 [Arguments] ${status_code}
1002
1003 # Description of Argument(s):
1004 # status_code : 200, 401.
1005
1006 # Verify basic auth works based on basic auth.
1007 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
1008 ... ${AUTH_URI}/redfish/v1/AccountService
1009 ${rc} ${out}= Run And Return Rc And Output ${cmd}
1010
1011 # Check the response of curl command is 200/401
1012 Should Contain ${out} ${status_code}
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05001013
1014
1015Create User With Unsupported Password Format And Verify
1016 [Documentation] Create admin or readonly user with unsupported password format
1017 ... and verify.
1018 [Arguments] ${username} ${role_id} ${password}
1019
1020 # Description of argument(s):
1021 # username The username to be created.
1022 # role_id The role ID of the user to be created
1023 # (e.g. "Administrator", "ReadOnly").
1024 # password The password to be assigned.
1025 # Unsupported password format are sequential characters,
1026 # sequential digits, palindrome digits, palindrome characters,
1027 # only uppercase letters, only lowercase letters, only digits,
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -05001028 # only characters, not a dictionary word, username and password
1029 # should not be same.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05001030
1031 # Make sure the user account in question does not already exist.
1032 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
1033 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1034
1035 # Create specified user with invalid password format.
1036 ${payload}= Create Dictionary
1037 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${True}
1038 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1039 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -05001040
1041
1042Verify Minimum Password Length For Redfish User
1043 [Documentation] Verify minimum password length for new and existing admin or
1044 ... readonly user.
1045 [Arguments] ${user_name} ${role_id}
1046
1047 # Description of argument(s):
1048 # user_name The username to be created.
1049 # role_id The role ID of the user to be created.
1050
1051 # Make sure the user account in question does not already exist.
1052 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
1053 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1054
1055 # Try to create a user with invalid length password.
1056 ${payload}= Create Dictionary
1057 ... UserName=${user_name} Password=UserPwd RoleId=${role_id} Enabled=${True}
1058 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1059 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1060
1061 # Create specified user with valid length password.
1062 Set To Dictionary ${payload} Password UserPwd1
1063 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1064 ... valid_status_codes=[${HTTP_CREATED}]
1065
1066 # Try to change to an invalid password.
1067 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
1068 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1069
1070 # Change to a valid password.
1071 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -08001072 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -05001073
1074 # Verify login.
1075 Redfish.Logout
1076 Redfish.Login ${user_name} UserPwd1
1077 Redfish.Logout
1078 Redfish.Login
1079 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
Nandakumar-AMI45830792025-10-30 13:15:15 +05301080
1081Create Admin User And Verify SSH Login
1082 [Documentation] Create admin user and verify SSH login & logout.
1083
1084 # Create an admin User.
1085 Redfish Create User new_admin TestPwd1 Administrator ${True}
1086
1087 # Attempt SSH login with admin user.
1088 SSHLibrary.Open Connection ${OPENBMC_HOST}
1089 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
1090
1091 # By default ssh_status is True, user can change the status via CLI
1092 # -v ssh_status:False
1093 Should Be Equal As Strings "${status}" "${ssh_status}"
1094
1095 # Close SSH connection for admin user.
George Keishingbf1bc712025-11-26 05:09:48 +00001096 SSHLibrary.Close Connection