blob: 8a24b9a4b259e52f99bddd51251a7cc46b7af0c3 [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
Igor Kanyuka30427852025-11-24 10:45:29 +000032Verify Redfish Admin and ReadOnly Users Persistence After Reboot
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050033 [Documentation] Verify Redfish admin user persistence after reboot.
34 [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot
Igor Kanyuka30427852025-11-24 10:45:29 +000035 ... Verify_Redfish_Readonly_User_Persistence_After_Reboot
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050036 [Setup] Run Keywords Redfish.Login AND
37 ... Redfish Create User admin_user TestPwd123 Administrator ${True}
Igor Kanyuka30427852025-11-24 10:45:29 +000038 ... AND Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050039 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Igor Kanyuka30427852025-11-24 10:45:29 +000040 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050041 ... AND Test Teardown Execution
Sandhya Somashekara83fb472019-08-29 02:26:21 -050042
43 # Reboot BMC.
44 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050045
46 # Verify users after reboot.
47 Redfish Verify User admin_user TestPwd123 Administrator ${True}
Igor Kanyuka30427852025-11-24 10:45:29 +000048 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050049
50
51Verify Redfish Operator User Persistence After Reboot
52 [Documentation] Verify Redfish operator user persistence after reboot.
53 [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot
54 [Setup] Run Keywords Redfish.Login AND
55 ... Redfish Create User operator_user TestPwd123 Operator ${True}
56 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
57 ... AND Test Teardown Execution
58
59 # Reboot BMC.
60 Redfish OBMC Reboot (off) stack_mode=normal
61
62 # Verify users after reboot.
Igor Kanyuka30427852025-11-24 10:45:29 +000063 Redfish Verify User operator_user TestPwd123 Operator ${True}
Rahul Maheshwarid0aa72b2022-08-23 06:44:07 -050064
65
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050066Redfish Create and Verify Admin User
67 [Documentation] Create a Redfish user with administrator role and verify.
George Keishingf5176902022-05-12 04:23:59 -050068 [Tags] Redfish_Create_and_Verify_Admin_User
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060069 [Template] Redfish Create And Verify User
70
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050071 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050072 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050073
74
75Redfish Create and Verify Operator User
76 [Documentation] Create a Redfish user with operator role and verify.
77 [Tags] Redfish_Create_and_Verify_Operator_User
78 [Template] Redfish Create And Verify User
79
80 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050081 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050082
83
84Redfish Create and Verify Readonly User
85 [Documentation] Create a Redfish user with readonly role and verify.
86 [Tags] Redfish_Create_and_Verify_Readonly_User
87 [Template] Redfish Create And Verify User
88
89 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -060090 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060091
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050092
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -050093Verify Redfish Admin User Login With Wrong Password
94 [Documentation] Verify Redfish create admin user with valid password and make sure
95 ... admin user failed to login with wrong password.
96 [Tags] Verify_Redfish_Admin_User_Login_With_Wrong_Password
97 [Template] Verify Redfish User Login With Wrong Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050098
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050099 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500100 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500101
102
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500103Verify Redfish Operator User Login With Wrong Password
104 [Documentation] Verify Redfish create operator user with valid password and make sure
George Keishingeeec7352025-10-14 09:58:59 +0530105 ... operator user failed to login with wrong password.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500106 [Tags] Verify_Redfish_Operator_User_Login_With_Wrong_Password
107 [Template] Verify Redfish User Login With Wrong Password
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500108
109 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500110 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500111
112
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500113Verify Redfish Readonly User Login With Wrong Password
114 [Documentation] Verify Redfish create readonly user with valid password and make sure
115 ... readonly user failed to login with wrong password.
116 [Tags] Verify_Redfish_Readonly_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
Anusha Dathatri4062b442020-02-03 04:39:15 -0600120 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500121
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500122
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500123Verify Login with Deleted Redfish Admin User
124 [Documentation] Verify login with deleted Redfish admin user.
125 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500126 [Template] Verify Login with Deleted Redfish User
127
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500128 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500129 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500130
131
132Verify Login with Deleted Redfish Operator User
133 [Documentation] Verify login with deleted Redfish operator user.
134 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
135 [Template] Verify Login with Deleted Redfish User
136
137 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500138 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500139
140
141Verify Login with Deleted Redfish Readonly User
142 [Documentation] Verify login with deleted Redfish readonly user.
143 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
144 [Template] Verify Login with Deleted Redfish User
145
146 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600147 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500148
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500149
150Verify Admin User Creation Without Enabling It
151 [Documentation] Verify admin user creation without enabling it.
152 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500153 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500154
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500155 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500156 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500157
158
159Verify Operator User Creation Without Enabling It
160 [Documentation] Verify operator user creation without enabling it.
161 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
162 [Template] Verify Create User Without Enabling
163
164 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500165 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500166
167
168Verify Readonly User Creation Without Enabling It
169 [Documentation] Verify readonly user creation without enabling it.
170 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
171 [Template] Verify Create User Without Enabling
172
173 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600174 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500175
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500176
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500177Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500178 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500179 [Tags] Verify_User_Creation_With_Invalid_Role_Id
180
181 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600182 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500183 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
184
185 # Create specified user.
186 ${payload}= Create Dictionary
187 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600188 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500189 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
190
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500191Verify Error Upon Creating Same Users With Different Privileges
192 [Documentation] Verify error upon creating same users with different privileges.
193 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
194
195 Redfish Create User test_user TestPwd123 Administrator ${True}
196
197 # Create specified user.
198 ${payload}= Create Dictionary
Nandish-Matti232a6f02023-04-07 05:54:32 -0500199 ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600200 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500201 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
202
Anusha Dathatri466816f2020-01-30 05:12:36 -0600203 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500204
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500205
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500206Verify Modifying User Attributes
207 [Documentation] Verify modifying user attributes.
208 [Tags] Verify_Modifying_User_Attributes
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500209
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500210 # Create Redfish users.
211 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600212 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500213
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500214 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600215 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500216 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
217
218 # Update admin_user username using Redfish.
219 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600220 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530221 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500222
Anusha Dathatri4062b442020-02-03 04:39:15 -0600223 # Update readonly_user role using Redfish.
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500224 ${payload}= Create Dictionary RoleId=Administrator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600225 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
George Keishing3f2902e2025-03-14 08:19:02 +0530226 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500227
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500228 # Verify users after updating
229 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500230 Redfish Verify User readonly_user TestPwd123 Administrator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500231
232 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600233 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600234 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500235
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500236
237Verify Modifying Operator User Attributes
238 [Documentation] Verify modifying operator user attributes.
239 [Tags] Verify_Modifying_Operator_User_Attributes
240 [Setup] Run Keywords Redfish.Login AND
241 ... Redfish Create User operator_user TestPwd123 Operator ${True}
242 [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
243 ... AND Test Teardown Execution
244
245 # Update operator_user password using Redfish.
246 ${payload}= Create Dictionary Password=NewTestPwd123
247 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800248 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Rahul Maheshwari124ebef2022-08-23 12:06:59 -0500249
250 # Verify users after updating
251 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
252
253
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500254Verify User Account Locked
255 [Documentation] Verify user account locked upon trying with invalid password.
256 [Tags] Verify_User_Account_Locked
257
258 Redfish Create User admin_user TestPwd123 Administrator ${True}
259
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500260 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
261 ... AccountLockoutDuration=${account_lockout_duration}
262 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
George Keishing1f8db9c2025-04-01 21:37:44 +0530263 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500264
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500265 Redfish.Logout
266
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500267 # Make ${account_lockout_threshold} failed login attempts.
268 Repeat Keyword ${account_lockout_threshold} times
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500269 ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500270
271 # Verify that legitimate login fails due to lockout.
Vidya-Kalasappanavar4831f592025-04-21 04:17:21 -0500272 Run Keyword And Expect Error *InvalidCredentialsError*
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500273 ... Redfish.Login admin_user TestPwd123
274
Vidya-Kalasappanavar344c21d2025-07-01 12:21:05 -0500275 # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout
276 # ... then verify that login works.
277 ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5
278 Sleep ${total_wait_duartion}s
279
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500280 Redfish.Login admin_user TestPwd123
281
282 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500283
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500284 Redfish.Login
285
Anusha Dathatri466816f2020-01-30 05:12:36 -0600286 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500287
aravinth0510746884b2022-09-29 16:04:07 +0000288
289Verify User Account Unlock
290 [Documentation] Verify manually unlocking the account before lockout time
291 [Tags] Verify_User_Account_Unlock
Igor Kanyuka0e81d992025-11-24 10:59:14 +0000292 [Teardown] Run Keywords SSHLibrary.Close All Connections
293 ... AND Redfish.Logout
George Keishinga36926b2023-05-17 21:54:34 +0530294 ... AND Redfish.Login
aravinth0510746884b2022-09-29 16:04:07 +0000295 ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
aravinth0510746884b2022-09-29 16:04:07 +0000296
297 Redfish Create User test_user TestPwd123 Administrator ${True}
298
299 ${payload}= Create Dictionary
300 ... AccountLockoutThreshold=${account_lockout_threshold}
301 ... AccountLockoutDuration=${account_lockout_duration}
302 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800303 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
aravinth0510746884b2022-09-29 16:04:07 +0000304
305 Redfish.Logout
306
307 # Make ${account_lockout_threshold} failed login attempts.
308 Repeat Keyword ${account_lockout_threshold} times
309 ... Run Keyword And Expect Error InvalidCredentialsError*
310 ... Redfish.Login test_user abc123
311
312 # Ensure SSH Login with locked account gets failed
313 SSHLibrary.Open Connection ${OPENBMC_HOST}
314 Run Keyword And Expect Error Authentication failed*
315 ... SSHLibrary.Login test_user TestPwd123
316
317 # Verify that legitimate login fails due to lockout.
318 Run Keyword And Expect Error InvalidCredentialsError*
319 ... Redfish.Login test_user TestPwd123
320
321 ${payload}= Create Dictionary Locked=${FALSE}
322
323 # Manually unlock the account before lockout threshold expires
324 Redfish.Login
325 Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800326 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
aravinth0510746884b2022-09-29 16:04:07 +0000327 Redfish.Logout
328
329 # Try redfish login with the recently unlocked account
330 Redfish.Login test_user TestPwd123
331
332 # Try SSH login with the unlocked account
333 SSHLibrary.Open Connection ${OPENBMC_HOST}
334 SSHLibrary.Login test_user TestPwd123
335
336
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500337Verify Admin User Privilege
338 [Documentation] Verify admin user privilege.
339 [Tags] Verify_Admin_User_Privilege
340
341 Redfish Create User admin_user TestPwd123 Administrator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600342 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500343
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500344 Redfish.Logout
345
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500346 Redfish.Login admin_user TestPwd123
347
348 # Change password of 'readonly' user with admin user.
349 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800350 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500351
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'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -0800376 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500377
378 # Verify modified user.
379 Redfish Verify User operator_user TestPwd123 Administrator ${True}
380
Anusha Dathatri466816f2020-01-30 05:12:36 -0600381 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
382 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Rahul Maheshwari3bc08642022-08-23 12:49:48 -0500383
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500384
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500385Verify Operator User Privilege
386 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600387 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500388
389 Redfish Create User admin_user TestPwd123 Administrator ${True}
390 Redfish Create User operator_user TestPwd123 Operator ${True}
391
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500392 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500393 # Login with operator user.
394 Redfish.Login operator_user TestPwd123
395
George Keishing093c1bd2020-02-10 09:47:34 -0600396 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500397 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500398
399 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600400 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500401 ... valid_status_codes=[${HTTP_FORBIDDEN}]
402
403 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500404
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500405 Redfish.Login
406
Anusha Dathatri466816f2020-01-30 05:12:36 -0600407 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
408 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500409
410
Anusha Dathatri4062b442020-02-03 04:39:15 -0600411Verify ReadOnly User Privilege
412 [Documentation] Verify ReadOnly user privilege.
413 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500414
Anusha Dathatri4062b442020-02-03 04:39:15 -0600415 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500416 Redfish.Logout
417
418 # Login with read_only user.
419 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500420
421 # Read system level data.
422 ${system_model}= Redfish_Utils.Get Attribute
423 ... ${SYSTEM_BASE_URI} Model
424
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500425 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500426 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600427 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500428
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500429
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500430Verify Minimum Password Length For Redfish Admin And Readonly User
431 [Documentation] Verify minimum password length for new and existing admin or
432 ... readonly user.
433 [Template] Verify Minimum Password Length For Redfish User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600434
Sridevi Ramesh34acff52025-08-07 03:34:22 -0500435 #username role_id
436 admin_user Administrator
437 readonly_user ReadOnly
Anusha Dathatri466816f2020-01-30 05:12:36 -0600438
439
Tony Lee94335f42021-02-04 15:16:39 +0800440Verify Standard User Roles Defined By Redfish
441 [Documentation] Verify standard user roles defined by Redfish.
442 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
443
444 ${member_list}= Redfish_Utils.Get Member List
445 ... /redfish/v1/AccountService/Roles
446
447 @{roles}= Create List
448 ... /redfish/v1/AccountService/Roles/Administrator
449 ... /redfish/v1/AccountService/Roles/Operator
450 ... /redfish/v1/AccountService/Roles/ReadOnly
451
452 List Should Contain Sub List ${member_list} ${roles}
453
454 # The standard roles are:
455
456 # | Role name | Assigned privileges |
457 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
458 # | Operator | Login, ConfigureComponents, ConfigureSelf |
459 # | ReadOnly | Login, ConfigureSelf |
460
461 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
462 @{operator}= Create List Login ConfigureComponents ConfigureSelf
463 @{readOnly}= Create List Login ConfigureSelf
464
465 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
466 ... readOnly_privileges=${readOnly}
467
468 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
469 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
470
471 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
472 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
473
474 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
475 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
476
477
manashsarma4910aa22021-07-26 09:12:36 -0500478Verify Error While Deleting Root User
479 [Documentation] Verify error while deleting root user.
480 [Tags] Verify_Error_While_Deleting_Root_User
481
482 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
483
484
manashsarma654cbc12021-09-23 02:28:12 -0500485Verify SSH Login Access With Admin User
George Keishingf8e18192023-07-05 14:26:27 +0530486 [Documentation] Verify that admin user have SSH login access.
487 ... By default, admin should have access but there could be
488 ... case where admin user shell access is restricted by design
489 ... in the community sphere..
manashsarma654cbc12021-09-23 02:28:12 -0500490 [Tags] Verify_SSH_Login_Access_With_Admin_User
491
Nandakumar Ba4887be2025-11-05 19:27:31 +0530492 #Create an admin user and verify SSH login.
493 Create Admin User And Verify SSH Login
manashsarma654cbc12021-09-23 02:28:12 -0500494
George Keishinge8015b32022-09-19 09:38:47 -0500495 Redfish.Login
496 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
497
Nandakumar-AMI45830792025-10-30 13:15:15 +0530498Verify SSH Login Is Revoked For Deleted User
499 [Documentation] Verify SSH login access is revoked for deleted User.
500 [Tags] Verify_SSH_Login_Is_Revoked_For_Deleted_User
501
502 #Create an admin user and verify SSH login.
503 Create Admin User And Verify SSH Login
504
505 #Login with root user.
506 Redfish.Login
507
508 # Delete the admin user.
509 Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin
510 ... valid_status_codes=[${HTTP_OK}]
511
512 # Attempt SSH login with Deleted user.
513 SSHLibrary.Open Connection ${OPENBMC_HOST}
514 Run Keyword And Expect Error Authentication failed*
515 ... SSHLibrary.Login new_admin TestPwd1
manashsarma654cbc12021-09-23 02:28:12 -0500516
aravinth0510746884b2022-09-29 16:04:07 +0000517Verify Configure BasicAuth Enable And Disable
518 [Documentation] Verify configure basicauth enable and disable
519 [Tags] Verify_Configure_BasicAuth_Enable_And_Disable
520 [Template] Template For Configure Auth Methods
521
522 # auth_method
523 BasicAuth
524 XToken
525
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500526
527Redfish Create and Verify Admin User With Invalid Password Format
528 [Documentation] Create a admin user with invalid password format and verify.
529 [Template] Create User With Unsupported Password Format And Verify
530 [Tags] Redfish_Create_and_Verify_Admin_User_With_Invalid_Password_Format
531
532 #username role_id password
533 admin_user Administrator snellens
534 admin_user Administrator 10000001
535 admin_user Administrator 12345678
536 admin_user Administrator abcdefgh
537 admin_user Administrator abf12345
538 admin_user Administrator helloworld
539 admin_user Administrator HELLOWORLD
540 admin_user Administrator &$%**!*@
541 admin_user Administrator Dictation
542
543
544Redfish Create and Verify Readonly User With Invalid Password Format
545 [Documentation] Create a readonly user with invalid password format and verify.
546 [Template] Create User With Unsupported Password Format And Verify
547 [Tags] Redfish_Create_and_Verify_Readonly_User_With_Invalid_Password_Format
548
549 #username role_id password
550 readonly_user ReadOnly snellens
551 readonly_user ReadOnly 10000001
552 readonly_user ReadOnly 12345678
553 readonly_user ReadOnly abcdefgh
554 readonly_user ReadOnly abf12345
555 readonly_user ReadOnly helloworld
556 readonly_user ReadOnly HELLOWORLD
557 readonly_user ReadOnly &$%**!*@
558 readonly_user ReadOnly Dictation
559
560
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500561Verify Admin And Readonly User Password Is Not Same As Username
562 [Documentation] Verify that admin and readonly user creation is failed if
563 ... password is same as username.
564 [Template] Create User With Unsupported Password Format And Verify
565 [Tags] Verify_Admin_And_Readonly_User_Password_Is_Not_Same_As_Username
566
567 #username role_id password
568 AdminUser1 Administrator AdminUser1
569 ReadOnlyUser1 ReadOnly ReadOnlyUser1
570
IanLaiAMI597181e2025-10-07 12:03:59 +0800571Verify AccountService Unsupported Methods
572 [Documentation] Verify Unsupported methods of AccountService
573 [Tags] Verify_AccountService_Unsupported_Methods
574
575 # Put operation on Account Services
576 Redfish.Put /redfish/v1/AccountService
577 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
578
579 # Post operation on Account Services
580 Redfish.Post /redfish/v1/AccountService
581 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
582
583 # Delete operation on Account Services
584 Redfish.Delete /redfish/v1/AccountService
585 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
586
Ian Lai63c31422025-10-27 12:32:24 +0800587Verify AccountService Roles Unsupported Methods
588 [Documentation] Verify Unsupported methods of AccountService/Roles
589 [Tags] Verify_AccountService_Roles_Unsupported_Methods
590
591 # Put operation on Account Services Roles
592 Redfish.Put /redfish/v1/AccountService/Roles
593 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
594
595 # Post operation on Account Services Roles
596 Redfish.Post /redfish/v1/AccountService/Roles
597 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
598
599 # Delete operation on Account Services Roles
600 Redfish.Delete /redfish/v1/AccountService/Roles
601 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
602
603 # Patch operation on Account Services Roles
604 Redfish.Patch /redfish/v1/AccountService/Roles
605 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
606
Nandakumar-AMI45830792025-10-30 13:15:15 +0530607Verify AccountService Roles Instance With Unsupported Methods
608 [Documentation] Verify Instance Roles for AccountService and Unsupported Methods
609 [Tags] Verify_AccountService_Roles_Instance_With_Unsupported_Methods
610
611 # GET Administrator Role Instance
612 Redfish.Get /redfish/v1/AccountService/Roles/Administrator
613 ... valid_status_codes=[${HTTP_OK}]
614
615 # GET Operator Role Instance
616 Redfish.Get /redfish/v1/AccountService/Roles/Operator
617 ... valid_status_codes=[${HTTP_OK}]
618
619 # GET ReadOnly RoleInstance
620 Redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
621 ... valid_status_codes=[${HTTP_OK}]
622
623 # Post operation on Account Service Roles Instance
624 Redfish.Post /redfish/v1/AccountService/Roles/Administrator
625 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
626
627 # Put operation on Account Service Roles Instance
628 Redfish.Put /redfish/v1/AccountService/Roles/Administrator
629 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
630
631 # Patch operation on Account Service Roles Instance
632 Redfish.Patch /redfish/v1/AccountService/Roles/Administrator
633 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
634
635 #Delete operation on Account Service Roles Instance
636 Redfish.Delete /redfish/v1/AccountService/Roles/Administrator
637 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -0500638
George Keishingbf1bc712025-11-26 05:09:48 +0000639Verify Account Lockout With Invalid Configuration
kirubakaranbe907fcd2025-11-21 10:19:58 +0000640 [Documentation] Verify Account Lockout configuration with invalid values.
641 [Tags] Verify_Account_Lockout_With_Invalid_Configuration
642
643 @{invalid_values_list}= Create List -1 abc 3.5 ${EMPTY}
644
645 FOR ${invalid_value} IN @{invalid_values_list}
646 ${payload}= Create Dictionary AccountLockoutThreshold=${invalid_value}
647 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
648 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
649
650 ${payload}= Create Dictionary AccountLockoutDuration=${invalid_value}
651 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
652 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
653
654 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
655 ... AccountLockoutDuration=${invalid_value}
656 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
657 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
658
659 ${payload}= Create Dictionary AccountLockoutThreshold=${invalid_value}
660 ... AccountLockoutDuration=${account_lockout_duration}
661 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
662 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
663 END
664
Sivas SRR6aa101f2019-02-19 22:31:55 -0600665*** Keywords ***
666
Sivas SRR6aa101f2019-02-19 22:31:55 -0600667Test Teardown Execution
668 [Documentation] Do the post test teardown.
669
Anusha Dathatridb769702020-02-12 01:02:30 -0600670 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500671 FFDC On Test Case Fail
672
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600673
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500674Redfish Create User
675 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500676 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500677
678 # Description of argument(s):
679 # username The username to be created.
680 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500681 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500682 # (e.g. "Administrator", "Operator", etc.).
683 # enabled Indicates whether the username being created
684 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500685 # login_check Checks user login for created user.
686 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500687
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500688 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600689 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500690 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
691
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500692 # Create specified user.
693 ${payload}= Create Dictionary
694 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600695 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500696 ... valid_status_codes=[${HTTP_CREATED}]
697
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500698 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600699 # openbmc/phosphor-user-manager#4
Rahul Maheshwari638a5982024-04-19 07:35:15 -0500700 ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset
Alagiridhilipankb9c93772024-04-02 10:04:27 +0000701
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600702 Bmc Execute Command ${cmd}
703
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500704 # Verify login with created user.
George Keishing79fc7f02025-05-02 00:37:49 +0530705 IF '${login_check}' == '${True}'
706 ${status}= Run Keyword And Return Status
707 ... Verify Redfish User Login ${username} ${password}
708 ELSE
709 ${status}= Set Variable ${False}
710 END
711
712 IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500713
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500714 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500715 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600716 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500717 Should Be Equal ${role_id} ${role_config}
718
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500719
720Redfish Verify User
721 [Documentation] Redfish user verification.
722 [Arguments] ${username} ${password} ${role_id} ${enabled}
723
724 # Description of argument(s):
725 # username The username to be created.
726 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500727 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500728 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500729 # enabled Indicates whether the username being created
730 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500731
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500732 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500733 # Doing a check of the returned status.
734 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500735
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500736 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500737 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600738 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500739 Should Be Equal ${role_id} ${role_config}
740
741
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500742Verify Redfish User Login
743 [Documentation] Verify Redfish login with given user id.
744 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
745 [Arguments] ${username} ${password}
746
747 # Description of argument(s):
748 # username Login username.
749 # password Login password.
750
751 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600752 # We don't really care if the current session is flushed out since we are going to login
753 # with new credential in next.
754 Run Keyword And Ignore Error Redfish.Logout
755
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500756 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
George Keishing409df052024-01-17 22:36:14 +0530757 RETURN ${status}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500758
759
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600760Redfish Create And Verify User
761 [Documentation] Redfish create and verify user.
762 [Arguments] ${username} ${password} ${role_id} ${enabled}
763
764 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500765 # username The username to be created.
766 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500767 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500768 # (e.g. "Administrator", "Operator", etc.).
769 # enabled Indicates whether the username being created
770 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600771
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500772 # Example:
773 #{
774 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
775 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
776 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
777 #"Description": "User Account",
778 #"Enabled": true,
779 #"Id": "test1",
780 #"Links": {
781 # "Role": {
782 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
783 # }
784 #},
785
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500786 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600787
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500788 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600789
790 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600791 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500792
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -0500793Verify Redfish User Login With Wrong Password
794 [Documentation] Verify Redfish User failed to login with wrong password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500795 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
796
797 # Description of argument(s):
798 # username The username to be created.
799 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500800 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500801 # (e.g. "Administrator", "Operator", etc.).
802 # enabled Indicates whether the username being created
803 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500804 # wrong_password Any invalid password.
805
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500806 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500807
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500808 Redfish.Logout
809
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500810 # Attempt to login with created user with invalid password.
811 Run Keyword And Expect Error InvalidCredentialsError*
812 ... Redfish.Login ${username} ${wrong_password}
813
814 Redfish.Login
815
816 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600817 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500818
819
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500820Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500821 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500822 [Arguments] ${username} ${password} ${role_id} ${enabled}
823
824 # Description of argument(s):
825 # username The username to be created.
826 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500827 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500828 # (e.g. "Administrator", "Operator", etc.).
829 # enabled Indicates whether the username being created
830 # should be enabled (${True}, ${False}).
831
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500832 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500833
834 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600835 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500836
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500837 Redfish.Logout
838
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500839 # Attempt to login with deleted user account.
840 Run Keyword And Expect Error InvalidCredentialsError*
841 ... Redfish.Login ${username} ${password}
842
843 Redfish.Login
844
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500845
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500846Verify Create User Without Enabling
847 [Documentation] Verify Create User Without Enabling.
848 [Arguments] ${username} ${password} ${role_id} ${enabled}
849
850 # Description of argument(s):
851 # username The username to be created.
852 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500853 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500854 # (e.g. "Administrator", "Operator", etc.).
855 # enabled Indicates whether the username being created
856 # should be enabled (${True}, ${False}).
857
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500858 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500859
860 Redfish.Logout
861
862 # Login with created user.
863 Run Keyword And Expect Error InvalidCredentialsError*
864 ... Redfish.Login ${username} ${password}
865
866 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500867
868 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600869 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500870
aravinth0510746884b2022-09-29 16:04:07 +0000871Template For Configure Auth Methods
872 [Documentation] Template to configure auth methods.
873 [Arguments] ${auth_method}
874 [Teardown] Configure AuthMethods ${auth_method}=${initial_value}
875
876 # Description of Argument(s):
877 # authmethods The authmethod setting which needs to be
878 # set in account service URI.
879 # valid values BasicAuth, XToken.
880
881 Get AuthMethods Default Values ${auth_method}
882
883 # Patch basicauth to TRUE
884 Configure AuthMethods ${auth_method}=${TRUE}
885
George Keishing79fc7f02025-05-02 00:37:49 +0530886 IF "${auth_method}" == "XToken"
887 Check XToken Works Fine ${HTTP_OK}
888 ELSE
889 Check BasicAuth Works Fine ${HTTP_OK}
890 END
aravinth0510746884b2022-09-29 16:04:07 +0000891
892 # Patch basicauth to FALSE
893 Configure AuthMethods ${auth_method}=${FALSE}
894
George Keishing79fc7f02025-05-02 00:37:49 +0530895 IF "${auth_method}" == "BasicAuth"
896 Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED}
897 ELSE
898 Check XToken Works Fine ${HTTP_UNAUTHORIZED}
899 END
aravinth0510746884b2022-09-29 16:04:07 +0000900
901Configure AuthMethods
902 [Documentation] Enable/disable authmethod types.
903 [Arguments] &{authmethods}
904
905 # Description of argument(s):
906 # authmethods The authmethod setting which needs to be
907 # set in account service URI.
908 # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE}
909 # This will set the value of "XToken" and "BasicAuth"
910 # property in accountservice uri to TRUE.
911
912 ${openbmc}= Create Dictionary AuthMethods=${authmethods}
913 ${oem}= Create Dictionary OpenBMC=${openbmc}
914 ${payload}= Create Dictionary Oem=${oem}
915
916 # Setting authmethod properties using Redfish session based auth
917 ${status}= Run Keyword And Return Status
918 ... Redfish.Patch ${REDFISH_BASE_URI}AccountService
919 ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
920
George Keishingc63bfe62023-11-15 19:09:59 +0530921 # Setting authmethod properties using basic auth in case the former fails
aravinth0510746884b2022-09-29 16:04:07 +0000922 IF ${status}==${FALSE}
923 # Payload dictionary pre-process to match json formatting
924 ${payload}= Convert To String ${payload}
925 ${payload}= Replace String ${payload} ' "
926 ${payload}= Replace String ${payload} False false
927 ${payload}= Replace String ${payload} True true
928
929 # Curl Command Framing for PATCH authmethod
930 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
931 ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}'
932 ... -H 'content-type:application/json' -H 'If-Match:*'
933 ... -d '${payload}'
934 ${rc} ${out}= Run And Return Rc And Output ${cmd}
935
936 # Check the response of curl command is 200 or 204
937 ${check_no_content}=
938 ... Run Keyword and Return Status Should Contain ${out} 204
939 ${check_ok}=
940 ... Run Keyword and Return Status Should Contain ${out} 200
941 Pass Execution If ${check_no_content}==${TRUE}
942 ... OR ${check_ok}==${TRUE}
943 END
944
945
946Get AuthMethods Default Values
947 [Documentation] Get enabled/disabled status of all authmethods
948 ... from Redfish account service URI
949 [Arguments] ${authmethod}
950
951 # Description of argument(s):
952 # authmethod The authmethod property whose value needs to be
953 # retrieved from account service URI.
954 # Usage Example Get AuthMethods Default Values BasicAuth
955 # returns >> ${TRUE}
956 # Example:
957 # {
958 # "@odata.id": "/redfish/v1/AccountService",
959 # (...)
960 # "Oem": {
961 # "OpenBMC": {
962 # "AuthMethods": {
963 # "BasicAuth": true,
964 # "Cookie": true,
965 # "SessionToken": true,
966 # "TLS": true,
967 # "XToken": true
968 # }
969 # }
970 # }
971 # }
972
973 ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem
974 ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']}
975 ${initial_value}= Get From Dictionary ${authmethods} ${authmethod}
976 Set Test Variable ${initial_value}
977
978Check XToken Works Fine
979 [Documentation] Verify Xtoken works fine.
980 [Arguments] ${status_code}
981
982 # Description of Argument(s):
983 # status_code : 200, 401.
984
985 # Verify xtoken auth works for xtoken
986 Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI}
987 ... valid_status_codes=[${status_code}]
988
989Check BasicAuth Works Fine
990 [Documentation] Verify Basic Auth works fine.
991 [Arguments] ${status_code}
992
993 # Description of Argument(s):
994 # status_code : 200, 401.
995
996 # Verify basic auth works based on basic auth.
997 ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD}
998 ... ${AUTH_URI}/redfish/v1/AccountService
999 ${rc} ${out}= Run And Return Rc And Output ${cmd}
1000
1001 # Check the response of curl command is 200/401
1002 Should Contain ${out} ${status_code}
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05001003
1004
1005Create User With Unsupported Password Format And Verify
1006 [Documentation] Create admin or readonly user with unsupported password format
1007 ... and verify.
1008 [Arguments] ${username} ${role_id} ${password}
1009
1010 # Description of argument(s):
1011 # username The username to be created.
1012 # role_id The role ID of the user to be created
1013 # (e.g. "Administrator", "ReadOnly").
1014 # password The password to be assigned.
1015 # Unsupported password format are sequential characters,
1016 # sequential digits, palindrome digits, palindrome characters,
1017 # only uppercase letters, only lowercase letters, only digits,
Sridevi Ramesh1a2d0452025-08-05 12:16:51 -05001018 # only characters, not a dictionary word, username and password
1019 # should not be same.
Sridevi Ramesh4fc23cf2025-08-04 02:08:05 -05001020
1021 # Make sure the user account in question does not already exist.
1022 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
1023 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1024
1025 # Create specified user with invalid password format.
1026 ${payload}= Create Dictionary
1027 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${True}
1028 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1029 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -05001030
1031
1032Verify Minimum Password Length For Redfish User
1033 [Documentation] Verify minimum password length for new and existing admin or
1034 ... readonly user.
1035 [Arguments] ${user_name} ${role_id}
1036
1037 # Description of argument(s):
1038 # user_name The username to be created.
1039 # role_id The role ID of the user to be created.
1040
1041 # Make sure the user account in question does not already exist.
1042 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
1043 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
1044
1045 # Try to create a user with invalid length password.
1046 ${payload}= Create Dictionary
1047 ... UserName=${user_name} Password=UserPwd RoleId=${role_id} Enabled=${True}
1048 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1049 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1050
1051 # Create specified user with valid length password.
1052 Set To Dictionary ${payload} Password UserPwd1
1053 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
1054 ... valid_status_codes=[${HTTP_CREATED}]
1055
1056 # Try to change to an invalid password.
1057 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
1058 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
1059
1060 # Change to a valid password.
1061 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
Igor Kanyuka56a34f92025-11-14 06:27:29 -08001062 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Sridevi Ramesh34acff52025-08-07 03:34:22 -05001063
1064 # Verify login.
1065 Redfish.Logout
1066 Redfish.Login ${user_name} UserPwd1
1067 Redfish.Logout
1068 Redfish.Login
1069 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
Nandakumar-AMI45830792025-10-30 13:15:15 +05301070
1071Create Admin User And Verify SSH Login
1072 [Documentation] Create admin user and verify SSH login & logout.
1073
1074 # Create an admin User.
1075 Redfish Create User new_admin TestPwd1 Administrator ${True}
1076
1077 # Attempt SSH login with admin user.
1078 SSHLibrary.Open Connection ${OPENBMC_HOST}
1079 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
1080
1081 # By default ssh_status is True, user can change the status via CLI
1082 # -v ssh_status:False
1083 Should Be Equal As Strings "${status}" "${ssh_status}"
1084
1085 # Close SSH connection for admin user.
George Keishingbf1bc712025-11-26 05:09:48 +00001086 SSHLibrary.Close Connection