blob: d9e02cd9e77e8aa7f5c6ded91ed5946109c2c7e7 [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
32 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
33 ${resp} = Create UserGroup ${groupname}
34 Should Be Equal ${resp} ok
35 ${usergroup_list} = Get GroupListUsr
36 Should Contain ${usergroup_list} ${groupname}
37 ${resp} = Delete Group ${groupname}
38 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
46 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
47 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
48 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
49
50 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
51 Should Be Equal ${resp} ok
52 ${user_list} = Get UserList
53 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
59 ${resp} = Delete User ${username}
60 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
69 ${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}
73
74 ${resp} = Create UserGroup ${groupname}
75 Should Be Equal ${resp} ok
76 ${resp} = Create User ${comment} ${username} ${groupname} ${password}
77 Should Be Equal ${resp} ok
78 ${user_list} = Get UserList
79 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
85 ${resp} = Delete User ${username}
86 Should Be Equal ${resp} ok
87 ${resp} = Delete Group ${groupname}
88 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}
98 \ ${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}
102 \ Should Be Equal ${resp} ok
103 \ ${user_list} = Get UserList
104 \ 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
115 ${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}
119
120 ${resp} = Create UserGroup ${groupname}
121 Should Be Equal ${resp} ok
122 ${resp} = Create User ${comment} ${username} ${groupname} ${EMPTY}
123 Should Be Equal ${resp} ok
124 ${user_list} = Get UserList
125 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
131 ${resp} = Delete User ${username}
132 Should Be Equal ${resp} ok
133 ${resp} = Delete Group ${groupname}
134 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
142 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
143 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
144 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
145
146 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
147 Should Be Equal ${resp} ok
148 ${user_list} = Get UserList
149 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
155 ${resp} = Change Password ${username} ${VALID_PASSWORD}
156 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
162 ${resp} = Delete User ${username}
163 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
171 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
172 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
173 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
174
175 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
176 Should Be Equal ${resp} ok
177 ${user_list} = Get UserList
178 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
184 ${resp} = Change Password ${username} ${EMPTY}
185 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
197 ${resp} = Change Password ${NON_EXISTING_USER} ${VALID_PASSWORD}
198 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
206 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
207 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
208 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
209
210 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
211 Should Be Equal ${resp} ok
212 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
213 Should Be Equal ${resp} error
214
215 ${resp} = Delete User ${username}
216 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
224 ${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}
228
229 ${resp} = Create User ${comment} ${EMPTY} ${groupname} ${password}
230 Should Be Equal ${resp} error
231 ${user_list} = Get UserList
232 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
240 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
241
242 ${resp} = Create UserGroup ${groupname}
243 Should Be Equal ${resp} ok
244 ${resp} = Create UserGroup ${groupname}
245 Should Be Equal ${resp} error
246
247 ${resp} = Delete Group ${groupname}
248 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
256 ${resp} = Create UserGroup ${EMPTY}
257 Should Be Equal ${resp} error
258 ${usergroup_list} = Get GroupListUsr
259 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
268 ${user_list} = Get UserList
269 : FOR ${username} IN @{user_list}
270 \ ${resp} = Delete User ${username}
271 \ Should Be Equal ${resp} ok
272
273
Chris Austenb29d2e82016-06-07 12:25:35 -0500274*** Keywords ***
275
276Get UserList
277 ${data} = create dictionary data=@{EMPTY}
278 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserList data=${data}
279 should be equal as strings ${resp.status_code} ${HTTP_OK}
280 ${jsondata} = to json ${resp.content}
281 [return] ${jsondata['data']}
282
283Get GroupListUsr
284 ${data} = create dictionary data=@{EMPTY}
285 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupListUsr data=${data}
286 should be equal as strings ${resp.status_code} ${HTTP_OK}
287 ${jsondata} = to json ${resp.content}
288 [return] ${jsondata['data']}
289
290Create User
291 [Arguments] ${comment} ${username} ${groupname} ${password}
292 @{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}
296 [return] ${jsondata['status']}
297
298Change Password
299 [Arguments] ${username} ${password}
300 @{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}
304 [return] ${jsondata['status']}
305
306Create UserGroup
307 [Arguments] ${args}
308 @{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}
312 [return] ${jsondata['status']}
313
314Delete Group
315 [Arguments] ${args}
316 @{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}
320 [return] ${jsondata['status']}
321
322Delete User
323 [Arguments] ${args}
324 @{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}
328 [return] ${jsondata['status']}
329
330Login BMC
331 [Arguments] ${username} ${password}
332 Open connection ${OPENBMC_HOST}
333 ${resp} = Login ${username} ${password}
334 [return] ${resp}