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 |
Gunnar Mills | eac1af2 | 2016-11-14 15:30:09 -0600 | [diff] [blame] | 18 | Test Teardown FFDC On Test Case Fail |
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 |
George Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 30 | [Tags] Create_and_delete_user_group |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 31 | |
| 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 Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 40 | Create and delete user without group name |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 41 | [Documentation] ***GOOD PATH*** |
| 42 | ... This testcase is for testing user creation with |
| 43 | ... without groupname in open bmc.\n |
Rahul Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 44 | [Tags] Create_and_delete_user_without_group_name |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 45 | |
| 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 | |
| 62 | Create 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 Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 67 | [Tags] Create_and_delete_user_with_user_group_name |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 68 | |
| 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 | |
| 90 | Create multiple users |
| 91 | [Documentation] ***GOOD PATH*** |
| 92 | ... This testcase is to verify that multiple users creation |
| 93 | ... in open bmc.\n |
Rahul Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 94 | [Tags] Create_multiple_users |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 95 | |
| 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 | |
| 109 | Create 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 Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 113 | [Tags] Create_and_delete_user_without_password |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 114 | |
| 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 | |
| 136 | Set password for existing user |
| 137 | [Documentation] ***GOOD PATH*** |
| 138 | ... This testcase is for testing password set for user |
| 139 | ... in open bmc.\n |
Rahul Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 140 | [Tags] Set_password_for_existing_user |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 141 | |
| 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 | |
| 165 | Set password with empty password for existing |
| 166 | [Documentation] ***GOOD PATH*** |
George Keishing | b843a59 | 2016-09-21 09:48:51 -0500 | [diff] [blame] | 167 | ... This testcase is to verify that empty password can be set |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 168 | ... for a existing user.\n |
Rahul Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 169 | [Tags] Set_password_with_empty_password_for_existing |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 170 | |
| 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 | |
| 191 | Set 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 Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 195 | [Tags] Set_password_for_non_existing_user |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 196 | |
| 197 | ${resp} = Change Password ${NON_EXISTING_USER} ${VALID_PASSWORD} |
| 198 | Should Be Equal ${resp} error |
| 199 | |
| 200 | Create 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 Maheshwari | f811910 | 2016-10-05 01:15:56 -0500 | [diff] [blame] | 204 | [Tags] Create_existing_user |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 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 | |
| 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 | |
| 218 | Create 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 Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 222 | [Tags] Create_user_with_no_name |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 223 | |
| 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 | |
| 234 | Create 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 Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 238 | [Tags] Create_existing_user_group |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 239 | |
| 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 | |
| 250 | Create 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 Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 254 | [Tags] Create_user_group_with_no_name |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 255 | |
| 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 Keishing | b843a59 | 2016-09-21 09:48:51 -0500 | [diff] [blame] | 261 | Cleanup 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 Keishing | c965bc1 | 2016-10-18 12:15:43 -0500 | [diff] [blame] | 266 | [Tags] Cleanup_Users_List |
George Keishing | b843a59 | 2016-09-21 09:48:51 -0500 | [diff] [blame] | 267 | |
| 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 Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 274 | *** Keywords *** |
| 275 | |
| 276 | Get 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 | |
| 283 | Get 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 | |
| 290 | Create 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 | |
| 298 | Change 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 | |
| 306 | Create 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 | |
| 314 | Delete 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 | |
| 322 | Delete 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 | |
| 330 | Login BMC |
| 331 | [Arguments] ${username} ${password} |
| 332 | Open connection ${OPENBMC_HOST} |
| 333 | ${resp} = Login ${username} ${password} |
| 334 | [return] ${resp} |