blob: 00a43506404195979dad22e98bbb2d35b4c28506 [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
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -05009Test Setup Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -060010Test 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
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500125 # Make sure the new user account does not already exist.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600126 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500127 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
128
129 # Update admin_user username using Redfish.
130 ${payload}= Create Dictionary UserName=newadmin_user
Anusha Dathatri466816f2020-01-30 05:12:36 -0600131 Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500132
133 # Update operator_user password using Redfish.
134 ${payload}= Create Dictionary Password=NewTestPwd123
Anusha Dathatri466816f2020-01-30 05:12:36 -0600135 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500136
Anusha Dathatri4062b442020-02-03 04:39:15 -0600137 # Update readonly_user role using Redfish.
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500138 ${payload}= Create Dictionary RoleId=Operator
Anusha Dathatri466816f2020-01-30 05:12:36 -0600139 Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500140
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500141 # Verify users after updating
142 Redfish Verify User newadmin_user TestPwd123 Administrator ${True}
143 Redfish Verify User operator_user NewTestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600144 Redfish Verify User readonly_user TestPwd123 Operator ${True}
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500145
146 # Delete created users.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600147 Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user
148 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
149 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500150
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500151Verify User Account Locked
152 [Documentation] Verify user account locked upon trying with invalid password.
153 [Tags] Verify_User_Account_Locked
154
155 Redfish Create User admin_user TestPwd123 Administrator ${True}
156
Joy Onyerikwu1483ce02019-06-26 14:56:36 -0500157 ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold}
158 ... AccountLockoutDuration=${account_lockout_duration}
159 Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload}
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500160
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500161 Redfish.Logout
162
Sandhya Somashekar37122b62019-06-18 06:02:02 -0500163 # Make ${account_lockout_threshold} failed login attempts.
164 Repeat Keyword ${account_lockout_threshold} times
165 ... Run Keyword And Expect Error InvalidCredentialsError* Redfish.Login admin_user abc123
166
167 # Verify that legitimate login fails due to lockout.
168 Run Keyword And Expect Error InvalidCredentialsError*
169 ... Redfish.Login admin_user TestPwd123
170
171 # Wait for lockout duration to expire and then verify that login works.
172 Sleep ${account_lockout_duration}s
173 Redfish.Login admin_user TestPwd123
174
175 Redfish.Logout
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500176
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500177 Redfish.Login
178
Anusha Dathatri466816f2020-01-30 05:12:36 -0600179 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500180
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500181Verify Admin User Privilege
182 [Documentation] Verify admin user privilege.
183 [Tags] Verify_Admin_User_Privilege
184
185 Redfish Create User admin_user TestPwd123 Administrator ${True}
186 Redfish Create User operator_user TestPwd123 Operator ${True}
Anusha Dathatri4062b442020-02-03 04:39:15 -0600187 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500188
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500189 Redfish.Logout
190
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500191 # Change role ID of operator user with admin user.
192 # Login with admin user.
193 Redfish.Login admin_user TestPwd123
194
195 # Modify Role ID of Operator user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600196 Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'}
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500197
198 # Verify modified user.
199 Redfish Verify User operator_user TestPwd123 Administrator ${True}
200
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500201 Redfish.Logout
202 Redfish.Login admin_user TestPwd123
203
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500204 # 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
Anusha Dathatri466816f2020-01-30 05:12:36 -0600210 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
211 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
212 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500213
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500214Verify Operator User Privilege
215 [Documentation] Verify operator user privilege.
216 [Tags] Verify_operator_User_Privilege
217
218 Redfish Create User admin_user TestPwd123 Administrator ${True}
219 Redfish Create User operator_user TestPwd123 Operator ${True}
220
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500221 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500222 # Login with operator user.
223 Redfish.Login operator_user TestPwd123
224
George Keishing093c1bd2020-02-10 09:47:34 -0600225 # Verify BMC reset.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500226 Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500227
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'}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500230 ... valid_status_codes=[${HTTP_FORBIDDEN}]
231
232 Redfish.Logout
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500233
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500234 Redfish.Login
235
Anusha Dathatri466816f2020-01-30 05:12:36 -0600236 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
237 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500238
239
Anusha Dathatri4062b442020-02-03 04:39:15 -0600240Verify ReadOnly User Privilege
241 [Documentation] Verify ReadOnly user privilege.
242 [Tags] Verify_ReadOnly_User_Privilege
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500243
Anusha Dathatri4062b442020-02-03 04:39:15 -0600244 Redfish Create User readonly_user TestPwd123 ReadOnly ${True}
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500245 Redfish.Logout
246
247 # Login with read_only user.
248 Redfish.Login readonly_user TestPwd123
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500249
250 # Read system level data.
251 ${system_model}= Redfish_Utils.Get Attribute
252 ... ${SYSTEM_BASE_URI} Model
253
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500254 Redfish.Logout
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500255 Redfish.Login
Anusha Dathatri4062b442020-02-03 04:39:15 -0600256 Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user
Sandhya Somashekar7a237472019-07-15 02:06:39 -0500257
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500258
Anusha Dathatri466816f2020-01-30 05:12:36 -0600259Verify Minimum Password Length For Redfish User
260 [Documentation] Verify minimum password length for new and existing user.
261 [Tags] Verify_Minimum_Password_Length_For_Redfish_User
262
263 ${user_name}= Set Variable testUser
264
265 # Make sure the user account in question does not already exist.
266 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
267 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
268
269 # Try to create a user with invalid length password.
270 ${payload}= Create Dictionary
271 ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True}
272 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
273 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
274
275 # Create specified user with valid length password.
276 Set To Dictionary ${payload} Password UserPwd1
277 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload}
278 ... valid_status_codes=[${HTTP_CREATED}]
279
280 # Try to change to an invalid password.
281 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'}
282 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
283
284 # Change to a valid password.
285 Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'}
286
287 # Verify login.
288 Redfish.Logout
289 Redfish.Login ${user_name} UserPwd1
290 Redfish.Logout
291 Redfish.Login
292 Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name}
293
294
Sivas SRR6aa101f2019-02-19 22:31:55 -0600295*** Keywords ***
296
Sivas SRR6aa101f2019-02-19 22:31:55 -0600297Test Teardown Execution
298 [Documentation] Do the post test teardown.
299
Anusha Dathatridb769702020-02-12 01:02:30 -0600300 Run Keyword And Ignore Error Redfish.Logout
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500301 FFDC On Test Case Fail
302
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600303
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500304Redfish Create User
305 [Documentation] Redfish create user.
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500306 [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500307
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}).
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500315 # login_check Checks user login for created user.
316 # (e.g. ${True}, ${False}).
Sandhya Somashekar8c5b2492019-05-16 05:19:03 -0500317
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
Anusha Dathatrif7268b52020-02-19 01:03:49 -0600328 # Resetting pam tally count as a workaround for issue
329 # openbmc/phosphor-user-manager#4
330 ${cmd}= Catenate /usr/sbin/pam_tally2 -u ${username} --reset
331 Bmc Execute Command ${cmd}
332
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500333 # Verify login with created user.
334 ${status}= Run Keyword If '${login_check}' == '${True}'
335 ... Verify Redfish User Login ${username} ${password}
336 Run Keyword If '${login_check}' == '${True}' Should Be Equal ${status} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500337
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500338 # Validate Role ID of created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500339 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600340 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500341 Should Be Equal ${role_id} ${role_config}
342
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500343
344Redfish Verify User
345 [Documentation] Redfish user verification.
346 [Arguments] ${username} ${password} ${role_id} ${enabled}
347
348 # Description of argument(s):
349 # username The username to be created.
350 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500351 # role_id The role ID of the user to be created
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500352 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500353 # enabled Indicates whether the username being created
354 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500355
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500356 ${status}= Verify Redfish User Login ${username} ${password}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500357 # Doing a check of the returned status.
358 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500359
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500360 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500361 ${role_config}= Redfish_Utils.Get Attribute
Anusha Dathatri466816f2020-01-30 05:12:36 -0600362 ... /redfish/v1/AccountService/Accounts/${username} RoleId
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500363 Should Be Equal ${role_id} ${role_config}
364
365
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500366Verify Redfish User Login
367 [Documentation] Verify Redfish login with given user id.
368 [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login
369 [Arguments] ${username} ${password}
370
371 # Description of argument(s):
372 # username Login username.
373 # password Login password.
374
375 # Logout from current Redfish session.
George Keishing1cf2a422021-02-02 22:59:29 -0600376 # We don't really care if the current session is flushed out since we are going to login
377 # with new credential in next.
378 Run Keyword And Ignore Error Redfish.Logout
379
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500380 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
381 [Return] ${status}
382
383
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600384Redfish Create And Verify User
385 [Documentation] Redfish create and verify user.
386 [Arguments] ${username} ${password} ${role_id} ${enabled}
387
388 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500389 # username The username to be created.
390 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500391 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500392 # (e.g. "Administrator", "Operator", etc.).
393 # enabled Indicates whether the username being created
394 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600395
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500396 # Example:
397 #{
398 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
399 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
400 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
401 #"Description": "User Account",
402 #"Enabled": true,
403 #"Id": "test1",
404 #"Links": {
405 # "Role": {
406 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
407 # }
408 #},
409
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500410 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600411
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500412 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600413
414 # Delete Specified User
Anusha Dathatri466816f2020-01-30 05:12:36 -0600415 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500416
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500417Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500418 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500419 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
420
421 # Description of argument(s):
422 # username The username to be created.
423 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500424 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500425 # (e.g. "Administrator", "Operator", etc.).
426 # enabled Indicates whether the username being created
427 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500428 # wrong_password Any invalid password.
429
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500430 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500431
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500432 Redfish.Logout
433
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500434 # Attempt to login with created user with invalid password.
435 Run Keyword And Expect Error InvalidCredentialsError*
436 ... Redfish.Login ${username} ${wrong_password}
437
438 Redfish.Login
439
440 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600441 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500442
443
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500444Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500445 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500446 [Arguments] ${username} ${password} ${role_id} ${enabled}
447
448 # Description of argument(s):
449 # username The username to be created.
450 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500451 # role_id The role ID of the user to be created
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500452 # (e.g. "Administrator", "Operator", etc.).
453 # enabled Indicates whether the username being created
454 # should be enabled (${True}, ${False}).
455
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500456 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500457
458 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600459 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500460
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500461 Redfish.Logout
462
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500463 # Attempt to login with deleted user account.
464 Run Keyword And Expect Error InvalidCredentialsError*
465 ... Redfish.Login ${username} ${password}
466
467 Redfish.Login
468
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500469
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500470Verify Create User Without Enabling
471 [Documentation] Verify Create User Without Enabling.
472 [Arguments] ${username} ${password} ${role_id} ${enabled}
473
474 # Description of argument(s):
475 # username The username to be created.
476 # password The password to be assigned.
Sandhya Somashekard7d46c02019-06-26 05:10:25 -0500477 # role_id The role ID of the user to be created
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500478 # (e.g. "Administrator", "Operator", etc.).
479 # enabled Indicates whether the username being created
480 # should be enabled (${True}, ${False}).
481
Anusha Dathatrie0dddcf2020-06-18 05:23:16 -0500482 Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500483
484 Redfish.Logout
485
486 # Login with created user.
487 Run Keyword And Expect Error InvalidCredentialsError*
488 ... Redfish.Login ${username} ${password}
489
490 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500491
492 # Delete newly created user.
Anusha Dathatri466816f2020-01-30 05:12:36 -0600493 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
George Keishing07fb41f2020-06-16 08:09:19 -0500494