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