blob: 94181532185f3dda850a598b6e90a478450f17a5 [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
George Keishingd55a4be2016-08-26 03:28:17 -050018Test Teardown Log FFDC
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
30
31 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
32 ${resp} = Create UserGroup ${groupname}
33 Should Be Equal ${resp} ok
34 ${usergroup_list} = Get GroupListUsr
35 Should Contain ${usergroup_list} ${groupname}
36 ${resp} = Delete Group ${groupname}
37 Should Be Equal ${resp} ok
38
Rahul Maheshwarif8119102016-10-05 01:15:56 -050039Create and delete user without group name
Chris Austenb29d2e82016-06-07 12:25:35 -050040 [Documentation] ***GOOD PATH***
41 ... This testcase is for testing user creation with
42 ... without groupname in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050043 [Tags] Create_and_delete_user_without_group_name
Chris Austenb29d2e82016-06-07 12:25:35 -050044
45 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
46 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
47 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
48
49 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
50 Should Be Equal ${resp} ok
51 ${user_list} = Get UserList
52 Should Contain ${user_list} ${username}
53
54 Login BMC ${username} ${password}
55 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
56 Should Be Equal ${rc} ${0}
57
58 ${resp} = Delete User ${username}
59 Should Be Equal ${resp} ok
60
61Create and delete user with user group name
62 [Documentation] ***GOOD PATH***
63 ... This testcase is for testing user creation with
64 ... user name, password, comment and group name(user group)
65 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050066 [Tags] Create_and_delete_user_with_user_group_name
Chris Austenb29d2e82016-06-07 12:25:35 -050067
68 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
69 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
70 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
71 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
72
73 ${resp} = Create UserGroup ${groupname}
74 Should Be Equal ${resp} ok
75 ${resp} = Create User ${comment} ${username} ${groupname} ${password}
76 Should Be Equal ${resp} ok
77 ${user_list} = Get UserList
78 Should Contain ${user_list} ${username}
79
80 Login BMC ${username} ${password}
81 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
82 Should Be Equal ${rc} ${0}
83
84 ${resp} = Delete User ${username}
85 Should Be Equal ${resp} ok
86 ${resp} = Delete Group ${groupname}
87 Should Be Equal ${resp} ok
88
89Create multiple users
90 [Documentation] ***GOOD PATH***
91 ... This testcase is to verify that multiple users creation
92 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -050093 [Tags] Create_multiple_users
Chris Austenb29d2e82016-06-07 12:25:35 -050094
95 : FOR ${INDEX} IN RANGE 1 10
96 \ Log ${INDEX}
97 \ ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
98 \ ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
99 \ ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
100 \ ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
101 \ Should Be Equal ${resp} ok
102 \ ${user_list} = Get UserList
103 \ Should Contain ${user_list} ${username}
104 \ Login BMC ${username} ${password}
105 \ ${rc}= Execute Command echo Login return_stdout=False return_rc=True
106 \ Should Be Equal ${rc} ${0}
107
108Create and delete user without password
109 [Documentation] ***GOOD PATH***
110 ... This testcase is to create and delete a user without password
111 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500112 [Tags] Create_and_delete_user_without_password
Chris Austenb29d2e82016-06-07 12:25:35 -0500113
114 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
115 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
116 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
117 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
118
119 ${resp} = Create UserGroup ${groupname}
120 Should Be Equal ${resp} ok
121 ${resp} = Create User ${comment} ${username} ${groupname} ${EMPTY}
122 Should Be Equal ${resp} ok
123 ${user_list} = Get UserList
124 Should Contain ${user_list} ${username}
125
126 Login BMC ${username} ${EMPTY}
127 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
128 Should Be Equal ${rc} ${0}
129
130 ${resp} = Delete User ${username}
131 Should Be Equal ${resp} ok
132 ${resp} = Delete Group ${groupname}
133 Should Be Equal ${resp} ok
134
135Set password for existing user
136 [Documentation] ***GOOD PATH***
137 ... This testcase is for testing password set for user
138 ... in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500139 [Tags] Set_password_for_existing_user
Chris Austenb29d2e82016-06-07 12:25:35 -0500140
141 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
142 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
143 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
144
145 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
146 Should Be Equal ${resp} ok
147 ${user_list} = Get UserList
148 Should Contain ${user_list} ${username}
149
150 Login BMC ${username} ${password}
151 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
152 Should Be Equal ${rc} ${0}
153
154 ${resp} = Change Password ${username} ${VALID_PASSWORD}
155 Should Be Equal ${resp} ok
156
157 Login BMC ${username} ${VALID_PASSWORD}
158 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
159 Should Be Equal ${rc} ${0}
160
161 ${resp} = Delete User ${username}
162 Should Be Equal ${resp} ok
163
164Set password with empty password for existing
165 [Documentation] ***GOOD PATH***
George Keishingb843a592016-09-21 09:48:51 -0500166 ... This testcase is to verify that empty password can be set
Chris Austenb29d2e82016-06-07 12:25:35 -0500167 ... for a existing user.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500168 [Tags] Set_password_with_empty_password_for_existing
Chris Austenb29d2e82016-06-07 12:25:35 -0500169
170 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
171 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
172 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
173
174 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
175 Should Be Equal ${resp} ok
176 ${user_list} = Get UserList
177 Should Contain ${user_list} ${username}
178
179 Login BMC ${username} ${password}
180 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
181 Should Be Equal ${rc} ${0}
182
183 ${resp} = Change Password ${username} ${EMPTY}
184 Should Be Equal ${resp} ok
185
186 Login BMC ${username} ${EMPTY}
187 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
188 Should Be Equal ${rc} ${0}
189
190Set password for non existing user
191 [Documentation] ***BAD PATH***
192 ... This testcase is for testing password set for non-existing user
193 ... in open bmc.\n
194
195 ${resp} = Change Password ${NON_EXISTING_USER} ${VALID_PASSWORD}
196 Should Be Equal ${resp} error
197
198Create existing user
199 [Documentation] ***BAD PATH***
200 ... This testcase is for checking that user creation is not allowed
201 ... for existing user in open bmc.\n
Rahul Maheshwarif8119102016-10-05 01:15:56 -0500202 [Tags] Create_existing_user
Chris Austenb29d2e82016-06-07 12:25:35 -0500203
204 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
205 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
206 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
207
208 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
209 Should Be Equal ${resp} ok
210 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
211 Should Be Equal ${resp} error
212
213 ${resp} = Delete User ${username}
214 Should Be Equal ${resp} ok
215
216Create user with no name
217 [Documentation] ***BAD PATH***
218 ... This testcase is for checking that user creation is not allowed
219 ... with empty username in open bmc.\n
220
221 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
222 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
223 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
224 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
225
226 ${resp} = Create User ${comment} ${EMPTY} ${groupname} ${password}
227 Should Be Equal ${resp} error
228 ${user_list} = Get UserList
229 Should Not Contain ${user_list} ${EMPTY}
230
231Create existing user group
232 [Documentation] ***BAD PATH***
233 ... This testcase is for checking that user group creation is not allowed
234 ... for existing user group in open bmc.\n
235
236 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
237
238 ${resp} = Create UserGroup ${groupname}
239 Should Be Equal ${resp} ok
240 ${resp} = Create UserGroup ${groupname}
241 Should Be Equal ${resp} error
242
243 ${resp} = Delete Group ${groupname}
244 Should Be Equal ${resp} ok
245
246Create user group with no name
247 [Documentation] ***BAD PATH***
248 ... This testcase is for checking that user group creation is not allowed
249 ... with empty groupname in open bmc.\n
250
251 ${resp} = Create UserGroup ${EMPTY}
252 Should Be Equal ${resp} error
253 ${usergroup_list} = Get GroupListUsr
254 Should Not Contain ${usergroup_list} ${EMPTY}
255
George Keishingb843a592016-09-21 09:48:51 -0500256Cleanup Users List
257 [Documentation] ***GOOD PATH***
258 ... This testcase is to clean up multiple users created by
259 ... the test so as to leave the system in cleaner state.
260 ... This is a no-op if there is no user list on the BMC.
261 [Tags] CleanupUsersList
262
263 ${user_list} = Get UserList
264 : FOR ${username} IN @{user_list}
265 \ ${resp} = Delete User ${username}
266 \ Should Be Equal ${resp} ok
267
268
Chris Austenb29d2e82016-06-07 12:25:35 -0500269*** Keywords ***
270
271Get UserList
272 ${data} = create dictionary data=@{EMPTY}
273 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserList data=${data}
274 should be equal as strings ${resp.status_code} ${HTTP_OK}
275 ${jsondata} = to json ${resp.content}
276 [return] ${jsondata['data']}
277
278Get GroupListUsr
279 ${data} = create dictionary data=@{EMPTY}
280 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupListUsr data=${data}
281 should be equal as strings ${resp.status_code} ${HTTP_OK}
282 ${jsondata} = to json ${resp.content}
283 [return] ${jsondata['data']}
284
285Create User
286 [Arguments] ${comment} ${username} ${groupname} ${password}
287 @{user_list} = Create List ${comment} ${username} ${groupname} ${password}
288 ${data} = create dictionary data=@{user_list}
289 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserAdd data=${data}
290 ${jsondata} = to json ${resp.content}
291 [return] ${jsondata['status']}
292
293Change Password
294 [Arguments] ${username} ${password}
295 @{user_list} = Create List ${username} ${password}
296 ${data} = create dictionary data=@{user_list}
297 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/User/action/Passwd data=${data}
298 ${jsondata} = to json ${resp.content}
299 [return] ${jsondata['status']}
300
301Create UserGroup
302 [Arguments] ${args}
303 @{group_list} = Create List ${args}
304 ${data} = create dictionary data=@{group_list}
305 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupAddUsr data=${data}
306 ${jsondata} = to json ${resp.content}
307 [return] ${jsondata['status']}
308
309Delete Group
310 [Arguments] ${args}
311 @{group_list} = Create List ${args}
312 ${data} = create dictionary data=@{group_list}
313 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Group/action/GroupDel data=${data}
314 ${jsondata} = to json ${resp.content}
315 [return] ${jsondata['status']}
316
317Delete User
318 [Arguments] ${args}
319 @{user_list} = Create List ${args}
320 ${data} = create dictionary data=@{user_list}
321 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/User/action/Userdel data=${data}
322 ${jsondata} = to json ${resp.content}
323 [return] ${jsondata['status']}
324
325Login BMC
326 [Arguments] ${username} ${password}
327 Open connection ${OPENBMC_HOST}
328 ${resp} = Login ${username} ${password}
329 [return] ${resp}