blob: b82e7760599dc8051f02cc7c84bc005252c8a074 [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
8Test Setup Test Setup Execution
9Test Teardown Test Teardown Execution
10
Sandhya Somashekar37122b62019-06-18 06:02:02 -050011*** Variables ***
12
13${account_lockout_duration} ${30}
14${account_lockout_threshold} ${3}
15
Sivas SRR6aa101f2019-02-19 22:31:55 -060016** Test Cases **
17
18Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060019 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060020 [Tags] Verify_AccountService_Available
21
George Keishing97c93942019-03-04 12:45:07 -060022 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060023 Should Be Equal As Strings ${resp} ${True}
24
Sandhya Somashekara83fb472019-08-29 02:26:21 -050025Verify Redfish User Persistence After Reboot
26 [Documentation] Verify Redfish user persistence after reboot.
27 [Tags] Verify_Redfish_User_Persistence_After_Reboot
28
29 # Create Redfish users.
30 Redfish Create User admin_user TestPwd123 Administrator ${True}
31 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -060032 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekara83fb472019-08-29 02:26:21 -050033
34 # Reboot BMC.
35 Redfish OBMC Reboot (off) stack_mode=normal
36 Redfish.Login
37
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 Somashekar33aa48c2019-03-13 05:54:49 -050088
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050089Verify User Creation With Invalid Role Id
Sandhya Somashekard7d46c02019-06-26 05:10:25 -050090 [Documentation] Verify user creation with invalid role ID.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050091 [Tags] Verify_User_Creation_With_Invalid_Role_Id
92
93 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -060094 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050095 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
96
97 # Create specified user.
98 ${payload}= Create Dictionary
99 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600100 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500101 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
102
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500103Verify Error Upon Creating Same Users With Different Privileges
104 [Documentation] Verify error upon creating same users with different privileges.
105 [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges
106
107 Redfish Create User test_user TestPwd123 Administrator ${True}
108
109 # Create specified user.
110 ${payload}= Create Dictionary
111 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600112 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500113 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
114
Anusha Dathatri466816f2020-01-30 05:12:36 -0600115 Redfish.Delete /redfish/v1/AccountService/Accounts/test_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500116
117Verify Modifying User Attributes
118 [Documentation] Verify modifying user attributes.
119 [Tags] Verify_Modifying_User_Attributes
120
121 # Create Redfish users.
122 Redfish Create User admin_user TestPwd123 Administrator ${True}
123 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600124 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500125
126 Redfish.Login
127
128 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600129 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500130 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
131
132 # Update admin_user username using Redfish.
133 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600134 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500135
136 # Update operator_user password using Redfish.
137 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600138 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500139
Anusha Dathatri4062b442020-02-03 04:39:15 -0600140 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500141 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600142 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500143
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500144 # Verify users after updating
145 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
146 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600147 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500148
149 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600150 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
151 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
152 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500153
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500154Verify User Account Locked
155 [Documentation] Verify user account locked upon trying with invalid password.
156 [Tags] Verify_User_Account_Locked
157
158 Redfish Create User admin_user TestPwd123 Administrator ${True}
159
Sandhya Somashekar4737c8f2019-07-11 00:00:58 -0500160 Redfish.Logout
161
162 Redfish.Login
163
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500164 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
165 ... AccountLockoutDuration=${account_lockout_duration}
166 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500167
168 # Make ${account_lockout_threshold} failed login attempts.
169 Repeat Keyword ${account_lockout_threshold} times
170 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
171
172 # Verify that legitimate login fails due to lockout.
173 Run Keyword And Expect Error InvalidCredentialsError*
174 ... Redfish.Login admin_user TestPwd123
175
176 # Wait for lockout duration to expire and then verify that login works.
177 Sleep ${account_lockout_duration}s
178 Redfish.Login admin_user TestPwd123
179
180 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500181
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500182 Redfish.Login
183
Anusha Dathatri466816f2020-01-30 05:12:36 -0600184 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500185
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500186Verify Admin User Privilege
187 [Documentation] Verify admin user privilege.
188 [Tags] Verify_Admin_User_Privilege
189
190 Redfish Create User admin_user TestPwd123 Administrator ${True}
191 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600192 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500193
194 # Change role ID of operator user with admin user.
195 # Login with admin user.
196 Redfish.Login admin_user TestPwd123
197
198 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600199 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500200
201 # Verify modified user.
202 Redfish Verify User operator_user TestPwd123 Administrator ${True}
203
204 # Change password of 'user' user with admin user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600205 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500206
207 # Verify modified user.
Anusha Dathatri4062b442020-02-03 04:39:15 -0600208 Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500209
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500210 Redfish.Login
211
Anusha Dathatri466816f2020-01-30 05:12:36 -0600212 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
213 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
214 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500215
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500216Verify Operator User Privilege
217 [Documentation] Verify operator user privilege.
218 [Tags] Verify_operator_User_Privilege
219
220 Redfish Create User admin_user TestPwd123 Administrator ${True}
221 Redfish Create User operator_user TestPwd123 Operator ${True}
222
223 # Login with operator user.
224 Redfish.Login operator_user TestPwd123
225
226 # Verify power on system.
227 Redfish OBMC Reboot (off) stack_mode=normal
228
229 # Attempt to change password of admin user with operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600230 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500231 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
232
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500233 Redfish.Login
234
Anusha Dathatri466816f2020-01-30 05:12:36 -0600235 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
236 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500237
238
Anusha Dathatri4062b442020-02-03 04:39:15 -0600239Verify ReadOnly User Privilege
240 [Documentation] Verify ReadOnly user privilege.
241 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500242
Anusha Dathatri4062b442020-02-03 04:39:15 -0600243 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500244
245 # Read system level data.
246 ${system_model}= Redfish_Utils.Get Attribute
247 ... ${SYSTEM_BASE_URI} Model
248
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500249 Redfish.Login
250
Anusha Dathatri4062b442020-02-03 04:39:15 -0600251 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500252
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500253
Anusha Dathatri466816f2020-01-30 05:12:36 -0600254Verify Minimum Password Length For Redfish User
255 [Documentation] Verify minimum password length for new and existing user.
256 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
257
258 ${user_name}= Set Variable testUser
259
260 # Make sure the user account in question does not already exist.
261 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
262 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
263
264 # Try to create a user with invalid length password.
265 ${payload}= Create Dictionary
266 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
267 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
268 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
269
270 # Create specified user with valid length password.
271 Set To Dictionary ${payload} Password UserPwd1
272 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
273 ... valid_status_codes=[${HTTP_CREATED}]
274
275 # Try to change to an invalid password.
276 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
277 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
278
279 # Change to a valid password.
280 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
281
282 # Verify login.
283 Redfish.Logout
284 Redfish.Login ${user_name} UserPwd1
285 Redfish.Logout
286 Redfish.Login
287 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
288
289
Sivas SRR6aa101f2019-02-19 22:31:55 -0600290*** Keywords ***
291
292Test Setup Execution
293 [Documentation] Do test case setup tasks.
294
George Keishing97c93942019-03-04 12:45:07 -0600295 Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -0600296
297
298Test Teardown Execution
299 [Documentation] Do the post test teardown.
300
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500301 FFDC On Test Case Fail
Anusha Dathatridb769702020-02-12 01:02:30 -0600302 Run Keyword And Ignore Error Redfish.Logout
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600303
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500304Redfish Create User
305 [Documentation] Redfish create user.
306 [Arguments] ${username} ${password} ${role_id} ${enabled}
307
308 # Description of argument(s):
309 # username The username to be created.
310 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500311 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500312 # (e.g. "Administrator", "Operator", etc.).
313 # enabled Indicates whether the username being created
314 # should be enabled (${True}, ${False}).
315
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500316 Redfish.Login
317
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500318 # Make sure the user account in question does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600319 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500320 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
321
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500322 # Create specified user.
323 ${payload}= Create Dictionary
324 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Anusha Dathatri466816f2020-01-30 05:12:36 -0600325 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500326 ... valid_status_codes=[${HTTP_CREATED}]
327
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500328 Redfish.Logout
329
330 # Login with created user.
George Keishing4916b462019-08-08 23:24:48 -0500331 Run Keyword If ${enabled} == ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500332 ... Run Keyword And Expect Error InvalidCredentialsError*
333 ... Redfish.Login ${username} ${password}
334 ... ELSE
335 ... Redfish.Login ${username} ${password}
336
Sandhya Somashekara83fb472019-08-29 02:26:21 -0500337 Run Keyword If ${enabled} == ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500338 ... Redfish.Login
339
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500340 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500341 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600342 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500343 Should Be Equal ${role_id} ${role_config}
344
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500345
346Redfish Verify User
347 [Documentation] Redfish user verification.
348 [Arguments] ${username} ${password} ${role_id} ${enabled}
349
350 # Description of argument(s):
351 # username The username to be created.
352 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500353 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500354 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500355 # enabled Indicates whether the username being created
356 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500357
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500358 # Trying to do a login with created user.
359 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500360
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500361 # Doing a check of the returned status.
362 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500363
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500364 # We do not need to login with created user (user could be in disabled status).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500365 Redfish.Login
366
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500367 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500368 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600369 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500370 Should Be Equal ${role_id} ${role_config}
371
372
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600373Redfish Create And Verify User
374 [Documentation] Redfish create and verify user.
375 [Arguments] ${username} ${password} ${role_id} ${enabled}
376
377 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500378 # username The username to be created.
379 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500380 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500381 # (e.g. "Administrator", "Operator", etc.).
382 # enabled Indicates whether the username being created
383 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600384
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500385 # Example:
386 #{
387 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
388 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
389 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
390 #"Description": "User Account",
391 #"Enabled": true,
392 #"Id": "test1",
393 #"Links": {
394 # "Role": {
395 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
396 # }
397 #},
398
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500399 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600400
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500401 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600402
403 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600404 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500405
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500406Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500407 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500408 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
409
410 # Description of argument(s):
411 # username The username to be created.
412 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500413 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500414 # (e.g. "Administrator", "Operator", etc.).
415 # enabled Indicates whether the username being created
416 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500417 # wrong_password Any invalid password.
418
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500419 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500420
421 # Attempt to login with created user with invalid password.
422 Run Keyword And Expect Error InvalidCredentialsError*
423 ... Redfish.Login ${username} ${wrong_password}
424
425 Redfish.Login
426
427 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600428 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500429
430
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500431Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500432 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500433 [Arguments] ${username} ${password} ${role_id} ${enabled}
434
435 # Description of argument(s):
436 # username The username to be created.
437 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500438 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500439 # (e.g. "Administrator", "Operator", etc.).
440 # enabled Indicates whether the username being created
441 # should be enabled (${True}, ${False}).
442
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500443 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500444 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
445
446 # Doing a check of the rerurned status
447 Should Be Equal ${status} ${True}
448
449 Redfish.Login
450
451 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600452 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500453
454 # Attempt to login with deleted user account.
455 Run Keyword And Expect Error InvalidCredentialsError*
456 ... Redfish.Login ${username} ${password}
457
458 Redfish.Login
459
460Verify Create User Without Enabling
461 [Documentation] Verify Create User Without Enabling.
462 [Arguments] ${username} ${password} ${role_id} ${enabled}
463
464 # Description of argument(s):
465 # username The username to be created.
466 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500467 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500468 # (e.g. "Administrator", "Operator", etc.).
469 # enabled Indicates whether the username being created
470 # should be enabled (${True}, ${False}).
471
472 Redfish.Login
473
474 Redfish Create User ${username} ${password} ${role_id} ${enabled}
475
476 Redfish.Logout
477
478 # Login with created user.
479 Run Keyword And Expect Error InvalidCredentialsError*
480 ... Redfish.Login ${username} ${password}
481
482 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500483
484 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600485 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}