blob: 943059cbdc2c8715ea290bd3cb2a14b9204f577b [file] [log] [blame]
Sivas SRR6aa101f2019-02-19 22:31:55 -06001*** Settings ***
2Documentation Test Redfish user account.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -05007Resource ../../lib/bmc_redfish_utils.robot
Sivas SRR6aa101f2019-02-19 22:31:55 -06008
manashsarma654cbc12021-09-23 02:28:12 -05009Library SSHLibrary
10
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -050011Test Setup Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -060012Test Teardown Test Teardown Execution
13
Sandhya Somashekar37122b62019-06-18 06:02:02 -050014*** Variables ***
15
16${account_lockout_duration} ${30}
17${account_lockout_threshold} ${3}
18
Sivas SRR6aa101f2019-02-19 22:31:55 -060019** Test Cases **
20
21Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060022 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060023 [Tags] Verify_AccountService_Available
24
George Keishing97c93942019-03-04 12:45:07 -060025 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060026 Should Be Equal As Strings ${resp} ${True}
27
Sandhya Somashekara83fb472019-08-29 02:26:21 -050028Verify Redfish User Persistence After Reboot
29 [Documentation] Verify Redfish user persistence after reboot.
30 [Tags] Verify_Redfish_User_Persistence_After_Reboot
Sandhya Somashekara83fb472019-08-29 02:26:21 -050031 # Create Redfish users.
32 Redfish Create User admin_user TestPwd123 Administrator ${True}
33 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060034 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050035
36 # Reboot BMC.
37 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050038
39 # Verify users after reboot.
40 Redfish Verify User admin_user TestPwd123 Administrator ${True}
41 Redfish Verify User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060042 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050043
44 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -060045 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
46 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
47 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekara83fb472019-08-29 02:26:21 -050048
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050049Redfish Create and Verify Admin User
50 [Documentation] Create a Redfish user with administrator role and verify.
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060051 [Tags] Redfish_Create_and_Verify_Users
52 [Template] Redfish Create And Verify User
53
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050054 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050055 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050056
57
58Redfish Create and Verify Operator User
59 [Documentation] Create a Redfish user with operator role and verify.
60 [Tags] Redfish_Create_and_Verify_Operator_User
61 [Template] Redfish Create And Verify User
62
63 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050064 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050065
66
67Redfish Create and Verify Readonly User
68 [Documentation] Create a Redfish user with readonly role and verify.
69 [Tags] Redfish_Create_and_Verify_Readonly_User
70 [Template] Redfish Create And Verify User
71
72 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -060073 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060074
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050075
76Verify Redfish Admin User With Wrong Password
77 [Documentation] Verify Redfish admin user with wrong password.
78 [Tags] Verify_Redfish_Admin_User_With_Wrong_Password
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050079 [Template] Verify Redfish User with Wrong Password
80
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050081 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050082 admin_user TestPwd123 Administrator ${True} alskjhfwurh
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050083
84
85Verify Redfish Operator User with Wrong Password
86 [Documentation] Verify Redfish operator user with wrong password.
87 [Tags] Verify_Redfish_Operator_User_with_Wrong_Password
88 [Template] Verify Redfish User with Wrong Password
89
90 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050091 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -050092
93
94Verify Redfish Readonly User With Wrong Password
95 [Documentation] Verify Redfish readonly user with wrong password.
96 [Tags] Verify_Redfish_Readonly_User_With_Wrong_Password
97 [Template] Verify Redfish User with Wrong Password
98
99 #username password role_id enabled wrong_password
Anusha Dathatri4062b442020-02-03 04:39:15 -0600100 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500101
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500102
103Verify Redfish Operator User with Wrong Password
104 [Documentation] Verify Redfish operator user with wrong password.
105 [Tags] Verify_Redfish_Operator_User_with_Wrong_Password
106 [Template] Verify Redfish User with Wrong Password
107
108 #username password role_id enabled wrong_password
109 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
110
111
112Verify Login with Deleted Redfish Admin User
113 [Documentation] Verify login with deleted Redfish admin user.
114 [Tags] Verify_Login_with_Deleted_Redfish_Admin_User
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500115 [Template] Verify Login with Deleted Redfish User
116
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500117 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500118 admin_user TestPwd123 Administrator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500119
120
121Verify Login with Deleted Redfish Operator User
122 [Documentation] Verify login with deleted Redfish operator user.
123 [Tags] Verify_Login_with_Deleted_Redfish_Operator_User
124 [Template] Verify Login with Deleted Redfish User
125
126 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500127 operator_user TestPwd123 Operator ${True}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500128
129
130Verify Login with Deleted Redfish Readonly User
131 [Documentation] Verify login with deleted Redfish readonly user.
132 [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User
133 [Template] Verify Login with Deleted Redfish User
134
135 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600136 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500137
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500138
139Verify Admin User Creation Without Enabling It
140 [Documentation] Verify admin user creation without enabling it.
141 [Tags] Verify_Admin_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500142 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500143
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500144 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500145 admin_user TestPwd123 Administrator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500146
147
148Verify Operator User Creation Without Enabling It
149 [Documentation] Verify operator user creation without enabling it.
150 [Tags] Verify_Operator_User_Creation_Without_Enabling_It
151 [Template] Verify Create User Without Enabling
152
153 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500154 operator_user TestPwd123 Operator ${False}
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500155
156
157Verify Readonly User Creation Without Enabling It
158 [Documentation] Verify readonly user creation without enabling it.
159 [Tags] Verify_Readonly_User_Creation_Without_Enabling_It
160 [Template] Verify Create User Without Enabling
161
162 #username password role_id enabled
Anusha Dathatri4062b442020-02-03 04:39:15 -0600163 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500164
Rahul Maheshwaricbc4c0b2022-04-25 05:29:25 -0500165
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500166Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500167 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500168 [Tags] Verify_User_Creation_With_Invalid_Role_Id
169
170 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600171 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500172 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
173
174 # Create specified user.
175 ${payload}= Create Dictionary
176 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600177 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500178 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
179
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500180Verify Error Upon Creating Same Users With Different Privileges
181 [Documentation] Verify error upon creating same users with different privileges.
182 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
183
184 Redfish Create User test_user TestPwd123 Administrator ${True}
185
186 # Create specified user.
187 ${payload}= Create Dictionary
188 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600189 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500190 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
191
Anusha Dathatri466816f2020-01-30 05:12:36 -0600192 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500193
194Verify Modifying User Attributes
195 [Documentation] Verify modifying user attributes.
196 [Tags] Verify_Modifying_User_Attributes
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500197 # Create Redfish users.
198 Redfish Create User admin_user TestPwd123 Administrator ${True}
199 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600200 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500201
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500202 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600203 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500204 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
205
206 # Update admin_user username using Redfish.
207 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600208 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500209
210 # Update operator_user password using Redfish.
211 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600212 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500213
Anusha Dathatri4062b442020-02-03 04:39:15 -0600214 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500215 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600216 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500217
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500218 # Verify users after updating
219 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
220 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600221 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500222
223 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600224 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
225 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
226 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500227
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500228Verify User Account Locked
229 [Documentation] Verify user account locked upon trying with invalid password.
230 [Tags] Verify_User_Account_Locked
231
232 Redfish Create User admin_user TestPwd123 Administrator ${True}
233
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500234 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
235 ... AccountLockoutDuration=${account_lockout_duration}
236 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500237
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500238 Redfish.Logout
239
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500240 # Make ${account_lockout_threshold} failed login attempts.
241 Repeat Keyword ${account_lockout_threshold} times
242 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
243
244 # Verify that legitimate login fails due to lockout.
245 Run Keyword And Expect Error InvalidCredentialsError*
246 ... Redfish.Login admin_user TestPwd123
247
248 # Wait for lockout duration to expire and then verify that login works.
249 Sleep ${account_lockout_duration}s
250 Redfish.Login admin_user TestPwd123
251
252 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500253
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500254 Redfish.Login
255
Anusha Dathatri466816f2020-01-30 05:12:36 -0600256 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500257
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500258Verify Admin User Privilege
259 [Documentation] Verify admin user privilege.
260 [Tags] Verify_Admin_User_Privilege
261
262 Redfish Create User admin_user TestPwd123 Administrator ${True}
263 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600264 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500265
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500266 Redfish.Logout
267
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500268 # Change role ID of operator user with admin user.
269 # Login with admin user.
270 Redfish.Login admin_user TestPwd123
271
272 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600273 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500274
275 # Verify modified user.
276 Redfish Verify User operator_user TestPwd123 Administrator ${True}
277
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500278 Redfish.Logout
279 Redfish.Login admin_user TestPwd123
280
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500281 # Change password of 'user' user with admin user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600282 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500283
284 # Verify modified user.
Anusha Dathatri4062b442020-02-03 04:39:15 -0600285 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500286
Anusha Dathatri466816f2020-01-30 05:12:36 -0600287 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
288 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
289 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500290
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500291Verify Operator User Privilege
292 [Documentation] Verify operator user privilege.
George Keishing5236ec52022-01-31 12:07:58 -0600293 [Tags] Verify_Operator_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500294
295 Redfish Create User admin_user TestPwd123 Administrator ${True}
296 Redfish Create User operator_user TestPwd123 Operator ${True}
297
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500298 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500299 # Login with operator user.
300 Redfish.Login operator_user TestPwd123
301
George Keishing093c1bd2020-02-10 09:47:34 -0600302 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500303 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500304
305 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600306 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500307 ... valid_status_codes=[${HTTP_FORBIDDEN}]
308
309 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500310
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500311 Redfish.Login
312
Anusha Dathatri466816f2020-01-30 05:12:36 -0600313 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
314 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500315
316
Anusha Dathatri4062b442020-02-03 04:39:15 -0600317Verify ReadOnly User Privilege
318 [Documentation] Verify ReadOnly user privilege.
319 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500320
Anusha Dathatri4062b442020-02-03 04:39:15 -0600321 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500322 Redfish.Logout
323
324 # Login with read_only user.
325 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500326
327 # Read system level data.
328 ${system_model}= Redfish_Utils.Get Attribute
329 ... ${SYSTEM_BASE_URI} Model
330
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500331 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500332 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600333 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500334
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500335
Anusha Dathatri466816f2020-01-30 05:12:36 -0600336Verify Minimum Password Length For Redfish User
337 [Documentation] Verify minimum password length for new and existing user.
338 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
339
340 ${user_name}= Set Variable testUser
341
342 # Make sure the user account in question does not already exist.
343 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
344 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
345
346 # Try to create a user with invalid length password.
347 ${payload}= Create Dictionary
348 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
349 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
350 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
351
352 # Create specified user with valid length password.
353 Set To Dictionary ${payload} Password UserPwd1
354 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
355 ... valid_status_codes=[${HTTP_CREATED}]
356
357 # Try to change to an invalid password.
358 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
359 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
360
361 # Change to a valid password.
362 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
363
364 # Verify login.
365 Redfish.Logout
366 Redfish.Login ${user_name} UserPwd1
367 Redfish.Logout
368 Redfish.Login
369 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
370
371
Tony Lee94335f42021-02-04 15:16:39 +0800372Verify Standard User Roles Defined By Redfish
373 [Documentation] Verify standard user roles defined by Redfish.
374 [Tags] Verify_Standard_User_Roles_Defined_By_Redfish
375
376 ${member_list}= Redfish_Utils.Get Member List
377 ... /redfish/v1/AccountService/Roles
378
379 @{roles}= Create List
380 ... /redfish/v1/AccountService/Roles/Administrator
381 ... /redfish/v1/AccountService/Roles/Operator
382 ... /redfish/v1/AccountService/Roles/ReadOnly
383
384 List Should Contain Sub List ${member_list} ${roles}
385
386 # The standard roles are:
387
388 # | Role name | Assigned privileges |
389 # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf |
390 # | Operator | Login, ConfigureComponents, ConfigureSelf |
391 # | ReadOnly | Login, ConfigureSelf |
392
393 @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf
394 @{operator}= Create List Login ConfigureComponents ConfigureSelf
395 @{readOnly}= Create List Login ConfigureSelf
396
397 ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator}
398 ... readOnly_privileges=${readOnly}
399
400 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator
401 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']}
402
403 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator
404 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']}
405
406 ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly
407 List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']}
408
409
manashsarma4910aa22021-07-26 09:12:36 -0500410Verify Error While Deleting Root User
411 [Documentation] Verify error while deleting root user.
412 [Tags] Verify_Error_While_Deleting_Root_User
413
414 Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}]
415
416
manashsarma654cbc12021-09-23 02:28:12 -0500417Verify SSH Login Access With Admin User
418 [Documentation] Verify that admin user does not have SSH login access.
419 [Tags] Verify_SSH_Login_Access_With_Admin_User
420
421 # Create an admin User.
422 Redfish Create User new_admin TestPwd1 Administrator ${True}
423
424 # Attempt SSH login with admin user.
425 SSHLibrary.Open Connection ${OPENBMC_HOST}
426 ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1
427 Should Be Equal ${status} ${False}
428
429
Sivas SRR6aa101f2019-02-19 22:31:55 -0600430*** Keywords ***
431
Sivas SRR6aa101f2019-02-19 22:31:55 -0600432Test Teardown Execution
433 [Documentation] Do the post test teardown.
434
Anusha Dathatridb769702020-02-12 01:02:30 -0600435 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500436 FFDC On Test Case Fail
437
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600438
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500439Redfish Create User
440 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500441 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500442
443 # Description of argument(s):
444 # username The username to be created.
445 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500446 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500447 # (e.g. "Administrator", "Operator", etc.).
448 # enabled Indicates whether the username being created
449 # should be enabled (${True}, ${False}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500450 # login_check Checks user login for created user.
451 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500452
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500453 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600454 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500455 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
456
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500457 # Create specified user.
458 ${payload}= Create Dictionary
459 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600460 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500461 ... valid_status_codes=[${HTTP_CREATED}]
462
Rahul Maheshwari9928b1d2021-07-19 04:59:55 -0500463 # Resetting faillock count as a workaround for issue
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600464 # openbmc/phosphor-user-manager#4
nagarjunb2261267e92022-03-30 21:04:16 +0530465 ${cmd}= Catenate test -f /usr/sbin/faillock && /usr/sbin/faillock --user USER --reset
466 ... || /usr/sbin/pam_tally2 -u ${username} --reset
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600467 Bmc Execute Command ${cmd}
468
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500469 # Verify login with created user.
470 ${status}= Run Keyword If '${login_check}' == '${True}'
471 ... Verify Redfish User Login ${username} ${password}
472 Run Keyword If '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500473
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500474 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500475 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600476 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500477 Should Be Equal ${role_id} ${role_config}
478
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500479
480Redfish Verify User
481 [Documentation] Redfish user verification.
482 [Arguments] ${username} ${password} ${role_id} ${enabled}
483
484 # Description of argument(s):
485 # username The username to be created.
486 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500487 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500488 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500489 # enabled Indicates whether the username being created
490 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500491
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500492 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500493 # Doing a check of the returned status.
494 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500495
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500496 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500497 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600498 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500499 Should Be Equal ${role_id} ${role_config}
500
501
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500502Verify Redfish User Login
503 [Documentation] Verify Redfish login with given user id.
504 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
505 [Arguments] ${username} ${password}
506
507 # Description of argument(s):
508 # username Login username.
509 # password Login password.
510
511 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600512 # We don't really care if the current session is flushed out since we are going to login
513 # with new credential in next.
514 Run Keyword And Ignore Error Redfish.Logout
515
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500516 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
517 [Return] ${status}
518
519
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600520Redfish Create And Verify User
521 [Documentation] Redfish create and verify user.
522 [Arguments] ${username} ${password} ${role_id} ${enabled}
523
524 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500525 # username The username to be created.
526 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500527 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500528 # (e.g. "Administrator", "Operator", etc.).
529 # enabled Indicates whether the username being created
530 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600531
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500532 # Example:
533 #{
534 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
535 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
536 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
537 #"Description": "User Account",
538 #"Enabled": true,
539 #"Id": "test1",
540 #"Links": {
541 # "Role": {
542 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
543 # }
544 #},
545
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500546 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600547
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500548 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600549
550 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600551 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500552
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500553Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500554 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500555 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
556
557 # Description of argument(s):
558 # username The username to be created.
559 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500560 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500561 # (e.g. "Administrator", "Operator", etc.).
562 # enabled Indicates whether the username being created
563 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500564 # wrong_password Any invalid password.
565
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500566 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500567
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500568 Redfish.Logout
569
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500570 # Attempt to login with created user with invalid password.
571 Run Keyword And Expect Error InvalidCredentialsError*
572 ... Redfish.Login ${username} ${wrong_password}
573
574 Redfish.Login
575
576 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600577 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500578
579
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500580Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500581 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500582 [Arguments] ${username} ${password} ${role_id} ${enabled}
583
584 # Description of argument(s):
585 # username The username to be created.
586 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500587 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500588 # (e.g. "Administrator", "Operator", etc.).
589 # enabled Indicates whether the username being created
590 # should be enabled (${True}, ${False}).
591
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500592 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500593
594 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600595 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500596
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500597 Redfish.Logout
598
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500599 # Attempt to login with deleted user account.
600 Run Keyword And Expect Error InvalidCredentialsError*
601 ... Redfish.Login ${username} ${password}
602
603 Redfish.Login
604
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500605
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500606Verify Create User Without Enabling
607 [Documentation] Verify Create User Without Enabling.
608 [Arguments] ${username} ${password} ${role_id} ${enabled}
609
610 # Description of argument(s):
611 # username The username to be created.
612 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500613 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500614 # (e.g. "Administrator", "Operator", etc.).
615 # enabled Indicates whether the username being created
616 # should be enabled (${True}, ${False}).
617
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500618 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500619
620 Redfish.Logout
621
622 # Login with created user.
623 Run Keyword And Expect Error InvalidCredentialsError*
624 ... Redfish.Login ${username} ${password}
625
626 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500627
628 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600629 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500630