blob: 166d6b1f5956781b63b08ace963f7dfa5f30cb67 [file] [log] [blame]
Sivas SRR6aa101f2019-02-19 22:31:55 -06001*** Settings ***
2Documentation Test Redfish user account.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -05007Resource ../../lib/bmc_redfish_utils.robot
Sivas SRR6aa101f2019-02-19 22:31:55 -06008
manashsarma654cbc12021-09-23 02:28:12 -05009Library SSHLibrary
10
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -050011Test Setup Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -060012Test Teardown Test Teardown Execution
13
Sandhya Somashekar37122b62019-06-18 06:02:02 -050014*** Variables ***
15
16${account_lockout_duration} ${30}
17${account_lockout_threshold} ${3}
18
George Keishingf8e18192023-07-05 14:26:27 +053019${ssh_status} ${True}
20
Sivas SRR6aa101f2019-02-19 22:31:55 -060021** Test Cases **
22
23Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060024 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060025 [Tags] Verify_AccountService_Available
26
George Keishing97c93942019-03-04 12:45:07 -060027 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060028 Should Be Equal As Strings ${resp} ${True}
29
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050030
31Verify Redfish Admin User Persistence After Reboot
32 [Documentation] Verify Redfish admin user persistence after reboot.
33 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
34 [Setup] Run Keywords Redfish.Login AND
35 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
36 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
37 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050038
39 # Reboot BMC.
40 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050041
42 # Verify users after reboot.
43 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050044
45
46Verify Redfish Operator User Persistence After Reboot
47 [Documentation] Verify Redfish operator user persistence after reboot.
48 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
49 [Setup] Run Keywords Redfish.Login AND
50 ... Redfish Create User operator_user TestPwd123 Operator ${True}
51 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
52 ... AND Test Teardown Execution
53
54 # Reboot BMC.
55 Redfish OBMC Reboot (off) stack_mode=normal
56
57 # Verify users after reboot.
Sandhya Somashekara83fb472019-08-29 02:26:21 -050058 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050059
60
61Verify Redfish Readonly User Persistence After Reboot
62 [Documentation] Verify Redfish readonly user persistence after reboot.
63 [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot
64 [Setup] Run Keywords Redfish.Login AND
65 ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
66 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
67 ... AND Test Teardown Execution
68
69 # Reboot BMC.
70 Redfish OBMC Reboot (off) stack_mode=normal
71
72 # Verify users after reboot.
Anusha Dathatri4062b442020-02-03 04:39:15 -060073 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050074
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
103Verify Redfish Admin User With Wrong Password
104 [Documentation] Verify Redfish admin user with wrong password.
105 [Tags] Verify_Redfish_Admin_User_With_Wrong_Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500106 [Template] Verify Redfish User with Wrong Password
107
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500108 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500109 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500110
111
112Verify Redfish Operator User with Wrong Password
113 [Documentation] Verify Redfish operator user with wrong password.
114 [Tags] Verify_Redfish_Operator_User_with_Wrong_Password
115 [Template] Verify Redfish User with Wrong Password
116
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
121Verify Redfish Readonly User With Wrong Password
122 [Documentation] Verify Redfish readonly user with wrong password.
123 [Tags] Verify_Redfish_Readonly_User_With_Wrong_Password
124 [Template] Verify Redfish User with Wrong Password
125
126 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600127 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500128
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500129
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500130Verify Login with Deleted Redfish Admin User
131 [Documentation] Verify login with deleted Redfish admin user.
132 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500133 [Template] Verify Login with Deleted Redfish User
134
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500135 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500136 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500137
138
139Verify Login with Deleted Redfish Operator User
140 [Documentation] Verify login with deleted Redfish operator user.
141 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
142 [Template] Verify Login with Deleted Redfish User
143
144 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500145 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500146
147
148Verify Login with Deleted Redfish Readonly User
149 [Documentation] Verify login with deleted Redfish readonly user.
150 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
151 [Template] Verify Login with Deleted Redfish User
152
153 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600154 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500155
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500156
157Verify Admin User Creation Without Enabling It
158 [Documentation] Verify admin user creation without enabling it.
159 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500160 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500161
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500162 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500163 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500164
165
166Verify Operator User Creation Without Enabling It
167 [Documentation] Verify operator user creation without enabling it.
168 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
169 [Template] Verify Create User Without Enabling
170
171 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500172 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500173
174
175Verify Readonly User Creation Without Enabling It
176 [Documentation] Verify readonly user creation without enabling it.
177 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
178 [Template] Verify Create User Without Enabling
179
180 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600181 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500182
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500183
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500184Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500185 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500186 [Tags] Verify_User_Creation_With_Invalid_Role_Id
187
188 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600189 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500190 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
191
192 # Create specified user.
193 ${payload}= Create Dictionary
194 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600195 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500196 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
197
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500198Verify Error Upon Creating Same Users With Different Privileges
199 [Documentation] Verify error upon creating same users with different privileges.
200 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
201
202 Redfish Create User test_user TestPwd123 Administrator ${True}
203
204 # Create specified user.
205 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500206 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600207 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500208 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
209
Anusha Dathatri466816f2020-01-30 05:12:36 -0600210 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500211
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500212
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500213Verify Modifying User Attributes
214 [Documentation] Verify modifying user attributes.
215 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500216
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500217 # Create Redfish users.
218 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600219 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500220
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500221 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600222 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500223 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
224
225 # Update admin_user username using Redfish.
226 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600227 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530228 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500229
Anusha Dathatri4062b442020-02-03 04:39:15 -0600230 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500231 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600232 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530233 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500234
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500235 # Verify users after updating
236 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500237 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500238
239 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600240 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600241 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500242
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500243
244Verify Modifying Operator User Attributes
245 [Documentation] Verify modifying operator user attributes.
246 [Tags] Verify_Modifying_Operator_User_Attributes
247 [Setup] Run Keywords Redfish.Login AND
248 ... Redfish Create User operator_user TestPwd123 Operator ${True}
249 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
250 ... AND Test Teardown Execution
251
252 # Update operator_user password using Redfish.
253 ${payload}= Create Dictionary Password=NewTestPwd123
254 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
255
256 # Verify users after updating
257 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
258
259
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500260Verify User Account Locked
261 [Documentation] Verify user account locked upon trying with invalid password.
262 [Tags] Verify_User_Account_Locked
263
264 Redfish Create User admin_user TestPwd123 Administrator ${True}
265
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500266 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
267 ... AccountLockoutDuration=${account_lockout_duration}
268 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530269 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500270
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500271 Redfish.Logout
272
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500273 # Make ${account_lockout_threshold} failed login attempts.
274 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500275 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500276
277 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500278 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500279 ... Redfish.Login admin_user TestPwd123
280
281 # Wait for lockout duration to expire and then verify that login works.
282 Sleep ${account_lockout_duration}s
283 Redfish.Login admin_user TestPwd123
284
285 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500286
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500287 Redfish.Login
288
Anusha Dathatri466816f2020-01-30 05:12:36 -0600289 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500290
aravinth0510746884b2022-09-29 16:04:07 +0000291
292Verify User Account Unlock
293 [Documentation] Verify manually unlocking the account before lockout time
294 [Tags] Verify_User_Account_Unlock
George Keishinga36926b2023-05-17 21:54:34 +0530295 [Teardown] Run Keywords Redfish.Logout
296 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000297 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
298 ... AND SSHLibrary.Close All Connections
299
300 Redfish Create User test_user TestPwd123 Administrator ${True}
301
302 ${payload}= Create Dictionary
303 ... AccountLockoutThreshold=${account_lockout_threshold}
304 ... AccountLockoutDuration=${account_lockout_duration}
305 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
306
307 Redfish.Logout
308
309 # Make ${account_lockout_threshold} failed login attempts.
310 Repeat Keyword ${account_lockout_threshold} times
311 ... Run Keyword And Expect Error InvalidCredentialsError*
312 ... Redfish.Login test_user abc123
313
314 # Ensure SSH Login with locked account gets failed
315 SSHLibrary.Open Connection ${OPENBMC_HOST}
316 Run Keyword And Expect Error Authentication failed*
317 ... SSHLibrary.Login test_user TestPwd123
318
319 # Verify that legitimate login fails due to lockout.
320 Run Keyword And Expect Error InvalidCredentialsError*
321 ... Redfish.Login test_user TestPwd123
322
323 ${payload}= Create Dictionary Locked=${FALSE}
324
325 # Manually unlock the account before lockout threshold expires
326 Redfish.Login
327 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
328 Redfish.Logout
329
330 # Try redfish login with the recently unlocked account
331 Redfish.Login test_user TestPwd123
332
333 # Try SSH login with the unlocked account
334 SSHLibrary.Open Connection ${OPENBMC_HOST}
335 SSHLibrary.Login test_user TestPwd123
336
337
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500338Verify Admin User Privilege
339 [Documentation] Verify admin user privilege.
340 [Tags] Verify_Admin_User_Privilege
341
342 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600343 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500344
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500345 Redfish.Logout
346
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500347 Redfish.Login admin_user TestPwd123
348
349 # Change password of 'readonly' user with admin user.
350 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
351
352 # Verify modified user.
353 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
354
355 # Note: Delete user would work here because a root login is
356 # performed as part of "Redfish Verify User" keyword's teardown.
357 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
358 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
359
360
361Verify Operator User Role Change Using Admin Privilege User
362 [Documentation] Verify operator user role change using admin privilege user
363 [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User
364
365 Redfish Create User admin_user TestPwd123 Administrator ${True}
366 Redfish Create User operator_user TestPwd123 Operator ${True}
367
368 Redfish.Logout
369
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500370 # Change role ID of operator user with admin user.
371 # Login with admin user.
372 Redfish.Login admin_user TestPwd123
373
374 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600375 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500376
377 # Verify modified user.
378 Redfish Verify User operator_user TestPwd123 Administrator ${True}
379
Anusha Dathatri466816f2020-01-30 05:12:36 -0600380 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
381 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500382
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500383
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500384Verify Operator User Privilege
385 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600386 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500387
388 Redfish Create User admin_user TestPwd123 Administrator ${True}
389 Redfish Create User operator_user TestPwd123 Operator ${True}
390
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500391 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500392 # Login with operator user.
393 Redfish.Login operator_user TestPwd123
394
George Keishing093c1bd2020-02-10 09:47:34 -0600395 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500396 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500397
398 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600399 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500400 ... valid_status_codes=[${HTTP_FORBIDDEN}]
401
402 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500403
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500404 Redfish.Login
405
Anusha Dathatri466816f2020-01-30 05:12:36 -0600406 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
407 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500408
409
Anusha Dathatri4062b442020-02-03 04:39:15 -0600410Verify ReadOnly User Privilege
411 [Documentation] Verify ReadOnly user privilege.
412 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500413
Anusha Dathatri4062b442020-02-03 04:39:15 -0600414 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500415 Redfish.Logout
416
417 # Login with read_only user.
418 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500419
420 # Read system level data.
421 ${system_model}= Redfish_Utils.Get Attribute
422 ... ${SYSTEM_BASE_URI} Model
423
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500424 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500425 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600426 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500427
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500428
Anusha Dathatri466816f2020-01-30 05:12:36 -0600429Verify Minimum Password Length For Redfish User
430 [Documentation] Verify minimum password length for new and existing user.
431 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
432
433 ${user_name}= Set Variable testUser
434
435 # Make sure the user account in question does not already exist.
436 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
437 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
438
439 # Try to create a user with invalid length password.
440 ${payload}= Create Dictionary
441 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
442 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
443 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
444
445 # Create specified user with valid length password.
446 Set To Dictionary ${payload} Password UserPwd1
447 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
448 ... valid_status_codes=[${HTTP_CREATED}]
449
450 # Try to change to an invalid password.
451 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
452 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
453
454 # Change to a valid password.
455 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
456
457 # Verify login.
458 Redfish.Logout
459 Redfish.Login ${user_name} UserPwd1
460 Redfish.Logout
461 Redfish.Login
462 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
463
464
Tony Lee94335f42021-02-04 15:16:39 +0800465Verify Standard User Roles Defined By Redfish
466 [Documentation] Verify standard user roles defined by Redfish.
467 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
468
469 ${member_list}= Redfish_Utils.Get Member List
470 ... /redfish/v1/AccountService/Roles
471
472 @{roles}= Create List
473 ... /redfish/v1/AccountService/Roles/Administrator
474 ... /redfish/v1/AccountService/Roles/Operator
475 ... /redfish/v1/AccountService/Roles/ReadOnly
476
477 List Should Contain Sub List ${member_list} ${roles}
478
479 # The standard roles are:
480
481 # | Role name | Assigned privileges |
482 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
483 # | Operator | Login, ConfigureComponents, ConfigureSelf |
484 # | ReadOnly | Login, ConfigureSelf |
485
486 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
487 @{operator}= Create List Login ConfigureComponents ConfigureSelf
488 @{readOnly}= Create List Login ConfigureSelf
489
490 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
491 ... readOnly_privileges=${readOnly}
492
493 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
494 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
495
496 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
497 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
498
499 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
500 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
501
502
manashsarma4910aa22021-07-26 09:12:36 -0500503Verify Error While Deleting Root User
504 [Documentation] Verify error while deleting root user.
505 [Tags] Verify_Error_While_Deleting_Root_User
506
507 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
508
509
manashsarma654cbc12021-09-23 02:28:12 -0500510Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530511 [Documentation] Verify that admin user have SSH login access.
512 ... By default, admin should have access but there could be
513 ... case where admin user shell access is restricted by design
514 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500515 [Tags] Verify_SSH_Login_Access_With_Admin_User
516
517 # Create an admin User.
518 Redfish Create User new_admin TestPwd1 Administrator ${True}
519
520 # Attempt SSH login with admin user.
521 SSHLibrary.Open Connection ${OPENBMC_HOST}
522 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
George Keishingf8e18192023-07-05 14:26:27 +0530523
524 # By default ssh_status is True, user can change the status via CLI
525 # -v ssh_status:False
526 Should Be Equal As Strings "${status}" "${ssh_status}"
manashsarma654cbc12021-09-23 02:28:12 -0500527
George Keishinge8015b32022-09-19 09:38:47 -0500528 Redfish.Login
529 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
530
manashsarma654cbc12021-09-23 02:28:12 -0500531
aravinth0510746884b2022-09-29 16:04:07 +0000532Verify Configure BasicAuth Enable And Disable
533 [Documentation] Verify configure basicauth enable and disable
534 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
535 [Template] Template For Configure Auth Methods
536
537 # auth_method
538 BasicAuth
539 XToken
540
Sivas SRR6aa101f2019-02-19 22:31:55 -0600541*** Keywords ***
542
Sivas SRR6aa101f2019-02-19 22:31:55 -0600543Test Teardown Execution
544 [Documentation] Do the post test teardown.
545
Anusha Dathatridb769702020-02-12 01:02:30 -0600546 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500547 FFDC On Test Case Fail
548
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600549
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500550Redfish Create User
551 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500552 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500553
554 # Description of argument(s):
555 # username The username to be created.
556 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500557 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500558 # (e.g. "Administrator", "Operator", etc.).
559 # enabled Indicates whether the username being created
560 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500561 # login_check Checks user login for created user.
562 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500563
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500564 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600565 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500566 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
567
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500568 # Create specified user.
569 ${payload}= Create Dictionary
570 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600571 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500572 ... valid_status_codes=[${HTTP_CREATED}]
573
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500574 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600575 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500576 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000577
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600578 Bmc Execute Command ${cmd}
579
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500580 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530581 IF '${login_check}' == '${True}'
582 ${status}= Run Keyword And Return Status
583 ... Verify Redfish User Login ${username} ${password}
584 ELSE
585 ${status}= Set Variable ${False}
586 END
587
588 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500589
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500590 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500591 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600592 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500593 Should Be Equal ${role_id} ${role_config}
594
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500595
596Redfish Verify User
597 [Documentation] Redfish user verification.
598 [Arguments] ${username} ${password} ${role_id} ${enabled}
599
600 # Description of argument(s):
601 # username The username to be created.
602 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500603 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500604 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500605 # enabled Indicates whether the username being created
606 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500607
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500608 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500609 # Doing a check of the returned status.
610 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500611
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500612 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500613 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600614 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500615 Should Be Equal ${role_id} ${role_config}
616
617
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500618Verify Redfish User Login
619 [Documentation] Verify Redfish login with given user id.
620 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
621 [Arguments] ${username} ${password}
622
623 # Description of argument(s):
624 # username Login username.
625 # password Login password.
626
627 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600628 # We don't really care if the current session is flushed out since we are going to login
629 # with new credential in next.
630 Run Keyword And Ignore Error Redfish.Logout
631
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500632 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530633 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500634
635
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600636Redfish Create And Verify User
637 [Documentation] Redfish create and verify user.
638 [Arguments] ${username} ${password} ${role_id} ${enabled}
639
640 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500641 # username The username to be created.
642 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500643 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500644 # (e.g. "Administrator", "Operator", etc.).
645 # enabled Indicates whether the username being created
646 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600647
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500648 # Example:
649 #{
650 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
651 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
652 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
653 #"Description": "User Account",
654 #"Enabled": true,
655 #"Id": "test1",
656 #"Links": {
657 # "Role": {
658 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
659 # }
660 #},
661
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500662 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600663
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500664 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600665
666 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600667 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500668
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500669Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500670 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500671 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
672
673 # Description of argument(s):
674 # username The username to be created.
675 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500676 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500677 # (e.g. "Administrator", "Operator", etc.).
678 # enabled Indicates whether the username being created
679 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500680 # wrong_password Any invalid password.
681
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500682 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500683
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500684 Redfish.Logout
685
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500686 # Attempt to login with created user with invalid password.
687 Run Keyword And Expect Error InvalidCredentialsError*
688 ... Redfish.Login ${username} ${wrong_password}
689
690 Redfish.Login
691
692 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600693 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500694
695
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500696Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500697 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500698 [Arguments] ${username} ${password} ${role_id} ${enabled}
699
700 # Description of argument(s):
701 # username The username to be created.
702 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500703 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500704 # (e.g. "Administrator", "Operator", etc.).
705 # enabled Indicates whether the username being created
706 # should be enabled (${True}, ${False}).
707
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500708 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500709
710 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600711 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500712
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500713 Redfish.Logout
714
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500715 # Attempt to login with deleted user account.
716 Run Keyword And Expect Error InvalidCredentialsError*
717 ... Redfish.Login ${username} ${password}
718
719 Redfish.Login
720
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500721
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500722Verify Create User Without Enabling
723 [Documentation] Verify Create User Without Enabling.
724 [Arguments] ${username} ${password} ${role_id} ${enabled}
725
726 # Description of argument(s):
727 # username The username to be created.
728 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500729 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500730 # (e.g. "Administrator", "Operator", etc.).
731 # enabled Indicates whether the username being created
732 # should be enabled (${True}, ${False}).
733
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500734 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500735
736 Redfish.Logout
737
738 # Login with created user.
739 Run Keyword And Expect Error InvalidCredentialsError*
740 ... Redfish.Login ${username} ${password}
741
742 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500743
744 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600745 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500746
aravinth0510746884b2022-09-29 16:04:07 +0000747Template For Configure Auth Methods
748 [Documentation] Template to configure auth methods.
749 [Arguments] ${auth_method}
750 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
751
752 # Description of Argument(s):
753 # authmethods The authmethod setting which needs to be
754 # set in account service URI.
755 # valid values BasicAuth, XToken.
756
757 Get AuthMethods Default Values ${auth_method}
758
759 # Patch basicauth to TRUE
760 Configure AuthMethods ${auth_method}=${TRUE}
761
George Keishing79fc7f02025-05-02 00:37:49 +0530762 IF "${auth_method}" == "XToken"
763 Check XToken Works Fine ${HTTP_OK}
764 ELSE
765 Check BasicAuth Works Fine ${HTTP_OK}
766 END
aravinth0510746884b2022-09-29 16:04:07 +0000767
768 # Patch basicauth to FALSE
769 Configure AuthMethods ${auth_method}=${FALSE}
770
George Keishing79fc7f02025-05-02 00:37:49 +0530771 IF "${auth_method}" == "BasicAuth"
772 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
773 ELSE
774 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
775 END
aravinth0510746884b2022-09-29 16:04:07 +0000776
777Configure AuthMethods
778 [Documentation] Enable/disable authmethod types.
779 [Arguments] &{authmethods}
780
781 # Description of argument(s):
782 # authmethods The authmethod setting which needs to be
783 # set in account service URI.
784 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
785 # This will set the value of "XToken" and "BasicAuth"
786 # property in accountservice uri to TRUE.
787
788 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
789 ${oem}= Create Dictionary OpenBMC=${openbmc}
790 ${payload}= Create Dictionary Oem=${oem}
791
792 # Setting authmethod properties using Redfish session based auth
793 ${status}= Run Keyword And Return Status
794 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
795 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
796
George Keishingc63bfe62023-11-15 19:09:59 +0530797 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000798 IF ${status}==${FALSE}
799 # Payload dictionary pre-process to match json formatting
800 ${payload}= Convert To String ${payload}
801 ${payload}= Replace String ${payload} ' "
802 ${payload}= Replace String ${payload} False false
803 ${payload}= Replace String ${payload} True true
804
805 # Curl Command Framing for PATCH authmethod
806 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
807 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
808 ... -H 'content-type:application/json' -H 'If-Match:*'
809 ... -d '${payload}'
810 ${rc} ${out}= Run And Return Rc And Output ${cmd}
811
812 # Check the response of curl command is 200 or 204
813 ${check_no_content}=
814 ... Run Keyword and Return Status Should Contain ${out} 204
815 ${check_ok}=
816 ... Run Keyword and Return Status Should Contain ${out} 200
817 Pass Execution If ${check_no_content}==${TRUE}
818 ... OR ${check_ok}==${TRUE}
819 END
820
821
822Get AuthMethods Default Values
823 [Documentation] Get enabled/disabled status of all authmethods
824 ... from Redfish account service URI
825 [Arguments] ${authmethod}
826
827 # Description of argument(s):
828 # authmethod The authmethod property whose value needs to be
829 # retrieved from account service URI.
830 # Usage Example Get AuthMethods Default Values BasicAuth
831 # returns >> ${TRUE}
832 # Example:
833 # {
834 # "@odata.id": "/redfish/v1/AccountService",
835 # (...)
836 # "Oem": {
837 # "OpenBMC": {
838 # "AuthMethods": {
839 # "BasicAuth": true,
840 # "Cookie": true,
841 # "SessionToken": true,
842 # "TLS": true,
843 # "XToken": true
844 # }
845 # }
846 # }
847 # }
848
849 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
850 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
851 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
852 Set Test Variable ${initial_value}
853
854Check XToken Works Fine
855 [Documentation] Verify Xtoken works fine.
856 [Arguments] ${status_code}
857
858 # Description of Argument(s):
859 # status_code : 200, 401.
860
861 # Verify xtoken auth works for xtoken
862 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
863 ... valid_status_codes=[${status_code}]
864
865Check BasicAuth Works Fine
866 [Documentation] Verify Basic Auth works fine.
867 [Arguments] ${status_code}
868
869 # Description of Argument(s):
870 # status_code : 200, 401.
871
872 # Verify basic auth works based on basic auth.
873 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
874 ... ${AUTH_URI}/redfish/v1/AccountService
875 ${rc} ${out}= Run And Return Rc And Output ${cmd}
876
877 # Check the response of curl command is 200/401
878 Should Contain ${out} ${status_code}