manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | |
| 4 | Documentation Suite to test local user management. |
| 5 | |
| 6 | Library OperatingSystem |
| 7 | Library String |
| 8 | Library Collections |
| 9 | |
| 10 | Resource ../../lib/resource.robot |
| 11 | Resource ../../lib/bmc_redfish_resource.robot |
| 12 | Resource ../../lib/openbmc_ffdc.robot |
| 13 | Resource ../../lib/certificate_utils.robot |
manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 14 | Resource ../../lib/dmtf_redfishtool_utils.robot |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 15 | |
| 16 | Suite Setup Suite Setup Execution |
| 17 | |
| 18 | |
| 19 | *** Variables *** |
| 20 | |
| 21 | ${root_cmd_args} = SEPARATOR= |
George Keishing | d4ba249 | 2022-01-10 08:27:34 -0600 | [diff] [blame] | 22 | ... redfishtool raw -r ${OPENBMC_HOST}:${HTTPS_PORT} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 23 | |
| 24 | |
| 25 | *** Test Cases *** |
| 26 | |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 27 | Verify Redfishtool Create Users |
| 28 | [Documentation] Create user via Redfishtool and verify. |
| 29 | [Tags] Verify_Redfishtool_Create_Users |
| 30 | [Teardown] Redfishtool Delete User "UserT100" |
| 31 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 32 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
| 33 | Redfishtool Verify User "UserT100" "ReadOnly" |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 34 | |
| 35 | |
| 36 | Verify Redfishtool Modify Users |
| 37 | [Documentation] Modify user via Redfishtool and verify. |
| 38 | [Tags] Verify_Redfishtool_Modify_Users |
| 39 | [Teardown] Redfishtool Delete User "UserT100" |
| 40 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 41 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 42 | Redfishtool Update User Role "UserT100" "Administrator" |
| 43 | Redfishtool Verify User "UserT100" "Administrator" |
| 44 | |
| 45 | |
| 46 | Verify Redfishtool Delete Users |
| 47 | [Documentation] Delete user via Redfishtool and verify. |
| 48 | [Tags] Verify_Redfishtool_Delete_Users |
| 49 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 50 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 51 | Redfishtool Delete User "UserT100" |
| 52 | ${status}= Redfishtool Verify User Name Exists "UserT100" |
| 53 | Should Be True ${status} == False |
| 54 | |
| 55 | |
| 56 | Verify Redfishtool Login With Deleted Redfish Users |
| 57 | [Documentation] Verify login with deleted user via Redfishtool. |
| 58 | [Tags] Verify_Redfishtool_Login_With_Deleted_Redfish_Users |
| 59 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 60 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 61 | Redfishtool Delete User "UserT100" |
| 62 | Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123" |
| 63 | ... ${HTTP_UNAUTHORIZED} |
| 64 | |
| 65 | |
| 66 | Verify Redfishtool Error Upon Creating Same Users With Different Privileges |
| 67 | [Documentation] Verify error upon creating same users with different privileges. |
| 68 | [Tags] Verify_Redfishtool_Error_Upon_Creating_Same_Users_With_Different_Privileges |
| 69 | [Teardown] Redfishtool Delete User "UserT100" |
| 70 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 71 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 72 | Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true |
| 73 | ... expected_error=${HTTP_BAD_REQUEST} |
| 74 | |
| 75 | |
| 76 | Verify Redfishtool Admin User Privilege |
| 77 | [Documentation] Verify privilege of admin user. |
| 78 | [Tags] Verify_Redfishtool_Admin_User_Privilege |
| 79 | [Teardown] Run Keywords Redfishtool Delete User "UserT100" AND |
| 80 | ... Redfishtool Delete User "UserT101" |
| 81 | |
| 82 | Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true |
| 83 | |
Gene Ratzlaff | ba7e33e | 2022-05-21 08:51:45 -0400 | [diff] [blame] | 84 | # Verify if a user can be added by admin |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 85 | Redfishtool Create User "UserT101" "TestPwd123" "ReadOnly" true "UserT100" "TestPwd123" |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 86 | |
| 87 | |
| 88 | Verify Redfishtool ReadOnly User Privilege |
| 89 | [Documentation] Verify Redfishtool ReadOnly user privilege works. |
| 90 | [Tags] Verify_Redfishtool_ReadOnly_User_Privilege |
| 91 | [Teardown] Redfishtool Delete User "UserT100" |
| 92 | |
| 93 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
| 94 | Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123" |
| 95 | |
| 96 | Redfishtool Create User |
| 97 | ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN} |
| 98 | |
| 99 | |
manashsarma | 75e7983 | 2020-06-24 07:08:38 -0500 | [diff] [blame] | 100 | Verify Redfishtool Operator User Privilege |
| 101 | [Documentation] Verify that an operator user is able to perform operator privilege |
| 102 | ... task(e.g. create user, delete user). |
| 103 | [Tags] Verify_Redfishtool_Operator_User_Privilege |
| 104 | [Teardown] Redfishtool Delete User "UserT100" |
| 105 | |
| 106 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true |
| 107 | Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123" |
| 108 | |
| 109 | Redfishtool Create User |
| 110 | ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN} |
| 111 | |
| 112 | |
| 113 | Verify Error While Creating User With Invalid Role |
| 114 | [Documentation] Verify error while creating a user with invalid role using Redfishtool. |
| 115 | [Tags] Verify_Error_While_Creating_User_With_Invalid_Role |
manashsarma | 26103d9 | 2020-12-08 00:46:28 -0600 | [diff] [blame] | 116 | [Teardown] Redfishtool Delete User "UserT100" ${HTTP_NOT_FOUND} |
manashsarma | 75e7983 | 2020-06-24 07:08:38 -0500 | [diff] [blame] | 117 | |
| 118 | Redfishtool Create User "UserT100" "TestPwd123" "wrongroleid" true expected_error=${HTTP_BAD_REQUEST} |
| 119 | |
| 120 | |
| 121 | Verify Minimum Password Length For Redfish User |
| 122 | [Documentation] Verify minimum password length of eight characters for new and existing user. |
| 123 | [Tags] Verify_Minimum_Password_Length_For_Redfish_User |
| 124 | [Teardown] Redfishtool Delete User "UserT100" |
| 125 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 126 | Redfishtool Create User "UserT100" "TestPwd" "ReadOnly" true expected_error=${HTTP_BAD_REQUEST} |
| 127 | Redfishtool Create User "UserT100" "TestPwd1" "ReadOnly" true |
manashsarma | 75e7983 | 2020-06-24 07:08:38 -0500 | [diff] [blame] | 128 | |
| 129 | |
| 130 | Verify Create User Without Enabling |
Gene Ratzlaff | ba7e33e | 2022-05-21 08:51:45 -0400 | [diff] [blame] | 131 | [Documentation] Create a user without enabling it and verify that it does not have access. |
| 132 | [Tags] Verify_Create_User_Without_Enabling |
manashsarma | 75e7983 | 2020-06-24 07:08:38 -0500 | [diff] [blame] | 133 | [Teardown] Redfishtool Delete User "UserT100" |
| 134 | |
manashsarma | 841ac303 | 2022-08-24 01:28:22 -0500 | [diff] [blame] | 135 | Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" false |
manashsarma | 75e7983 | 2020-06-24 07:08:38 -0500 | [diff] [blame] | 136 | Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123" |
| 137 | ... ${HTTP_UNAUTHORIZED} |
| 138 | |
manashsarma | c0efe58 | 2020-06-15 09:51:48 -0500 | [diff] [blame] | 139 | |
| 140 | Verify Error While Running Redfishtool With Incorrect Password |
| 141 | [Documentation] Verify error while running redfishtool with incorrect Password. |
| 142 | [Tags] Verify_Error_While_Running_Redfishtool_With_Incorrect_Password |
| 143 | [Teardown] Redfishtool Delete User "UserT100" |
| 144 | |
| 145 | Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true |
| 146 | Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd234" ${HTTP_UNAUTHORIZED} |
| 147 | |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 148 | *** Keywords *** |
| 149 | |
| 150 | |
| 151 | Redfishtool Access Resource |
| 152 | [Documentation] Access resource. |
manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 153 | [Arguments] ${uri} ${login_user} ${login_pasword} ${expected_error}=200 |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 154 | |
| 155 | # Description of argument(s): |
| 156 | # uri URI for resource access. |
| 157 | # login_user The login user name used other than default root user. |
| 158 | # login_pasword The login password. |
| 159 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 160 | # authentication error, etc. ) |
| 161 | |
| 162 | ${user_cmd_args}= Set Variable |
| 163 | ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
| 164 | Redfishtool Get ${uri} ${user_cmd_args} ${expected_error} |
| 165 | |
| 166 | |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 167 | Redfishtool Create User |
| 168 | [Documentation] Create new user. |
Gene Ratzlaff | ba7e33e | 2022-05-21 08:51:45 -0400 | [diff] [blame] | 169 | [Arguments] ${user_name} ${password} ${roleId} ${enable} ${login_user}="" ${login_pasword}="" |
manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 170 | ... ${expected_error}=200 |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 171 | |
| 172 | # Description of argument(s): |
| 173 | # user_name The user name (e.g. "test", "robert", etc.). |
| 174 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
Gene Ratzlaff | ba7e33e | 2022-05-21 08:51:45 -0400 | [diff] [blame] | 175 | # roleId The role of user (e.g. "Administrator", "Operator", etc.). |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 176 | # enable Enabled attribute of (e.g. true or false). |
| 177 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 178 | # authentication error, etc. ) |
| 179 | |
| 180 | ${user_cmd_args}= Set Variable |
| 181 | ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
| 182 | ${data}= Set Variable |
| 183 | ... '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}' |
| 184 | Run Keyword If ${login_user} == "" |
| 185 | ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} ${expected_error} |
| 186 | ... ELSE |
| 187 | ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${user_cmd_args} ${expected_error} |
| 188 | |
| 189 | |
| 190 | Redfishtool Update User Role |
| 191 | [Documentation] Update user role. |
| 192 | [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}="" |
manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 193 | ... ${expected_error}=200 |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 194 | |
| 195 | # Description of argument(s): |
| 196 | # user_name The user name (e.g. "test", "robert", etc.). |
| 197 | # newRole The new role of user (e.g. "Administrator", "Operator", etc.). |
| 198 | # login_user The login user name used other than default root user. |
| 199 | # login_pasword The login password. |
| 200 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 201 | # authentication error, etc. ) |
| 202 | |
| 203 | ${user_cmd_args}= Set Variable |
| 204 | ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always |
| 205 | Run Keyword If ${login_user} == "" |
| 206 | ... Redfishtool Patch '{"RoleId":${newRole}}' |
| 207 | ... /redfish/v1/AccountService/Accounts/${user_name} ${root_cmd_args} ${expected_error} |
| 208 | ... ELSE |
| 209 | ... Redfishtool Patch '{"RoleId":${newRole}}' |
| 210 | ... /redfish/v1/AccountService/Accounts/${user_name} ${user_cmd_args} ${expected_error} |
| 211 | |
| 212 | |
| 213 | Redfishtool Delete User |
Gene Ratzlaff | ba7e33e | 2022-05-21 08:51:45 -0400 | [diff] [blame] | 214 | [Documentation] Delete a user. |
manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 215 | [Arguments] ${user_name} ${expected_error}=200 |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 216 | |
| 217 | # Description of argument(s): |
| 218 | # user_name The user name (e.g. "test", "robert", etc.). |
| 219 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 220 | # authentication error, etc. ). |
| 221 | |
| 222 | Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name} |
| 223 | ... ${root_cmd_args} ${expected_error} |
| 224 | |
| 225 | |
| 226 | Redfishtool Verify User |
| 227 | [Documentation] Verify role of the user. |
| 228 | [Arguments] ${user_name} ${role} |
| 229 | |
| 230 | # Description of argument(s): |
| 231 | # user_name The user name (e.g. "test", "robert", etc.). |
| 232 | # role The new role of user (e.g. "Administrator", "Operator", etc.). |
| 233 | |
| 234 | ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name} |
| 235 | ${json_obj}= Evaluate json.loads('''${user_account}''') json |
| 236 | Should Be equal "${json_obj["RoleId"]}" ${role} |
| 237 | |
| 238 | |
| 239 | Redfishtool Verify User Name Exists |
| 240 | [Documentation] Verify user name exists. |
| 241 | [Arguments] ${user_name} |
| 242 | |
| 243 | # Description of argument(s): |
| 244 | # user_name The user name (e.g. "test", "robert", etc.). |
| 245 | |
| 246 | ${status}= Run Keyword And Return Status redfishtool Get |
| 247 | ... /redfish/v1/AccountService/Accounts/${user_name} |
| 248 | |
| 249 | [return] ${status} |
| 250 | |
| 251 | |
manashsarma | 9ca0d37 | 2020-05-26 04:49:05 -0500 | [diff] [blame] | 252 | Suite Setup Execution |
| 253 | [Documentation] Do suite setup execution. |
| 254 | |
| 255 | ${tool_exist}= Run which redfishtool |
| 256 | Should Not Be Empty ${tool_exist} |