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