blob: e3b3d2af3150411ecb0d54fecc74fafb7212bf59 [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
7
George Keishing07fb41f2020-06-16 08:09:19 -05008Suite Setup Suite Setup Execution
Sivas SRR6aa101f2019-02-19 22:31:55 -06009Test Setup Test Setup Execution
10Test Teardown Test Teardown Execution
11
Sandhya Somashekar37122b62019-06-18 06:02:02 -050012*** Variables ***
13
14${account_lockout_duration} ${30}
15${account_lockout_threshold} ${3}
16
Sivas SRR6aa101f2019-02-19 22:31:55 -060017** Test Cases **
18
19Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060020 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060021 [Tags] Verify_AccountService_Available
22
George Keishing97c93942019-03-04 12:45:07 -060023 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060024 Should Be Equal As Strings ${resp} ${True}
25
Sandhya Somashekara83fb472019-08-29 02:26:21 -050026Verify Redfish User Persistence After Reboot
27 [Documentation] Verify Redfish user persistence after reboot.
28 [Tags] Verify_Redfish_User_Persistence_After_Reboot
29
30 # Create Redfish users.
31 Redfish Create User admin_user TestPwd123 Administrator ${True}
32 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060033 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050034
35 # Reboot BMC.
36 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekara83fb472019-08-29 02:26:21 -050037
38 # Verify users after reboot.
39 Redfish Verify User admin_user TestPwd123 Administrator ${True}
40 Redfish Verify User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060041 Redfish Verify User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050042
43 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -060044 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
45 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
46 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekara83fb472019-08-29 02:26:21 -050047
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060048Redfish Create and Verify Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050049 [Documentation] Create Redfish users with various roles.
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060050 [Tags] Redfish_Create_and_Verify_Users
51 [Template] Redfish Create And Verify User
52
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050053 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050054 admin_user TestPwd123 Administrator ${True}
55 operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060056 readonly_user TestPwd123 ReadOnly ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060057
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050058Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050059 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050060 [Tags] Verify_Redfish_User_with_Wrong_Password
61 [Template] Verify Redfish User with Wrong Password
62
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050063 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050064 admin_user TestPwd123 Administrator ${True} alskjhfwurh
65 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
Anusha Dathatri4062b442020-02-03 04:39:15 -060066 readonly_user TestPwd123 ReadOnly ${True} 12
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050067
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050068Verify Login with Deleted Redfish Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050069 [Documentation] Verify login with deleted Redfish Users.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050070 [Tags] Verify_Login_with_Deleted_Redfish_Users
71 [Template] Verify Login with Deleted Redfish User
72
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050073 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050074 admin_user TestPwd123 Administrator ${True}
75 operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060076 readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050077
George Keishinge0c5ec32019-06-13 09:45:29 -050078Verify User Creation Without Enabling It
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050079 [Documentation] Verify User Creation Without Enabling it.
George Keishinge0c5ec32019-06-13 09:45:29 -050080 [Tags] Verify_User_Creation_Without_Enabling_It
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050081 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050082
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050083 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050084 admin_user TestPwd123 Administrator ${False}
85 operator_user TestPwd123 Operator ${False}
Anusha Dathatri4062b442020-02-03 04:39:15 -060086 readonly_user TestPwd123 ReadOnly ${False}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050087
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050088Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -050089 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050090 [Tags] Verify_User_Creation_With_Invalid_Role_Id
91
92 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -060093 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050094 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
95
96 # Create specified user.
97 ${payload}= Create Dictionary
98 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -060099 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500100 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
101
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500102Verify Error Upon Creating Same Users With Different Privileges
103 [Documentation] Verify error upon creating same users with different privileges.
104 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
105
106 Redfish Create User test_user TestPwd123 Administrator ${True}
107
108 # Create specified user.
109 ${payload}= Create Dictionary
110 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600111 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500112 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
113
Anusha Dathatri466816f2020-01-30 05:12:36 -0600114 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500115
116Verify Modifying User Attributes
117 [Documentation] Verify modifying user attributes.
118 [Tags] Verify_Modifying_User_Attributes
119
120 # Create Redfish users.
121 Redfish Create User admin_user TestPwd123 Administrator ${True}
122 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600123 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500124
125 Redfish.Login
126
127 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600128 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500129 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
130
131 # Update admin_user username using Redfish.
132 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600133 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500134
135 # Update operator_user password using Redfish.
136 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600137 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500138
Anusha Dathatri4062b442020-02-03 04:39:15 -0600139 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500140 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600141 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500142
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500143 # Verify users after updating
144 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
145 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600146 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500147
148 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600149 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
150 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
151 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500152
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500153Verify User Account Locked
154 [Documentation] Verify user account locked upon trying with invalid password.
155 [Tags] Verify_User_Account_Locked
156
157 Redfish Create User admin_user TestPwd123 Administrator ${True}
158
Sandhya Somashekar4737c8f2019-07-11 00:00:58 -0500159 Redfish.Logout
160
161 Redfish.Login
162
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500163 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
164 ... AccountLockoutDuration=${account_lockout_duration}
165 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500166
167 # Make ${account_lockout_threshold} failed login attempts.
168 Repeat Keyword ${account_lockout_threshold} times
169 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
170
171 # Verify that legitimate login fails due to lockout.
172 Run Keyword And Expect Error InvalidCredentialsError*
173 ... Redfish.Login admin_user TestPwd123
174
175 # Wait for lockout duration to expire and then verify that login works.
176 Sleep ${account_lockout_duration}s
177 Redfish.Login admin_user TestPwd123
178
179 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500180
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500181 Redfish.Login
182
Anusha Dathatri466816f2020-01-30 05:12:36 -0600183 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500184
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500185Verify Admin User Privilege
186 [Documentation] Verify admin user privilege.
187 [Tags] Verify_Admin_User_Privilege
188
189 Redfish Create User admin_user TestPwd123 Administrator ${True}
190 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600191 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500192
193 # Change role ID of operator user with admin user.
194 # Login with admin user.
195 Redfish.Login admin_user TestPwd123
196
197 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600198 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500199
200 # Verify modified user.
201 Redfish Verify User operator_user TestPwd123 Administrator ${True}
202
203 # Change password of 'user' user with admin user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600204 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500205
206 # Verify modified user.
Anusha Dathatri4062b442020-02-03 04:39:15 -0600207 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500208
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500209 Redfish.Login
210
Anusha Dathatri466816f2020-01-30 05:12:36 -0600211 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
212 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
213 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500214
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500215Verify Operator User Privilege
216 [Documentation] Verify operator user privilege.
217 [Tags] Verify_operator_User_Privilege
218
219 Redfish Create User admin_user TestPwd123 Administrator ${True}
220 Redfish Create User operator_user TestPwd123 Operator ${True}
221
222 # Login with operator user.
223 Redfish.Login operator_user TestPwd123
224
George Keishing093c1bd2020-02-10 09:47:34 -0600225 # Verify BMC reset.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500226 Redfish OBMC Reboot (off) stack_mode=normal
227
228 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600229 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500230 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
231
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500232 Redfish.Login
233
Anusha Dathatri466816f2020-01-30 05:12:36 -0600234 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
235 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500236
237
Anusha Dathatri4062b442020-02-03 04:39:15 -0600238Verify ReadOnly User Privilege
239 [Documentation] Verify ReadOnly user privilege.
240 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500241
Anusha Dathatri4062b442020-02-03 04:39:15 -0600242 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500243
244 # Read system level data.
245 ${system_model}= Redfish_Utils.Get Attribute
246 ... ${SYSTEM_BASE_URI} Model
247
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500248 Redfish.Login
249
Anusha Dathatri4062b442020-02-03 04:39:15 -0600250 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500251
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500252
Anusha Dathatri466816f2020-01-30 05:12:36 -0600253Verify Minimum Password Length For Redfish User
254 [Documentation] Verify minimum password length for new and existing user.
255 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
256
257 ${user_name}= Set Variable testUser
258
259 # Make sure the user account in question does not already exist.
260 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
261 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
262
263 # Try to create a user with invalid length password.
264 ${payload}= Create Dictionary
265 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
266 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
267 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
268
269 # Create specified user with valid length password.
270 Set To Dictionary ${payload} Password UserPwd1
271 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
272 ... valid_status_codes=[${HTTP_CREATED}]
273
274 # Try to change to an invalid password.
275 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
276 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
277
278 # Change to a valid password.
279 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
280
281 # Verify login.
282 Redfish.Logout
283 Redfish.Login ${user_name} UserPwd1
284 Redfish.Logout
285 Redfish.Login
286 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
287
288
Sivas SRR6aa101f2019-02-19 22:31:55 -0600289*** Keywords ***
290
291Test Setup Execution
292 [Documentation] Do test case setup tasks.
293
George Keishing97c93942019-03-04 12:45:07 -0600294 Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -0600295
296
297Test Teardown Execution
298 [Documentation] Do the post test teardown.
299
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500300 FFDC On Test Case Fail
Anusha Dathatridb769702020-02-12 01:02:30 -0600301 Run Keyword And Ignore Error Redfish.Logout
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600302
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500303Redfish Create User
304 [Documentation] Redfish create user.
305 [Arguments] ${username} ${password} ${role_id} ${enabled}
306
307 # Description of argument(s):
308 # username The username to be created.
309 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500310 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500311 # (e.g. "Administrator", "Operator", etc.).
312 # enabled Indicates whether the username being created
313 # should be enabled (${True}, ${False}).
314
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500315 Redfish.Login
316
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500317 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600318 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500319 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
320
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500321 # Create specified user.
322 ${payload}= Create Dictionary
323 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600324 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500325 ... valid_status_codes=[${HTTP_CREATED}]
326
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600327 # Resetting pam tally count as a workaround for issue
328 # openbmc/phosphor-user-manager#4
329 ${cmd}= Catenate /usr/sbin/pam_tally2 -u ${username} --reset
330 Bmc Execute Command ${cmd}
331
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500332 Redfish.Logout
333
334 # Login with created user.
George Keishing4916b462019-08-08 23:24:48 -0500335 Run Keyword If ${enabled} == ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500336 ... Run Keyword And Expect Error InvalidCredentialsError*
337 ... Redfish.Login ${username} ${password}
338 ... ELSE
339 ... Redfish.Login ${username} ${password}
340
Sandhya Somashekara83fb472019-08-29 02:26:21 -0500341 Run Keyword If ${enabled} == ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500342 ... Redfish.Login
343
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500344 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500345 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600346 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500347 Should Be Equal ${role_id} ${role_config}
348
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500349
350Redfish Verify User
351 [Documentation] Redfish user verification.
352 [Arguments] ${username} ${password} ${role_id} ${enabled}
353
354 # Description of argument(s):
355 # username The username to be created.
356 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500357 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500358 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500359 # enabled Indicates whether the username being created
360 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500361
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500362 # Trying to do a login with created user.
363 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500364
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500365 # Doing a check of the returned status.
366 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500367
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500368 # We do not need to login with created user (user could be in disabled status).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500369 Redfish.Login
370
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500371 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500372 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600373 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500374 Should Be Equal ${role_id} ${role_config}
375
376
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600377Redfish Create And Verify User
378 [Documentation] Redfish create and verify user.
379 [Arguments] ${username} ${password} ${role_id} ${enabled}
380
381 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500382 # username The username to be created.
383 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500384 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500385 # (e.g. "Administrator", "Operator", etc.).
386 # enabled Indicates whether the username being created
387 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600388
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500389 # Example:
390 #{
391 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
392 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
393 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
394 #"Description": "User Account",
395 #"Enabled": true,
396 #"Id": "test1",
397 #"Links": {
398 # "Role": {
399 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
400 # }
401 #},
402
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500403 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600404
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500405 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600406
407 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600408 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500409
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500410Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500411 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500412 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
413
414 # Description of argument(s):
415 # username The username to be created.
416 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500417 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500418 # (e.g. "Administrator", "Operator", etc.).
419 # enabled Indicates whether the username being created
420 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500421 # wrong_password Any invalid password.
422
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500423 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500424
425 # Attempt to login with created user with invalid password.
426 Run Keyword And Expect Error InvalidCredentialsError*
427 ... Redfish.Login ${username} ${wrong_password}
428
429 Redfish.Login
430
431 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600432 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500433
434
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500435Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500436 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500437 [Arguments] ${username} ${password} ${role_id} ${enabled}
438
439 # Description of argument(s):
440 # username The username to be created.
441 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500442 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500443 # (e.g. "Administrator", "Operator", etc.).
444 # enabled Indicates whether the username being created
445 # should be enabled (${True}, ${False}).
446
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500447 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500448 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
449
450 # Doing a check of the rerurned status
451 Should Be Equal ${status} ${True}
452
453 Redfish.Login
454
455 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600456 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500457
458 # Attempt to login with deleted user account.
459 Run Keyword And Expect Error InvalidCredentialsError*
460 ... Redfish.Login ${username} ${password}
461
462 Redfish.Login
463
464Verify Create User Without Enabling
465 [Documentation] Verify Create User Without Enabling.
466 [Arguments] ${username} ${password} ${role_id} ${enabled}
467
468 # Description of argument(s):
469 # username The username to be created.
470 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500471 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500472 # (e.g. "Administrator", "Operator", etc.).
473 # enabled Indicates whether the username being created
474 # should be enabled (${True}, ${False}).
475
476 Redfish.Login
477
478 Redfish Create User ${username} ${password} ${role_id} ${enabled}
479
480 Redfish.Logout
481
482 # Login with created user.
483 Run Keyword And Expect Error InvalidCredentialsError*
484 ... Redfish.Login ${username} ${password}
485
486 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500487
488 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600489 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500490
491
492Suite Setup Execution
493 [Documentation] Do test case setup tasks.
494
495 Redfish.Login