blob: e28fedb23780060e64df61b73c5313e203b564b5 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2
3Documentation This suite is for testing Open BMC user account management.
4
5Resource ../lib/rest_client.robot
6Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -05007Resource ../lib/openbmc_ffdc.robot
Chris Austenb29d2e82016-06-07 12:25:35 -05008
9Library OperatingSystem
10Library SSHLibrary
11Library String
George Keishingd55a4be2016-08-26 03:28:17 -050012Test Teardown Log FFDC
Chris Austenb29d2e82016-06-07 12:25:35 -050013
14*** Variables ***
15${RANDOM_STRING_LENGTH} ${8}
16${VALID_PASSWORD} abc123
17${NON_EXISTING_USER} aaaaa
18*** Test Cases ***
19
20Create and delete user group
21 [Documentation] ***GOOD PATH***
22 ... This testcase is for testing user group creation
23 ... and deletion in open bmc.\n
24
25 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
26 ${resp} = Create UserGroup ${groupname}
27 Should Be Equal ${resp} ok
28 ${usergroup_list} = Get GroupListUsr
29 Should Contain ${usergroup_list} ${groupname}
30 ${resp} = Delete Group ${groupname}
31 Should Be Equal ${resp} ok
32
33Create and delete user without groupname
34 [Documentation] ***GOOD PATH***
35 ... This testcase is for testing user creation with
36 ... without groupname in open bmc.\n
37
38 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
39 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
40 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
41
42 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
43 Should Be Equal ${resp} ok
44 ${user_list} = Get UserList
45 Should Contain ${user_list} ${username}
46
47 Login BMC ${username} ${password}
48 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
49 Should Be Equal ${rc} ${0}
50
51 ${resp} = Delete User ${username}
52 Should Be Equal ${resp} ok
53
54Create and delete user with user group name
55 [Documentation] ***GOOD PATH***
56 ... This testcase is for testing user creation with
57 ... user name, password, comment and group name(user group)
58 ... in open bmc.\n
59
60 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
61 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
62 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
63 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
64
65 ${resp} = Create UserGroup ${groupname}
66 Should Be Equal ${resp} ok
67 ${resp} = Create User ${comment} ${username} ${groupname} ${password}
68 Should Be Equal ${resp} ok
69 ${user_list} = Get UserList
70 Should Contain ${user_list} ${username}
71
72 Login BMC ${username} ${password}
73 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
74 Should Be Equal ${rc} ${0}
75
76 ${resp} = Delete User ${username}
77 Should Be Equal ${resp} ok
78 ${resp} = Delete Group ${groupname}
79 Should Be Equal ${resp} ok
80
81Create multiple users
82 [Documentation] ***GOOD PATH***
83 ... This testcase is to verify that multiple users creation
84 ... in open bmc.\n
85
86 : FOR ${INDEX} IN RANGE 1 10
87 \ Log ${INDEX}
88 \ ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
89 \ ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
90 \ ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
91 \ ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
92 \ Should Be Equal ${resp} ok
93 \ ${user_list} = Get UserList
94 \ Should Contain ${user_list} ${username}
95 \ Login BMC ${username} ${password}
96 \ ${rc}= Execute Command echo Login return_stdout=False return_rc=True
97 \ Should Be Equal ${rc} ${0}
98
99Create and delete user without password
100 [Documentation] ***GOOD PATH***
101 ... This testcase is to create and delete a user without password
102 ... in open bmc.\n
103
104 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
105 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
106 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
107 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
108
109 ${resp} = Create UserGroup ${groupname}
110 Should Be Equal ${resp} ok
111 ${resp} = Create User ${comment} ${username} ${groupname} ${EMPTY}
112 Should Be Equal ${resp} ok
113 ${user_list} = Get UserList
114 Should Contain ${user_list} ${username}
115
116 Login BMC ${username} ${EMPTY}
117 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
118 Should Be Equal ${rc} ${0}
119
120 ${resp} = Delete User ${username}
121 Should Be Equal ${resp} ok
122 ${resp} = Delete Group ${groupname}
123 Should Be Equal ${resp} ok
124
125Set password for existing user
126 [Documentation] ***GOOD PATH***
127 ... This testcase is for testing password set for user
128 ... in open bmc.\n
129
130 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
131 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
132 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
133
134 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
135 Should Be Equal ${resp} ok
136 ${user_list} = Get UserList
137 Should Contain ${user_list} ${username}
138
139 Login BMC ${username} ${password}
140 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
141 Should Be Equal ${rc} ${0}
142
143 ${resp} = Change Password ${username} ${VALID_PASSWORD}
144 Should Be Equal ${resp} ok
145
146 Login BMC ${username} ${VALID_PASSWORD}
147 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
148 Should Be Equal ${rc} ${0}
149
150 ${resp} = Delete User ${username}
151 Should Be Equal ${resp} ok
152
153Set password with empty password for existing
154 [Documentation] ***GOOD PATH***
155 ... This testcase is to verify that empty password can be set
156 ... for a existing user.\n
157
158 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
159 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
160 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
161
162 ${resp} = Create User ${comment} ${username} ${EMPTY} ${password}
163 Should Be Equal ${resp} ok
164 ${user_list} = Get UserList
165 Should Contain ${user_list} ${username}
166
167 Login BMC ${username} ${password}
168 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
169 Should Be Equal ${rc} ${0}
170
171 ${resp} = Change Password ${username} ${EMPTY}
172 Should Be Equal ${resp} ok
173
174 Login BMC ${username} ${EMPTY}
175 ${rc}= Execute Command echo Login return_stdout=False return_rc=True
176 Should Be Equal ${rc} ${0}
177
178Set password for non existing user
179 [Documentation] ***BAD PATH***
180 ... This testcase is for testing password set for non-existing user
181 ... in open bmc.\n
182
183 ${resp} = Change Password ${NON_EXISTING_USER} ${VALID_PASSWORD}
184 Should Be Equal ${resp} error
185
186Create existing user
187 [Documentation] ***BAD PATH***
188 ... This testcase is for checking that user creation is not allowed
189 ... for existing user in open bmc.\n
190
191 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
192 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
193 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
194
195 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
196 Should Be Equal ${resp} ok
197 ${resp} = Create User ${comment} ${username} ${EMPTY} ${EMPTY}
198 Should Be Equal ${resp} error
199
200 ${resp} = Delete User ${username}
201 Should Be Equal ${resp} ok
202
203Create user with no name
204 [Documentation] ***BAD PATH***
205 ... This testcase is for checking that user creation is not allowed
206 ... with empty username in open bmc.\n
207
208 ${username} = Generate Random String ${RANDOM_STRING_LENGTH}
209 ${password} = Generate Random String ${RANDOM_STRING_LENGTH}
210 ${comment} = Generate Random String ${RANDOM_STRING_LENGTH}
211 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
212
213 ${resp} = Create User ${comment} ${EMPTY} ${groupname} ${password}
214 Should Be Equal ${resp} error
215 ${user_list} = Get UserList
216 Should Not Contain ${user_list} ${EMPTY}
217
218Create existing user group
219 [Documentation] ***BAD PATH***
220 ... This testcase is for checking that user group creation is not allowed
221 ... for existing user group in open bmc.\n
222
223 ${groupname} = Generate Random String ${RANDOM_STRING_LENGTH}
224
225 ${resp} = Create UserGroup ${groupname}
226 Should Be Equal ${resp} ok
227 ${resp} = Create UserGroup ${groupname}
228 Should Be Equal ${resp} error
229
230 ${resp} = Delete Group ${groupname}
231 Should Be Equal ${resp} ok
232
233Create user group with no name
234 [Documentation] ***BAD PATH***
235 ... This testcase is for checking that user group creation is not allowed
236 ... with empty groupname in open bmc.\n
237
238 ${resp} = Create UserGroup ${EMPTY}
239 Should Be Equal ${resp} error
240 ${usergroup_list} = Get GroupListUsr
241 Should Not Contain ${usergroup_list} ${EMPTY}
242
243*** Keywords ***
244
245Get UserList
246 ${data} = create dictionary data=@{EMPTY}
247 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserList data=${data}
248 should be equal as strings ${resp.status_code} ${HTTP_OK}
249 ${jsondata} = to json ${resp.content}
250 [return] ${jsondata['data']}
251
252Get GroupListUsr
253 ${data} = create dictionary data=@{EMPTY}
254 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupListUsr data=${data}
255 should be equal as strings ${resp.status_code} ${HTTP_OK}
256 ${jsondata} = to json ${resp.content}
257 [return] ${jsondata['data']}
258
259Create User
260 [Arguments] ${comment} ${username} ${groupname} ${password}
261 @{user_list} = Create List ${comment} ${username} ${groupname} ${password}
262 ${data} = create dictionary data=@{user_list}
263 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Users/action/UserAdd data=${data}
264 ${jsondata} = to json ${resp.content}
265 [return] ${jsondata['status']}
266
267Change Password
268 [Arguments] ${username} ${password}
269 @{user_list} = Create List ${username} ${password}
270 ${data} = create dictionary data=@{user_list}
271 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/User/action/Passwd data=${data}
272 ${jsondata} = to json ${resp.content}
273 [return] ${jsondata['status']}
274
275Create UserGroup
276 [Arguments] ${args}
277 @{group_list} = Create List ${args}
278 ${data} = create dictionary data=@{group_list}
279 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Groups/action/GroupAddUsr data=${data}
280 ${jsondata} = to json ${resp.content}
281 [return] ${jsondata['status']}
282
283Delete Group
284 [Arguments] ${args}
285 @{group_list} = Create List ${args}
286 ${data} = create dictionary data=@{group_list}
287 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/Group/action/GroupDel data=${data}
288 ${jsondata} = to json ${resp.content}
289 [return] ${jsondata['status']}
290
291Delete User
292 [Arguments] ${args}
293 @{user_list} = Create List ${args}
294 ${data} = create dictionary data=@{user_list}
295 ${resp} = OpenBMC Post Request /org/openbmc/UserManager/User/action/Userdel data=${data}
296 ${jsondata} = to json ${resp.content}
297 [return] ${jsondata['status']}
298
299Login BMC
300 [Arguments] ${username} ${password}
301 Open connection ${OPENBMC_HOST}
302 ${resp} = Login ${username} ${password}
303 [return] ${resp}