blob: 6e578933f50a4cbfe2ce1a15f053103a63bc40c1 [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
11
12** Test Cases **
13
14Verify AccountService Available
Sivas SRRfa6831c2019-02-22 00:12:00 -060015 [Documentation] Verify Redfish account service is available.
Sivas SRR6aa101f2019-02-19 22:31:55 -060016 [Tags] Verify_AccountService_Available
17
George Keishing97c93942019-03-04 12:45:07 -060018 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled
Sivas SRR6aa101f2019-02-19 22:31:55 -060019 Should Be Equal As Strings ${resp} ${True}
20
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060021Redfish Create and Verify Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050022 [Documentation] Create Redfish users with various roles.
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -060023 [Tags] Redfish_Create_and_Verify_Users
24 [Template] Redfish Create And Verify User
25
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050026 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050027 admin_user TestPwd123 Administrator ${True}
28 operator_user TestPwd123 Operator ${True}
29 user_user TestPwd123 User ${True}
30 callback_user TestPwd123 Callback ${True}
Sivas SRR6aa101f2019-02-19 22:31:55 -060031
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050032Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050033 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050034 [Tags] Verify_Redfish_User_with_Wrong_Password
35 [Template] Verify Redfish User with Wrong Password
36
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050037 #username password role_id enabled wrong_password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050038 admin_user TestPwd123 Administrator ${True} alskjhfwurh
39 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024
40 user_user TestPwd123 User ${True} 12
41 callback_user TestPwd123 Callback ${True} !#@D#RF#@!D
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050042
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050043Verify Login with Deleted Redfish Users
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050044 [Documentation] Verify login with deleted Redfish Users.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050045 [Tags] Verify_Login_with_Deleted_Redfish_Users
46 [Template] Verify Login with Deleted Redfish User
47
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050048 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050049 admin_user TestPwd123 Administrator ${True}
50 operator_user TestPwd123 Operator ${True}
51 user_user TestPwd123 User ${True}
52 callback_user TestPwd123 Callback ${True}
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -050053
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050054Verify User Creation Without Enabling it
55 [Documentation] Verify User Creation Without Enabling it.
56 [Tags] Verify_User_Creation_Without_Enabling_it
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050057 [Template] Verify Create User Without Enabling
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050058
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050059 #username password role_id enabled
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050060 admin_user TestPwd123 Administrator ${False}
61 operator_user TestPwd123 Operator ${False}
62 user_user TestPwd123 User ${False}
63 callback_user TestPwd123 Callback ${False}
64
65Verify Redfish User Persistence After Reboot
66 [Documentation] Verify Redfish user persistence after reboot.
67 [Tags] Verify_Redfish_User_Persistence_After_Reboot
68
69 # Create Redfish users.
70 Redfish Create User admin_user TestPwd123 Administrator ${True}
71 Redfish Create User operator_user TestPwd123 Operator ${True}
72 Redfish Create User user_user TestPwd123 User ${True}
73 Redfish Create User callback_user TestPwd123 Callback ${True}
74
75 # Reboot BMC.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050076 Redfish OBMC Reboot (off) stack_mode=normal
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -050077
78 # Verify users after reboot.
79 Redfish Verify User admin_user TestPwd123 Administrator ${True}
80 Redfish Verify User operator_user TestPwd123 Operator ${True}
81 Redfish Verify User user_user TestPwd123 User ${True}
82 Redfish Verify User callback_user TestPwd123 Callback ${True}
83
84 # Delete created users.
85 Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user
86 Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user
87 Redfish.Delete /redfish/v1/AccountService/Accounts/user_user
88 Redfish.Delete /redfish/v1/AccountService/Accounts/callback_user
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -050089
Sandhya Somashekare92b1e62019-04-25 05:27:45 -050090Verify User Creation With Invalid Role Id
91 [Documentation] Verify user creation with invalid role id.
92 [Tags] Verify_User_Creation_With_Invalid_Role_Id
93
94 # Make sure the user account in question does not already exist.
95 Redfish.Delete ${REDFISH_ACCOUNTS_URI}test_user
96 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
97
98 # Create specified user.
99 ${payload}= Create Dictionary
100 ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True}
101 Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
102 ... valid_status_codes=[${HTTP_BAD_REQUEST}]
103
104
Sivas SRR6aa101f2019-02-19 22:31:55 -0600105*** Keywords ***
106
107Test Setup Execution
108 [Documentation] Do test case setup tasks.
109
George Keishing97c93942019-03-04 12:45:07 -0600110 Redfish.Login
Sivas SRR6aa101f2019-02-19 22:31:55 -0600111
112
113Test Teardown Execution
114 [Documentation] Do the post test teardown.
115
116 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600117 Redfish.Logout
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600118
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500119Redfish Create User
120 [Documentation] Redfish create user.
121 [Arguments] ${username} ${password} ${role_id} ${enabled}
122
123 # Description of argument(s):
124 # username The username to be created.
125 # password The password to be assigned.
126 # role_id The role id of the user to be created
127 # (e.g. "Administrator", "Operator", etc.).
128 # enabled Indicates whether the username being created
129 # should be enabled (${True}, ${False}).
130
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500131 # Make sure the user account in question does not already exist.
132 Redfish.Delete ${REDFISH_ACCOUNTS_URI}${userName}
133 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
134
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500135 # Create specified user.
136 ${payload}= Create Dictionary
137 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500138 Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500139 ... valid_status_codes=[${HTTP_CREATED}]
140
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500141 Redfish.Logout
142
143 # Login with created user.
144 Run Keyword If ${enabled} == False
145 ... Run Keyword And Expect Error InvalidCredentialsError*
146 ... Redfish.Login ${username} ${password}
147 ... ELSE
148 ... Redfish.Login ${username} ${password}
149
150 Run Keyword If ${enabled} == False
151 ... Redfish.Login
152
153 # Validate Role Id of created user.
154 ${role_config}= Redfish_Utils.Get Attribute
155 ... /redfish/v1/AccountService/Accounts/${username} RoleId
156 Should Be Equal ${role_id} ${role_config}
157
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500158
159Redfish Verify User
160 [Documentation] Redfish user verification.
161 [Arguments] ${username} ${password} ${role_id} ${enabled}
162
163 # Description of argument(s):
164 # username The username to be created.
165 # password The password to be assigned.
166 # role_id The role id of the user to be created
167 # (e.g. "Administrator", "Operator", etc.).
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500168 # enabled Indicates whether the username being created
169 # should be enabled (${True}, ${False}).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500170
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500171 # Trying to do a login with created user.
172 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500173
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500174 # Doing a check of the returned status.
175 Should Be Equal ${status} ${enabled}
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500176
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500177 # We do not need to login with created user (user could be in disabled status).
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500178 Redfish.Login
179
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500180 # Validate Role Id of user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500181 ${role_config}= Redfish_Utils.Get Attribute
182 ... /redfish/v1/AccountService/Accounts/${username} RoleId
183 Should Be Equal ${role_id} ${role_config}
184
185
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600186Redfish Create And Verify User
187 [Documentation] Redfish create and verify user.
188 [Arguments] ${username} ${password} ${role_id} ${enabled}
189
190 # Description of argument(s):
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500191 # username The username to be created.
192 # password The password to be assigned.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500193 # role_id The role id of the user to be created
194 # (e.g. "Administrator", "Operator", etc.).
195 # enabled Indicates whether the username being created
196 # should be enabled (${True}, ${False}).
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600197
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500198 # Example:
199 #{
200 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount",
201 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1",
202 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount",
203 #"Description": "User Account",
204 #"Enabled": true,
205 #"Id": "test1",
206 #"Links": {
207 # "Role": {
208 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator"
209 # }
210 #},
211
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500212 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600213
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500214 Redfish Verify User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar00f59cc2019-03-05 03:39:47 -0600215
216 # Delete Specified User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500217 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}
218
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500219Verify Redfish User with Wrong Password
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500220 [Documentation] Verify Redfish User with Wrong Password.
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500221 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password}
222
223 # Description of argument(s):
224 # username The username to be created.
225 # password The password to be assigned.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500226 # role_id The role id of the user to be created
227 # (e.g. "Administrator", "Operator", etc.).
228 # enabled Indicates whether the username being created
229 # should be enabled (${True}, ${False}).
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500230 # wrong_password Any invalid password.
231
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500232 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500233
234 # Attempt to login with created user with invalid password.
235 Run Keyword And Expect Error InvalidCredentialsError*
236 ... Redfish.Login ${username} ${wrong_password}
237
238 Redfish.Login
239
240 # Delete newly created user.
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500241 Redfish.Delete ${REDFISH_ACCOUNTS_URI}${username}
Sandhya Somashekar33aa48c2019-03-13 05:54:49 -0500242
243
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500244Verify Login with Deleted Redfish User
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500245 [Documentation] Verify Login with Deleted Redfish User.
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500246 [Arguments] ${username} ${password} ${role_id} ${enabled}
247
248 # Description of argument(s):
249 # username The username to be created.
250 # password The password to be assigned.
251 # role_id The role id of the user to be created
252 # (e.g. "Administrator", "Operator", etc.).
253 # enabled Indicates whether the username being created
254 # should be enabled (${True}, ${False}).
255
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500256 Redfish Create User ${username} ${password} ${role_id} ${enabled}
Sandhya Somashekare92b1e62019-04-25 05:27:45 -0500257 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password}
258
259 # Doing a check of the rerurned status
260 Should Be Equal ${status} ${True}
261
262 Redfish.Login
263
264 # Delete newly created user.
265 Redfish.Delete ${REDFISH_ACCOUNTS_URI}${userName}
266
267 # Attempt to login with deleted user account.
268 Run Keyword And Expect Error InvalidCredentialsError*
269 ... Redfish.Login ${username} ${password}
270
271 Redfish.Login
272
273Verify Create User Without Enabling
274 [Documentation] Verify Create User Without Enabling.
275 [Arguments] ${username} ${password} ${role_id} ${enabled}
276
277 # Description of argument(s):
278 # username The username to be created.
279 # password The password to be assigned.
280 # role_id The role id of the user to be created
281 # (e.g. "Administrator", "Operator", etc.).
282 # enabled Indicates whether the username being created
283 # should be enabled (${True}, ${False}).
284
285 Redfish.Login
286
287 Redfish Create User ${username} ${password} ${role_id} ${enabled}
288
289 Redfish.Logout
290
291 # Login with created user.
292 Run Keyword And Expect Error InvalidCredentialsError*
293 ... Redfish.Login ${username} ${password}
294
295 Redfish.Login
Sandhya Somashekaraf402ca2019-03-18 05:59:19 -0500296
297 # Delete newly created user.
Sandhya Somashekaraa280aa2019-04-01 04:15:06 -0500298 Redfish.Delete /redfish/v1/AccountService/Accounts/${username}