blob: 3445697d0319d7d3525db9a7e03d8f46c3a9304e [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2
3Documentation This suite is for testing Open BMC user account management.
George Keishingb843a592016-09-21 09:48:51 -05004... The randomness of the string generated is limited to the
5... instance per test case however we end up running multiple
6... test and multiple iteration. This creates scenario where
7... the same previous user is generated.
8... As a good pratice, clean up all the users at the end of
9... test.
Chris Austenb29d2e82016-06-07 12:25:35 -050010
11Resource ../lib/rest_client.robot
12Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -050013Resource ../lib/openbmc_ffdc.robot
Chris Austenb29d2e82016-06-07 12:25:35 -050014
15Library OperatingSystem
16Library SSHLibrary
17Library String
Gunnar Millseac1af22016-11-14 15:30:09 -060018Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -050019
20*** Variables ***
21${RANDOM_STRING_LENGTH} ${8}
22${VALID_PASSWORD} abc123
23${NON_EXISTING_USER} aaaaa
24*** Test Cases ***
25
26Create and delete user group
27 [Documentation] ***GOOD PATH***
28 ... This testcase is for testing user group creation
29 ... and deletion in open bmc.\n
George Keishingc965bc12016-10-18 12:15:43 -050030 [Tags] Create_and_delete_user_group
Chris Austenb29d2e82016-06-07 12:25:35 -050031
Gunnar Mills1cd544d2016-12-06 11:19:22 -060032 ${groupname}= Generate Random String ${RANDOM_STRING_LENGTH}
33 ${resp}= Create UserGroup ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -050034 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -060035 ${usergroup_list}= Get GroupListUsr
Chris Austenb29d2e82016-06-07 12:25:35 -050036 Should Contain ${usergroup_list} ${groupname}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060037 ${resp}= Delete Group ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -050038 Should Be Equal ${resp} ok
39
Rahul Maheshwarif8119102016-10-05 01:15:56 -050040Create and delete user without group name
Chris Austenb29d2e82016-06-07 12:25:35 -050041 [Documentation] ***GOOD PATH***
42 ... This testcase is for testing user creation with
43 ... without groupname in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050044 [Tags] Create_and_delete_user_without_group_name
Chris Austenb29d2e82016-06-07 12:25:35 -050045
Gunnar Mills1cd544d2016-12-06 11:19:22 -060046 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
47 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
48 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -050049
Gunnar Mills1cd544d2016-12-06 11:19:22 -060050 ${resp}= Create User ${comment} ${username} ${EMPTY} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -050051 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -060052 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -050053 Should Contain ${user_list} ${username}
54
55 Login BMC ${username} ${password}
56 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
57 Should Be Equal ${rc} ${0}
58
Gunnar Mills1cd544d2016-12-06 11:19:22 -060059 ${resp}= Delete User ${username}
Chris Austenb29d2e82016-06-07 12:25:35 -050060 Should Be Equal ${resp} ok
61
62Create and delete user with user group name
63 [Documentation] ***GOOD PATH***
64 ... This testcase is for testing user creation with
65 ... user name, password, comment and group name(user group)
66 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050067 [Tags] Create_and_delete_user_with_user_group_name
Chris Austenb29d2e82016-06-07 12:25:35 -050068
Gunnar Mills1cd544d2016-12-06 11:19:22 -060069 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
70 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
71 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
72 ${groupname}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -050073
Gunnar Mills1cd544d2016-12-06 11:19:22 -060074 ${resp}= Create UserGroup ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -050075 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -060076 ${resp}= Create User ${comment} ${username} ${groupname} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -050077 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -060078 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -050079 Should Contain ${user_list} ${username}
80
81 Login BMC ${username} ${password}
82 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
83 Should Be Equal ${rc} ${0}
84
Gunnar Mills1cd544d2016-12-06 11:19:22 -060085 ${resp}= Delete User ${username}
Chris Austenb29d2e82016-06-07 12:25:35 -050086 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -060087 ${resp}= Delete Group ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -050088 Should Be Equal ${resp} ok
89
90Create multiple users
91 [Documentation] ***GOOD PATH***
92 ... This testcase is to verify that multiple users creation
93 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050094 [Tags] Create_multiple_users
Chris Austenb29d2e82016-06-07 12:25:35 -050095
96 : FOR ${INDEX} IN RANGE 1 10
97 \ Log ${INDEX}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060098 \ ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
99 \ ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
100 \ ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
101 \ ${resp}= Create User ${comment} ${username} ${EMPTY} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -0500102 \ Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600103 \ ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -0500104 \ Should Contain ${user_list} ${username}
105 \ Login BMC ${username} ${password}
106 \ ${rc}= Execute Command echo Login return_stdout=False return_rc=True
107 \ Should Be Equal ${rc} ${0}
108
109Create and delete user without password
110 [Documentation] ***GOOD PATH***
111 ... This testcase is to create and delete a user without password
112 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500113 [Tags] Create_and_delete_user_without_password
Chris Austenb29d2e82016-06-07 12:25:35 -0500114
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600115 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
116 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
117 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
118 ${groupname}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500119
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600120 ${resp}= Create UserGroup ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -0500121 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600122 ${resp}= Create User ${comment} ${username} ${groupname} ${EMPTY}
Chris Austenb29d2e82016-06-07 12:25:35 -0500123 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600124 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -0500125 Should Contain ${user_list} ${username}
126
127 Login BMC ${username} ${EMPTY}
128 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
129 Should Be Equal ${rc} ${0}
130
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600131 ${resp}= Delete User ${username}
Chris Austenb29d2e82016-06-07 12:25:35 -0500132 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600133 ${resp}= Delete Group ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -0500134 Should Be Equal ${resp} ok
135
136Set password for existing user
137 [Documentation] ***GOOD PATH***
138 ... This testcase is for testing password set for user
139 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500140 [Tags] Set_password_for_existing_user
Chris Austenb29d2e82016-06-07 12:25:35 -0500141
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600142 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
143 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
144 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500145
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600146 ${resp}= Create User ${comment} ${username} ${EMPTY} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -0500147 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600148 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -0500149 Should Contain ${user_list} ${username}
150
151 Login BMC ${username} ${password}
152 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
153 Should Be Equal ${rc} ${0}
154
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600155 ${resp}= Change Password ${username} ${VALID_PASSWORD}
Chris Austenb29d2e82016-06-07 12:25:35 -0500156 Should Be Equal ${resp} ok
157
158 Login BMC ${username} ${VALID_PASSWORD}
159 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
160 Should Be Equal ${rc} ${0}
161
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600162 ${resp}= Delete User ${username}
Chris Austenb29d2e82016-06-07 12:25:35 -0500163 Should Be Equal ${resp} ok
164
165Set password with empty password for existing
166 [Documentation] ***GOOD PATH***
George Keishingb843a592016-09-21 09:48:51 -0500167 ... This testcase is to verify that empty password can be set
Chris Austenb29d2e82016-06-07 12:25:35 -0500168 ... for a existing user.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500169 [Tags] Set_password_with_empty_password_for_existing
Chris Austenb29d2e82016-06-07 12:25:35 -0500170
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600171 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
172 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
173 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500174
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600175 ${resp}= Create User ${comment} ${username} ${EMPTY} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -0500176 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600177 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -0500178 Should Contain ${user_list} ${username}
179
180 Login BMC ${username} ${password}
181 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
182 Should Be Equal ${rc} ${0}
183
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600184 ${resp}= Change Password ${username} ${EMPTY}
Chris Austenb29d2e82016-06-07 12:25:35 -0500185 Should Be Equal ${resp} ok
186
187 Login BMC ${username} ${EMPTY}
188 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
189 Should Be Equal ${rc} ${0}
190
191Set password for non existing user
192 [Documentation] ***BAD PATH***
193 ... This testcase is for testing password set for non-existing user
194 ... in open bmc.\n
George Keishingc965bc12016-10-18 12:15:43 -0500195 [Tags] Set_password_for_non_existing_user
Chris Austenb29d2e82016-06-07 12:25:35 -0500196
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600197 ${resp}= Change Password ${NON_EXISTING_USER} ${VALID_PASSWORD}
Chris Austenb29d2e82016-06-07 12:25:35 -0500198 Should Be Equal ${resp} error
199
200Create existing user
201 [Documentation] ***BAD PATH***
202 ... This testcase is for checking that user creation is not allowed
203 ... for existing user in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500204 [Tags] Create_existing_user
Chris Austenb29d2e82016-06-07 12:25:35 -0500205
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600206 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
207 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
208 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500209
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600210 ${resp}= Create User ${comment} ${username} ${EMPTY} ${EMPTY}
Chris Austenb29d2e82016-06-07 12:25:35 -0500211 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600212 ${resp}= Create User ${comment} ${username} ${EMPTY} ${EMPTY}
Chris Austenb29d2e82016-06-07 12:25:35 -0500213 Should Be Equal ${resp} error
214
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600215 ${resp}= Delete User ${username}
Chris Austenb29d2e82016-06-07 12:25:35 -0500216 Should Be Equal ${resp} ok
217
218Create user with no name
219 [Documentation] ***BAD PATH***
220 ... This testcase is for checking that user creation is not allowed
221 ... with empty username in open bmc.\n
George Keishingc965bc12016-10-18 12:15:43 -0500222 [Tags] Create_user_with_no_name
Chris Austenb29d2e82016-06-07 12:25:35 -0500223
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600224 ${username}= Generate Random String ${RANDOM_STRING_LENGTH}
225 ${password}= Generate Random String ${RANDOM_STRING_LENGTH}
226 ${comment}= Generate Random String ${RANDOM_STRING_LENGTH}
227 ${groupname}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500228
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600229 ${resp}= Create User ${comment} ${EMPTY} ${groupname} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -0500230 Should Be Equal ${resp} error
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600231 ${user_list}= Get UserList
Chris Austenb29d2e82016-06-07 12:25:35 -0500232 Should Not Contain ${user_list} ${EMPTY}
233
234Create existing user group
235 [Documentation] ***BAD PATH***
236 ... This testcase is for checking that user group creation is not allowed
237 ... for existing user group in open bmc.\n
George Keishingc965bc12016-10-18 12:15:43 -0500238 [Tags] Create_existing_user_group
Chris Austenb29d2e82016-06-07 12:25:35 -0500239
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600240 ${groupname}= Generate Random String ${RANDOM_STRING_LENGTH}
Chris Austenb29d2e82016-06-07 12:25:35 -0500241
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600242 ${resp}= Create UserGroup ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -0500243 Should Be Equal ${resp} ok
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600244 ${resp}= Create UserGroup ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -0500245 Should Be Equal ${resp} error
246
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600247 ${resp}= Delete Group ${groupname}
Chris Austenb29d2e82016-06-07 12:25:35 -0500248 Should Be Equal ${resp} ok
249
250Create user group with no name
251 [Documentation] ***BAD PATH***
252 ... This testcase is for checking that user group creation is not allowed
253 ... with empty groupname in open bmc.\n
George Keishingc965bc12016-10-18 12:15:43 -0500254 [Tags] Create_user_group_with_no_name
Chris Austenb29d2e82016-06-07 12:25:35 -0500255
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600256 ${resp}= Create UserGroup ${EMPTY}
Chris Austenb29d2e82016-06-07 12:25:35 -0500257 Should Be Equal ${resp} error
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600258 ${usergroup_list}= Get GroupListUsr
Chris Austenb29d2e82016-06-07 12:25:35 -0500259 Should Not Contain ${usergroup_list} ${EMPTY}
260
George Keishingb843a592016-09-21 09:48:51 -0500261Cleanup Users List
262 [Documentation] ***GOOD PATH***
263 ... This testcase is to clean up multiple users created by
264 ... the test so as to leave the system in cleaner state.
265 ... This is a no-op if there is no user list on the BMC.
George Keishingc965bc12016-10-18 12:15:43 -0500266 [Tags] Cleanup_Users_List
George Keishingb843a592016-09-21 09:48:51 -0500267
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600268 ${user_list}= Get UserList
George Keishingb843a592016-09-21 09:48:51 -0500269 : FOR ${username} IN @{user_list}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600270 \ ${resp}= Delete User ${username}
George Keishingb843a592016-09-21 09:48:51 -0500271 \ Should Be Equal ${resp} ok
272
273
Chris Austenb29d2e82016-06-07 12:25:35 -0500274*** Keywords ***
275
276Get UserList
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600277 ${data}= create dictionary data=@{EMPTY}
278 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserList data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500279 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600280 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500281 [return] ${jsondata['data']}
282
283Get GroupListUsr
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600284 ${data}= create dictionary data=@{EMPTY}
285 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupListUsr data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500286 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600287 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500288 [return] ${jsondata['data']}
289
290Create User
291 [Arguments] ${comment} ${username} ${groupname} ${password}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600292 @{user_list}= Create List ${comment} ${username} ${groupname} ${password}
293 ${data}= create dictionary data=@{user_list}
294 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserAdd data=${data}
295 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500296 [return] ${jsondata['status']}
297
298Change Password
299 [Arguments] ${username} ${password}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600300 @{user_list}= Create List ${username} ${password}
301 ${data}= create dictionary data=@{user_list}
302 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/User/action/Passwd data=${data}
303 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500304 [return] ${jsondata['status']}
305
306Create UserGroup
307 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600308 @{group_list}= Create List ${args}
309 ${data}= create dictionary data=@{group_list}
310 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupAddUsr data=${data}
311 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500312 [return] ${jsondata['status']}
313
314Delete Group
315 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600316 @{group_list}= Create List ${args}
317 ${data}= create dictionary data=@{group_list}
318 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/Group/action/GroupDel data=${data}
319 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500320 [return] ${jsondata['status']}
321
322Delete User
323 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600324 @{user_list}= Create List ${args}
325 ${data}= create dictionary data=@{user_list}
326 ${resp}= OpenBMC Post Request /org/openbmc/UserManager/User/action/Userdel data=${data}
327 ${jsondata}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500328 [return] ${jsondata['status']}
329
330Login BMC
331 [Arguments] ${username} ${password}
332 Open connection ${OPENBMC_HOST}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600333 ${resp}= Login ${username} ${password}
Chris Austenb29d2e82016-06-07 12:25:35 -0500334 [return] ${resp}