blob: f2eeef13c5d849734a0470dfe3e5ff426a091334 [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}
George Keishingf8e18192023-07-05 14:26:27 +053018${ssh_status} ${True}
19
Sivas SRR6aa101f2019-02-19 22:31:55 -060020** Test Cases **
21
22Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060023 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060024 [Tags] Verify_AccountService_Available
25
George Keishing97c93942019-03-04 12:45:07 -060026 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060027 Should Be Equal As Strings ${resp} ${True}
28
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050029
30Verify Redfish Admin User Persistence After Reboot
31 [Documentation] Verify Redfish admin user persistence after reboot.
32 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
33 [Setup] Run Keywords Redfish.Login AND
34 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
35 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
36 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050037
38 # Reboot BMC.
39 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050040
41 # Verify users after reboot.
42 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050043
44
45Verify Redfish Operator User Persistence After Reboot
46 [Documentation] Verify Redfish operator user persistence after reboot.
47 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
48 [Setup] Run Keywords Redfish.Login AND
49 ... Redfish Create User operator_user TestPwd123 Operator ${True}
50 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
51 ... AND Test Teardown Execution
52
53 # Reboot BMC.
54 Redfish OBMC Reboot (off) stack_mode=normal
55
56 # Verify users after reboot.
Sandhya Somashekara83fb472019-08-29 02:26:21 -050057 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050058
59
60Verify Redfish Readonly User Persistence After Reboot
61 [Documentation] Verify Redfish readonly user persistence after reboot.
62 [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot
63 [Setup] Run Keywords Redfish.Login AND
64 ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
65 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
66 ... AND Test Teardown Execution
67
68 # Reboot BMC.
69 Redfish OBMC Reboot (off) stack_mode=normal
70
71 # Verify users after reboot.
Anusha Dathatri4062b442020-02-03 04:39:15 -060072 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050073
Sandhya Somashekara83fb472019-08-29 02:26:21 -050074
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050075Redfish Create and Verify Admin User
76 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050077 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060078 [Template] Redfish Create And Verify User
79
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050080 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050081 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050082
83
84Redfish Create and Verify Operator User
85 [Documentation] Create a Redfish user with operator role and verify.
86 [Tags] Redfish_Create_and_Verify_Operator_User
87 [Template] Redfish Create And Verify User
88
89 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050090 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050091
92
93Redfish Create and Verify Readonly User
94 [Documentation] Create a Redfish user with readonly role and verify.
95 [Tags] Redfish_Create_and_Verify_Readonly_User
96 [Template] Redfish Create And Verify User
97
98 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -060099 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -0600100
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500101
102Verify Redfish Admin User With Wrong Password
103 [Documentation] Verify Redfish admin user with wrong password.
104 [Tags] Verify_Redfish_Admin_User_With_Wrong_Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500105 [Template] Verify Redfish User with Wrong Password
106
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500107 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500108 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500109
110
111Verify Redfish Operator User with Wrong Password
112 [Documentation] Verify Redfish operator user with wrong password.
113 [Tags] Verify_Redfish_Operator_User_with_Wrong_Password
114 [Template] Verify Redfish User with Wrong Password
115
116 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500117 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500118
119
120Verify Redfish Readonly User With Wrong Password
121 [Documentation] Verify Redfish readonly user with wrong password.
122 [Tags] Verify_Redfish_Readonly_User_With_Wrong_Password
123 [Template] Verify Redfish User with Wrong Password
124
125 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600126 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500127
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500128
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500129Verify Login with Deleted Redfish Admin User
130 [Documentation] Verify login with deleted Redfish admin user.
131 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500132 [Template] Verify Login with Deleted Redfish User
133
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500134 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500135 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500136
137
138Verify Login with Deleted Redfish Operator User
139 [Documentation] Verify login with deleted Redfish operator user.
140 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
141 [Template] Verify Login with Deleted Redfish User
142
143 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500144 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500145
146
147Verify Login with Deleted Redfish Readonly User
148 [Documentation] Verify login with deleted Redfish readonly user.
149 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
150 [Template] Verify Login with Deleted Redfish User
151
152 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600153 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500154
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500155
156Verify Admin User Creation Without Enabling It
157 [Documentation] Verify admin user creation without enabling it.
158 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500159 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500160
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500161 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500162 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500163
164
165Verify Operator User Creation Without Enabling It
166 [Documentation] Verify operator user creation without enabling it.
167 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
168 [Template] Verify Create User Without Enabling
169
170 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500171 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500172
173
174Verify Readonly User Creation Without Enabling It
175 [Documentation] Verify readonly user creation without enabling it.
176 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
177 [Template] Verify Create User Without Enabling
178
179 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600180 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500181
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500182
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500183Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500184 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500185 [Tags] Verify_User_Creation_With_Invalid_Role_Id
186
187 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600188 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500189 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
190
191 # Create specified user.
192 ${payload}= Create Dictionary
193 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600194 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500195 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
196
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500197Verify Error Upon Creating Same Users With Different Privileges
198 [Documentation] Verify error upon creating same users with different privileges.
199 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
200
201 Redfish Create User test_user TestPwd123 Administrator ${True}
202
203 # Create specified user.
204 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500205 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600206 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500207 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
208
Anusha Dathatri466816f2020-01-30 05:12:36 -0600209 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500210
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500211
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500212Verify Modifying User Attributes
213 [Documentation] Verify modifying user attributes.
214 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500215
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500216 # Create Redfish users.
217 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600218 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500219
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500220 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600221 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500222 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
223
224 # Update admin_user username using Redfish.
225 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600226 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530227 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500228
Anusha Dathatri4062b442020-02-03 04:39:15 -0600229 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500230 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600231 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530232 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500233
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500234 # Verify users after updating
235 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500236 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500237
238 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600239 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600240 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500241
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500242
243Verify Modifying Operator User Attributes
244 [Documentation] Verify modifying operator user attributes.
245 [Tags] Verify_Modifying_Operator_User_Attributes
246 [Setup] Run Keywords Redfish.Login AND
247 ... Redfish Create User operator_user TestPwd123 Operator ${True}
248 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
249 ... AND Test Teardown Execution
250
251 # Update operator_user password using Redfish.
252 ${payload}= Create Dictionary Password=NewTestPwd123
253 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
254
255 # Verify users after updating
256 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
257
258
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500259Verify User Account Locked
260 [Documentation] Verify user account locked upon trying with invalid password.
261 [Tags] Verify_User_Account_Locked
262
263 Redfish Create User admin_user TestPwd123 Administrator ${True}
264
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500265 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
266 ... AccountLockoutDuration=${account_lockout_duration}
267 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530268 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500269
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500270 Redfish.Logout
271
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500272 # Make ${account_lockout_threshold} failed login attempts.
273 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500274 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500275
276 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500277 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500278 ... Redfish.Login admin_user TestPwd123
279
Vidya-Kalasappanavar344c21d2025-07-01 12:21:05 -0500280 # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout
281 # ... then verify that login works.
282 ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5
283 Sleep ${total_wait_duartion}s
284
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500285 Redfish.Login admin_user TestPwd123
286
287 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500288
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500289 Redfish.Login
290
Anusha Dathatri466816f2020-01-30 05:12:36 -0600291 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500292
aravinth0510746884b2022-09-29 16:04:07 +0000293
294Verify User Account Unlock
295 [Documentation] Verify manually unlocking the account before lockout time
296 [Tags] Verify_User_Account_Unlock
George Keishinga36926b2023-05-17 21:54:34 +0530297 [Teardown] Run Keywords Redfish.Logout
298 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000299 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
300 ... AND SSHLibrary.Close All Connections
301
302 Redfish Create User test_user TestPwd123 Administrator ${True}
303
304 ${payload}= Create Dictionary
305 ... AccountLockoutThreshold=${account_lockout_threshold}
306 ... AccountLockoutDuration=${account_lockout_duration}
307 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
308
309 Redfish.Logout
310
311 # Make ${account_lockout_threshold} failed login attempts.
312 Repeat Keyword ${account_lockout_threshold} times
313 ... Run Keyword And Expect Error InvalidCredentialsError*
314 ... Redfish.Login test_user abc123
315
316 # Ensure SSH Login with locked account gets failed
317 SSHLibrary.Open Connection ${OPENBMC_HOST}
318 Run Keyword And Expect Error Authentication failed*
319 ... SSHLibrary.Login test_user TestPwd123
320
321 # Verify that legitimate login fails due to lockout.
322 Run Keyword And Expect Error InvalidCredentialsError*
323 ... Redfish.Login test_user TestPwd123
324
325 ${payload}= Create Dictionary Locked=${FALSE}
326
327 # Manually unlock the account before lockout threshold expires
328 Redfish.Login
329 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
330 Redfish.Logout
331
332 # Try redfish login with the recently unlocked account
333 Redfish.Login test_user TestPwd123
334
335 # Try SSH login with the unlocked account
336 SSHLibrary.Open Connection ${OPENBMC_HOST}
337 SSHLibrary.Login test_user TestPwd123
338
339
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500340Verify Admin User Privilege
341 [Documentation] Verify admin user privilege.
342 [Tags] Verify_Admin_User_Privilege
343
344 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600345 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500346
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500347 Redfish.Logout
348
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500349 Redfish.Login admin_user TestPwd123
350
351 # Change password of 'readonly' user with admin user.
352 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
353
354 # Verify modified user.
355 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
356
357 # Note: Delete user would work here because a root login is
358 # performed as part of "Redfish Verify User" keyword's teardown.
359 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
360 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
361
362
363Verify Operator User Role Change Using Admin Privilege User
364 [Documentation] Verify operator user role change using admin privilege user
365 [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User
366
367 Redfish Create User admin_user TestPwd123 Administrator ${True}
368 Redfish Create User operator_user TestPwd123 Operator ${True}
369
370 Redfish.Logout
371
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500372 # Change role ID of operator user with admin user.
373 # Login with admin user.
374 Redfish.Login admin_user TestPwd123
375
376 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600377 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500378
379 # Verify modified user.
380 Redfish Verify User operator_user TestPwd123 Administrator ${True}
381
Anusha Dathatri466816f2020-01-30 05:12:36 -0600382 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
383 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500384
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500385
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500386Verify Operator User Privilege
387 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600388 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500389
390 Redfish Create User admin_user TestPwd123 Administrator ${True}
391 Redfish Create User operator_user TestPwd123 Operator ${True}
392
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500393 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500394 # Login with operator user.
395 Redfish.Login operator_user TestPwd123
396
George Keishing093c1bd2020-02-10 09:47:34 -0600397 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500398 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500399
400 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600401 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500402 ... valid_status_codes=[${HTTP_FORBIDDEN}]
403
404 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500405
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500406 Redfish.Login
407
Anusha Dathatri466816f2020-01-30 05:12:36 -0600408 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
409 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500410
411
Anusha Dathatri4062b442020-02-03 04:39:15 -0600412Verify ReadOnly User Privilege
413 [Documentation] Verify ReadOnly user privilege.
414 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500415
Anusha Dathatri4062b442020-02-03 04:39:15 -0600416 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500417 Redfish.Logout
418
419 # Login with read_only user.
420 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500421
422 # Read system level data.
423 ${system_model}= Redfish_Utils.Get Attribute
424 ... ${SYSTEM_BASE_URI} Model
425
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500426 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500427 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600428 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500429
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500430
Anusha Dathatri466816f2020-01-30 05:12:36 -0600431Verify Minimum Password Length For Redfish User
432 [Documentation] Verify minimum password length for new and existing user.
433 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
434
435 ${user_name}= Set Variable testUser
436
437 # Make sure the user account in question does not already exist.
438 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
439 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
440
441 # Try to create a user with invalid length password.
442 ${payload}= Create Dictionary
443 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
444 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
445 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
446
447 # Create specified user with valid length password.
448 Set To Dictionary ${payload} Password UserPwd1
449 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
450 ... valid_status_codes=[${HTTP_CREATED}]
451
452 # Try to change to an invalid password.
453 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
454 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
455
456 # Change to a valid password.
457 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
458
459 # Verify login.
460 Redfish.Logout
461 Redfish.Login ${user_name} UserPwd1
462 Redfish.Logout
463 Redfish.Login
464 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
465
466
Tony Lee94335f42021-02-04 15:16:39 +0800467Verify Standard User Roles Defined By Redfish
468 [Documentation] Verify standard user roles defined by Redfish.
469 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
470
471 ${member_list}= Redfish_Utils.Get Member List
472 ... /redfish/v1/AccountService/Roles
473
474 @{roles}= Create List
475 ... /redfish/v1/AccountService/Roles/Administrator
476 ... /redfish/v1/AccountService/Roles/Operator
477 ... /redfish/v1/AccountService/Roles/ReadOnly
478
479 List Should Contain Sub List ${member_list} ${roles}
480
481 # The standard roles are:
482
483 # | Role name | Assigned privileges |
484 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
485 # | Operator | Login, ConfigureComponents, ConfigureSelf |
486 # | ReadOnly | Login, ConfigureSelf |
487
488 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
489 @{operator}= Create List Login ConfigureComponents ConfigureSelf
490 @{readOnly}= Create List Login ConfigureSelf
491
492 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
493 ... readOnly_privileges=${readOnly}
494
495 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
496 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
497
498 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
499 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
500
501 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
502 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
503
504
manashsarma4910aa22021-07-26 09:12:36 -0500505Verify Error While Deleting Root User
506 [Documentation] Verify error while deleting root user.
507 [Tags] Verify_Error_While_Deleting_Root_User
508
509 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
510
511
manashsarma654cbc12021-09-23 02:28:12 -0500512Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530513 [Documentation] Verify that admin user have SSH login access.
514 ... By default, admin should have access but there could be
515 ... case where admin user shell access is restricted by design
516 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500517 [Tags] Verify_SSH_Login_Access_With_Admin_User
518
519 # Create an admin User.
520 Redfish Create User new_admin TestPwd1 Administrator ${True}
521
522 # Attempt SSH login with admin user.
523 SSHLibrary.Open Connection ${OPENBMC_HOST}
524 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
George Keishingf8e18192023-07-05 14:26:27 +0530525
526 # By default ssh_status is True, user can change the status via CLI
527 # -v ssh_status:False
528 Should Be Equal As Strings "${status}" "${ssh_status}"
manashsarma654cbc12021-09-23 02:28:12 -0500529
George Keishinge8015b32022-09-19 09:38:47 -0500530 Redfish.Login
531 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
532
manashsarma654cbc12021-09-23 02:28:12 -0500533
aravinth0510746884b2022-09-29 16:04:07 +0000534Verify Configure BasicAuth Enable And Disable
535 [Documentation] Verify configure basicauth enable and disable
536 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
537 [Template] Template For Configure Auth Methods
538
539 # auth_method
540 BasicAuth
541 XToken
542
Sivas SRR6aa101f2019-02-19 22:31:55 -0600543*** Keywords ***
544
Sivas SRR6aa101f2019-02-19 22:31:55 -0600545Test Teardown Execution
546 [Documentation] Do the post test teardown.
547
Anusha Dathatridb769702020-02-12 01:02:30 -0600548 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500549 FFDC On Test Case Fail
550
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600551
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500552Redfish Create User
553 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500554 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500555
556 # Description of argument(s):
557 # username The username to be created.
558 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500559 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500560 # (e.g. "Administrator", "Operator", etc.).
561 # enabled Indicates whether the username being created
562 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500563 # login_check Checks user login for created user.
564 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500565
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500566 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600567 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500568 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
569
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500570 # Create specified user.
571 ${payload}= Create Dictionary
572 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600573 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500574 ... valid_status_codes=[${HTTP_CREATED}]
575
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500576 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600577 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500578 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000579
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600580 Bmc Execute Command ${cmd}
581
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500582 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530583 IF '${login_check}' == '${True}'
584 ${status}= Run Keyword And Return Status
585 ... Verify Redfish User Login ${username} ${password}
586 ELSE
587 ${status}= Set Variable ${False}
588 END
589
590 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500591
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500592 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500593 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600594 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500595 Should Be Equal ${role_id} ${role_config}
596
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500597
598Redfish Verify User
599 [Documentation] Redfish user verification.
600 [Arguments] ${username} ${password} ${role_id} ${enabled}
601
602 # Description of argument(s):
603 # username The username to be created.
604 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500605 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500606 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500607 # enabled Indicates whether the username being created
608 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500609
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500610 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500611 # Doing a check of the returned status.
612 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500613
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500614 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500615 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600616 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500617 Should Be Equal ${role_id} ${role_config}
618
619
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500620Verify Redfish User Login
621 [Documentation] Verify Redfish login with given user id.
622 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
623 [Arguments] ${username} ${password}
624
625 # Description of argument(s):
626 # username Login username.
627 # password Login password.
628
629 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600630 # We don't really care if the current session is flushed out since we are going to login
631 # with new credential in next.
632 Run Keyword And Ignore Error Redfish.Logout
633
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500634 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530635 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500636
637
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600638Redfish Create And Verify User
639 [Documentation] Redfish create and verify user.
640 [Arguments] ${username} ${password} ${role_id} ${enabled}
641
642 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500643 # username The username to be created.
644 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500645 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500646 # (e.g. "Administrator", "Operator", etc.).
647 # enabled Indicates whether the username being created
648 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600649
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500650 # Example:
651 #{
652 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
653 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
654 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
655 #"Description": "User Account",
656 #"Enabled": true,
657 #"Id": "test1",
658 #"Links": {
659 # "Role": {
660 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
661 # }
662 #},
663
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500664 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600665
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500666 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600667
668 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600669 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500670
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500671Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500672 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500673 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
674
675 # Description of argument(s):
676 # username The username to be created.
677 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500678 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500679 # (e.g. "Administrator", "Operator", etc.).
680 # enabled Indicates whether the username being created
681 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500682 # wrong_password Any invalid password.
683
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500684 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500685
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500686 Redfish.Logout
687
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500688 # Attempt to login with created user with invalid password.
689 Run Keyword And Expect Error InvalidCredentialsError*
690 ... Redfish.Login ${username} ${wrong_password}
691
692 Redfish.Login
693
694 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600695 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500696
697
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500698Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500699 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500700 [Arguments] ${username} ${password} ${role_id} ${enabled}
701
702 # Description of argument(s):
703 # username The username to be created.
704 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500705 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500706 # (e.g. "Administrator", "Operator", etc.).
707 # enabled Indicates whether the username being created
708 # should be enabled (${True}, ${False}).
709
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500710 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500711
712 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600713 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500714
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500715 Redfish.Logout
716
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500717 # Attempt to login with deleted user account.
718 Run Keyword And Expect Error InvalidCredentialsError*
719 ... Redfish.Login ${username} ${password}
720
721 Redfish.Login
722
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500723
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500724Verify Create User Without Enabling
725 [Documentation] Verify Create User Without Enabling.
726 [Arguments] ${username} ${password} ${role_id} ${enabled}
727
728 # Description of argument(s):
729 # username The username to be created.
730 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500731 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500732 # (e.g. "Administrator", "Operator", etc.).
733 # enabled Indicates whether the username being created
734 # should be enabled (${True}, ${False}).
735
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500736 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500737
738 Redfish.Logout
739
740 # Login with created user.
741 Run Keyword And Expect Error InvalidCredentialsError*
742 ... Redfish.Login ${username} ${password}
743
744 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500745
746 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600747 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500748
aravinth0510746884b2022-09-29 16:04:07 +0000749Template For Configure Auth Methods
750 [Documentation] Template to configure auth methods.
751 [Arguments] ${auth_method}
752 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
753
754 # Description of Argument(s):
755 # authmethods The authmethod setting which needs to be
756 # set in account service URI.
757 # valid values BasicAuth, XToken.
758
759 Get AuthMethods Default Values ${auth_method}
760
761 # Patch basicauth to TRUE
762 Configure AuthMethods ${auth_method}=${TRUE}
763
George Keishing79fc7f02025-05-02 00:37:49 +0530764 IF "${auth_method}" == "XToken"
765 Check XToken Works Fine ${HTTP_OK}
766 ELSE
767 Check BasicAuth Works Fine ${HTTP_OK}
768 END
aravinth0510746884b2022-09-29 16:04:07 +0000769
770 # Patch basicauth to FALSE
771 Configure AuthMethods ${auth_method}=${FALSE}
772
George Keishing79fc7f02025-05-02 00:37:49 +0530773 IF "${auth_method}" == "BasicAuth"
774 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
775 ELSE
776 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
777 END
aravinth0510746884b2022-09-29 16:04:07 +0000778
779Configure AuthMethods
780 [Documentation] Enable/disable authmethod types.
781 [Arguments] &{authmethods}
782
783 # Description of argument(s):
784 # authmethods The authmethod setting which needs to be
785 # set in account service URI.
786 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
787 # This will set the value of "XToken" and "BasicAuth"
788 # property in accountservice uri to TRUE.
789
790 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
791 ${oem}= Create Dictionary OpenBMC=${openbmc}
792 ${payload}= Create Dictionary Oem=${oem}
793
794 # Setting authmethod properties using Redfish session based auth
795 ${status}= Run Keyword And Return Status
796 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
797 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
798
George Keishingc63bfe62023-11-15 19:09:59 +0530799 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000800 IF ${status}==${FALSE}
801 # Payload dictionary pre-process to match json formatting
802 ${payload}= Convert To String ${payload}
803 ${payload}= Replace String ${payload} ' "
804 ${payload}= Replace String ${payload} False false
805 ${payload}= Replace String ${payload} True true
806
807 # Curl Command Framing for PATCH authmethod
808 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
809 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
810 ... -H 'content-type:application/json' -H 'If-Match:*'
811 ... -d '${payload}'
812 ${rc} ${out}= Run And Return Rc And Output ${cmd}
813
814 # Check the response of curl command is 200 or 204
815 ${check_no_content}=
816 ... Run Keyword and Return Status Should Contain ${out} 204
817 ${check_ok}=
818 ... Run Keyword and Return Status Should Contain ${out} 200
819 Pass Execution If ${check_no_content}==${TRUE}
820 ... OR ${check_ok}==${TRUE}
821 END
822
823
824Get AuthMethods Default Values
825 [Documentation] Get enabled/disabled status of all authmethods
826 ... from Redfish account service URI
827 [Arguments] ${authmethod}
828
829 # Description of argument(s):
830 # authmethod The authmethod property whose value needs to be
831 # retrieved from account service URI.
832 # Usage Example Get AuthMethods Default Values BasicAuth
833 # returns >> ${TRUE}
834 # Example:
835 # {
836 # "@odata.id": "/redfish/v1/AccountService",
837 # (...)
838 # "Oem": {
839 # "OpenBMC": {
840 # "AuthMethods": {
841 # "BasicAuth": true,
842 # "Cookie": true,
843 # "SessionToken": true,
844 # "TLS": true,
845 # "XToken": true
846 # }
847 # }
848 # }
849 # }
850
851 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
852 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
853 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
854 Set Test Variable ${initial_value}
855
856Check XToken Works Fine
857 [Documentation] Verify Xtoken works fine.
858 [Arguments] ${status_code}
859
860 # Description of Argument(s):
861 # status_code : 200, 401.
862
863 # Verify xtoken auth works for xtoken
864 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
865 ... valid_status_codes=[${status_code}]
866
867Check BasicAuth Works Fine
868 [Documentation] Verify Basic Auth works fine.
869 [Arguments] ${status_code}
870
871 # Description of Argument(s):
872 # status_code : 200, 401.
873
874 # Verify basic auth works based on basic auth.
875 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
876 ... ${AUTH_URI}/redfish/v1/AccountService
877 ${rc} ${out}= Run And Return Rc And Output ${cmd}
878
879 # Check the response of curl command is 200/401
880 Should Contain ${out} ${status_code}