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