Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test Redfish user account. |
| 3 | |
| 4 | Resource ../../lib/resource.robot |
| 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 7 | Resource ../../lib/bmc_redfish_utils.robot |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 8 | |
manashsarma | 654cbc1 | 2021-09-23 02:28:12 -0500 | [diff] [blame] | 9 | Library SSHLibrary |
| 10 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 11 | Test Setup Redfish.Login |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 12 | Test Teardown Test Teardown Execution |
| 13 | |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 14 | *** Variables *** |
| 15 | |
| 16 | ${account_lockout_duration} ${30} |
| 17 | ${account_lockout_threshold} ${3} |
George Keishing | f8e1819 | 2023-07-05 14:26:27 +0530 | [diff] [blame] | 18 | ${ssh_status} ${True} |
| 19 | |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 20 | ** Test Cases ** |
| 21 | |
| 22 | Verify AccountService Available |
Sivas SRR | fa6831c | 2019-02-22 00:12:00 -0600 | [diff] [blame] | 23 | [Documentation] Verify Redfish account service is available. |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 24 | [Tags] Verify_AccountService_Available |
| 25 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 26 | ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 27 | Should Be Equal As Strings ${resp} ${True} |
| 28 | |
Rahul Maheshwari | d0aa72b | 2022-08-23 06:44:07 -0500 | [diff] [blame] | 29 | |
| 30 | Verify Redfish Admin User Persistence After Reboot |
| 31 | [Documentation] Verify Redfish admin user persistence after reboot. |
| 32 | [Tags] Verify_Redfish_Admin_User_Persistence_After_Reboot |
| 33 | [Setup] Run Keywords Redfish.Login AND |
| 34 | ... Redfish Create User admin_user TestPwd123 Administrator ${True} |
| 35 | [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user |
| 36 | ... AND Test Teardown Execution |
Sandhya Somashekar | a83fb47 | 2019-08-29 02:26:21 -0500 | [diff] [blame] | 37 | |
| 38 | # Reboot BMC. |
| 39 | Redfish OBMC Reboot (off) stack_mode=normal |
Sandhya Somashekar | a83fb47 | 2019-08-29 02:26:21 -0500 | [diff] [blame] | 40 | |
| 41 | # Verify users after reboot. |
| 42 | Redfish Verify User admin_user TestPwd123 Administrator ${True} |
Rahul Maheshwari | d0aa72b | 2022-08-23 06:44:07 -0500 | [diff] [blame] | 43 | |
| 44 | |
| 45 | Verify Redfish Operator User Persistence After Reboot |
| 46 | [Documentation] Verify Redfish operator user persistence after reboot. |
| 47 | [Tags] Verify_Redfish_Operator_User_Persistence_After_Reboot |
| 48 | [Setup] Run Keywords Redfish.Login AND |
| 49 | ... Redfish Create User operator_user TestPwd123 Operator ${True} |
| 50 | [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user |
| 51 | ... AND Test Teardown Execution |
| 52 | |
| 53 | # Reboot BMC. |
| 54 | Redfish OBMC Reboot (off) stack_mode=normal |
| 55 | |
| 56 | # Verify users after reboot. |
Sandhya Somashekar | a83fb47 | 2019-08-29 02:26:21 -0500 | [diff] [blame] | 57 | Redfish Verify User operator_user TestPwd123 Operator ${True} |
Rahul Maheshwari | d0aa72b | 2022-08-23 06:44:07 -0500 | [diff] [blame] | 58 | |
| 59 | |
| 60 | Verify Redfish Readonly User Persistence After Reboot |
| 61 | [Documentation] Verify Redfish readonly user persistence after reboot. |
| 62 | [Tags] Verify_Redfish_Readonly_User_Persistence_After_Reboot |
| 63 | [Setup] Run Keywords Redfish.Login AND |
| 64 | ... Redfish Create User readonly_user TestPwd123 ReadOnly ${True} |
| 65 | [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user |
| 66 | ... AND Test Teardown Execution |
| 67 | |
| 68 | # Reboot BMC. |
| 69 | Redfish OBMC Reboot (off) stack_mode=normal |
| 70 | |
| 71 | # Verify users after reboot. |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 72 | Redfish Verify User readonly_user TestPwd123 ReadOnly ${True} |
Sandhya Somashekar | a83fb47 | 2019-08-29 02:26:21 -0500 | [diff] [blame] | 73 | |
Sandhya Somashekar | a83fb47 | 2019-08-29 02:26:21 -0500 | [diff] [blame] | 74 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 75 | Redfish Create and Verify Admin User |
| 76 | [Documentation] Create a Redfish user with administrator role and verify. |
George Keishing | f517690 | 2022-05-12 04:23:59 -0500 | [diff] [blame] | 77 | [Tags] Redfish_Create_and_Verify_Admin_User |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 78 | [Template] Redfish Create And Verify User |
| 79 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 80 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 81 | admin_user TestPwd123 Administrator ${True} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 82 | |
| 83 | |
| 84 | Redfish Create and Verify Operator User |
| 85 | [Documentation] Create a Redfish user with operator role and verify. |
| 86 | [Tags] Redfish_Create_and_Verify_Operator_User |
| 87 | [Template] Redfish Create And Verify User |
| 88 | |
| 89 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 90 | operator_user TestPwd123 Operator ${True} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 91 | |
| 92 | |
| 93 | Redfish Create and Verify Readonly User |
| 94 | [Documentation] Create a Redfish user with readonly role and verify. |
| 95 | [Tags] Redfish_Create_and_Verify_Readonly_User |
| 96 | [Template] Redfish Create And Verify User |
| 97 | |
| 98 | #username password role_id enabled |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 99 | readonly_user TestPwd123 ReadOnly ${True} |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 100 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 101 | |
| 102 | Verify Redfish Admin User With Wrong Password |
| 103 | [Documentation] Verify Redfish admin user with wrong password. |
| 104 | [Tags] Verify_Redfish_Admin_User_With_Wrong_Password |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 105 | [Template] Verify Redfish User with Wrong Password |
| 106 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 107 | #username password role_id enabled wrong_password |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 108 | admin_user TestPwd123 Administrator ${True} alskjhfwurh |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 109 | |
| 110 | |
| 111 | Verify Redfish Operator User with Wrong Password |
| 112 | [Documentation] Verify Redfish operator user with wrong password. |
| 113 | [Tags] Verify_Redfish_Operator_User_with_Wrong_Password |
| 114 | [Template] Verify Redfish User with Wrong Password |
| 115 | |
| 116 | #username password role_id enabled wrong_password |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 117 | operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024 |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 118 | |
| 119 | |
| 120 | Verify Redfish Readonly User With Wrong Password |
| 121 | [Documentation] Verify Redfish readonly user with wrong password. |
| 122 | [Tags] Verify_Redfish_Readonly_User_With_Wrong_Password |
| 123 | [Template] Verify Redfish User with Wrong Password |
| 124 | |
| 125 | #username password role_id enabled wrong_password |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 126 | readonly_user TestPwd123 ReadOnly ${True} 12 |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 127 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 128 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 129 | Verify Login with Deleted Redfish Admin User |
| 130 | [Documentation] Verify login with deleted Redfish admin user. |
| 131 | [Tags] Verify_Login_with_Deleted_Redfish_Admin_User |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 132 | [Template] Verify Login with Deleted Redfish User |
| 133 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 134 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 135 | admin_user TestPwd123 Administrator ${True} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 136 | |
| 137 | |
| 138 | Verify Login with Deleted Redfish Operator User |
| 139 | [Documentation] Verify login with deleted Redfish operator user. |
| 140 | [Tags] Verify_Login_with_Deleted_Redfish_Operator_User |
| 141 | [Template] Verify Login with Deleted Redfish User |
| 142 | |
| 143 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 144 | operator_user TestPwd123 Operator ${True} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 145 | |
| 146 | |
| 147 | Verify Login with Deleted Redfish Readonly User |
| 148 | [Documentation] Verify login with deleted Redfish readonly user. |
| 149 | [Tags] Verify_Login_with_Deleted_Redfish_Readonly_User |
| 150 | [Template] Verify Login with Deleted Redfish User |
| 151 | |
| 152 | #username password role_id enabled |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 153 | readonly_user TestPwd123 ReadOnly ${True} |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 154 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 155 | |
| 156 | Verify Admin User Creation Without Enabling It |
| 157 | [Documentation] Verify admin user creation without enabling it. |
| 158 | [Tags] Verify_Admin_User_Creation_Without_Enabling_It |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 159 | [Template] Verify Create User Without Enabling |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 160 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 161 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 162 | admin_user TestPwd123 Administrator ${False} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 163 | |
| 164 | |
| 165 | Verify Operator User Creation Without Enabling It |
| 166 | [Documentation] Verify operator user creation without enabling it. |
| 167 | [Tags] Verify_Operator_User_Creation_Without_Enabling_It |
| 168 | [Template] Verify Create User Without Enabling |
| 169 | |
| 170 | #username password role_id enabled |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 171 | operator_user TestPwd123 Operator ${False} |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 172 | |
| 173 | |
| 174 | Verify Readonly User Creation Without Enabling It |
| 175 | [Documentation] Verify readonly user creation without enabling it. |
| 176 | [Tags] Verify_Readonly_User_Creation_Without_Enabling_It |
| 177 | [Template] Verify Create User Without Enabling |
| 178 | |
| 179 | #username password role_id enabled |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 180 | readonly_user TestPwd123 ReadOnly ${False} |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 181 | |
Rahul Maheshwari | cbc4c0b | 2022-04-25 05:29:25 -0500 | [diff] [blame] | 182 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 183 | Verify User Creation With Invalid Role Id |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 184 | [Documentation] Verify user creation with invalid role ID. |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 185 | [Tags] Verify_User_Creation_With_Invalid_Role_Id |
| 186 | |
| 187 | # Make sure the user account in question does not already exist. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 188 | Redfish.Delete /redfish/v1/AccountService/Accounts/test_user |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 189 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 190 | |
| 191 | # Create specified user. |
| 192 | ${payload}= Create Dictionary |
| 193 | ... UserName=test_user Password=TestPwd123 RoleId=wrongroleid Enabled=${True} |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 194 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 195 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 196 | |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 197 | Verify Error Upon Creating Same Users With Different Privileges |
| 198 | [Documentation] Verify error upon creating same users with different privileges. |
| 199 | [Tags] Verify_Error_Upon_Creating_Same_Users_With_Different_Privileges |
| 200 | |
| 201 | Redfish Create User test_user TestPwd123 Administrator ${True} |
| 202 | |
| 203 | # Create specified user. |
| 204 | ${payload}= Create Dictionary |
Nandish-Matti | 232a6f0 | 2023-04-07 05:54:32 -0500 | [diff] [blame] | 205 | ... UserName=test_user Password=TestPwd123 RoleId=ReadOnly Enabled=${True} |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 206 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 207 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 208 | |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 209 | Redfish.Delete /redfish/v1/AccountService/Accounts/test_user |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 210 | |
Rahul Maheshwari | 124ebef | 2022-08-23 12:06:59 -0500 | [diff] [blame] | 211 | |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 212 | Verify Modifying User Attributes |
| 213 | [Documentation] Verify modifying user attributes. |
| 214 | [Tags] Verify_Modifying_User_Attributes |
Rahul Maheshwari | 124ebef | 2022-08-23 12:06:59 -0500 | [diff] [blame] | 215 | |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 216 | # Create Redfish users. |
| 217 | Redfish Create User admin_user TestPwd123 Administrator ${True} |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 218 | Redfish Create User readonly_user TestPwd123 ReadOnly ${True} |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 219 | |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 220 | # Make sure the new user account does not already exist. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 221 | Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 222 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 223 | |
| 224 | # Update admin_user username using Redfish. |
| 225 | ${payload}= Create Dictionary UserName=newadmin_user |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 226 | Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body=&{payload} |
George Keishing | 3f2902e | 2025-03-14 08:19:02 +0530 | [diff] [blame] | 227 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 228 | |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 229 | # Update readonly_user role using Redfish. |
Rahul Maheshwari | 124ebef | 2022-08-23 12:06:59 -0500 | [diff] [blame] | 230 | ${payload}= Create Dictionary RoleId=Administrator |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 231 | Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body=&{payload} |
George Keishing | 3f2902e | 2025-03-14 08:19:02 +0530 | [diff] [blame] | 232 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 233 | |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 234 | # Verify users after updating |
| 235 | Redfish Verify User newadmin_user TestPwd123 Administrator ${True} |
Rahul Maheshwari | 124ebef | 2022-08-23 12:06:59 -0500 | [diff] [blame] | 236 | Redfish Verify User readonly_user TestPwd123 Administrator ${True} |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 237 | |
| 238 | # Delete created users. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 239 | Redfish.Delete /redfish/v1/AccountService/Accounts/newadmin_user |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 240 | Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 241 | |
Rahul Maheshwari | 124ebef | 2022-08-23 12:06:59 -0500 | [diff] [blame] | 242 | |
| 243 | Verify Modifying Operator User Attributes |
| 244 | [Documentation] Verify modifying operator user attributes. |
| 245 | [Tags] Verify_Modifying_Operator_User_Attributes |
| 246 | [Setup] Run Keywords Redfish.Login AND |
| 247 | ... Redfish Create User operator_user TestPwd123 Operator ${True} |
| 248 | [Teardown] Run Keywords Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user |
| 249 | ... AND Test Teardown Execution |
| 250 | |
| 251 | # Update operator_user password using Redfish. |
| 252 | ${payload}= Create Dictionary Password=NewTestPwd123 |
| 253 | Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body=&{payload} |
| 254 | |
| 255 | # Verify users after updating |
| 256 | Redfish Verify User operator_user NewTestPwd123 Operator ${True} |
| 257 | |
| 258 | |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 259 | Verify User Account Locked |
| 260 | [Documentation] Verify user account locked upon trying with invalid password. |
| 261 | [Tags] Verify_User_Account_Locked |
| 262 | |
| 263 | Redfish Create User admin_user TestPwd123 Administrator ${True} |
| 264 | |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 265 | ${payload}= Create Dictionary AccountLockoutThreshold=${account_lockout_threshold} |
| 266 | ... AccountLockoutDuration=${account_lockout_duration} |
| 267 | Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload} |
George Keishing | 1f8db9c | 2025-04-01 21:37:44 +0530 | [diff] [blame] | 268 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 269 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 270 | Redfish.Logout |
| 271 | |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 272 | # Make ${account_lockout_threshold} failed login attempts. |
| 273 | Repeat Keyword ${account_lockout_threshold} times |
Vidya-Kalasappanavar | 4831f59 | 2025-04-21 04:17:21 -0500 | [diff] [blame] | 274 | ... Run Keyword And Expect Error *InvalidCredentialsError* Redfish.Login admin_user abcd1234 |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 275 | |
| 276 | # Verify that legitimate login fails due to lockout. |
Vidya-Kalasappanavar | 4831f59 | 2025-04-21 04:17:21 -0500 | [diff] [blame] | 277 | Run Keyword And Expect Error *InvalidCredentialsError* |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 278 | ... Redfish.Login admin_user TestPwd123 |
| 279 | |
Vidya-Kalasappanavar | 344c21d | 2025-07-01 12:21:05 -0500 | [diff] [blame^] | 280 | # Wait for lockout duration to expire and adding 5 sec delay to the account lock timeout |
| 281 | # ... then verify that login works. |
| 282 | ${total_wait_duartion}= Evaluate ${account_lockout_duration} + 5 |
| 283 | Sleep ${total_wait_duartion}s |
| 284 | |
Sandhya Somashekar | 37122b6 | 2019-06-18 06:02:02 -0500 | [diff] [blame] | 285 | Redfish.Login admin_user TestPwd123 |
| 286 | |
| 287 | Redfish.Logout |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 288 | |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 289 | Redfish.Login |
| 290 | |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 291 | Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 292 | |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 293 | |
| 294 | Verify User Account Unlock |
| 295 | [Documentation] Verify manually unlocking the account before lockout time |
| 296 | [Tags] Verify_User_Account_Unlock |
George Keishing | a36926b | 2023-05-17 21:54:34 +0530 | [diff] [blame] | 297 | [Teardown] Run Keywords Redfish.Logout |
| 298 | ... AND Redfish.Login |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 299 | ... AND Redfish.Delete /redfish/v1/AccountService/Accounts/test_user |
| 300 | ... AND SSHLibrary.Close All Connections |
| 301 | |
| 302 | Redfish Create User test_user TestPwd123 Administrator ${True} |
| 303 | |
| 304 | ${payload}= Create Dictionary |
| 305 | ... AccountLockoutThreshold=${account_lockout_threshold} |
| 306 | ... AccountLockoutDuration=${account_lockout_duration} |
| 307 | Redfish.Patch ${REDFISH_ACCOUNTS_SERVICE_URI} body=${payload} |
| 308 | |
| 309 | Redfish.Logout |
| 310 | |
| 311 | # Make ${account_lockout_threshold} failed login attempts. |
| 312 | Repeat Keyword ${account_lockout_threshold} times |
| 313 | ... Run Keyword And Expect Error InvalidCredentialsError* |
| 314 | ... Redfish.Login test_user abc123 |
| 315 | |
| 316 | # Ensure SSH Login with locked account gets failed |
| 317 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 318 | Run Keyword And Expect Error Authentication failed* |
| 319 | ... SSHLibrary.Login test_user TestPwd123 |
| 320 | |
| 321 | # Verify that legitimate login fails due to lockout. |
| 322 | Run Keyword And Expect Error InvalidCredentialsError* |
| 323 | ... Redfish.Login test_user TestPwd123 |
| 324 | |
| 325 | ${payload}= Create Dictionary Locked=${FALSE} |
| 326 | |
| 327 | # Manually unlock the account before lockout threshold expires |
| 328 | Redfish.Login |
| 329 | Redfish.Patch ${REDFISH_ACCOUNTS_URI}test_user body=${payload} |
| 330 | Redfish.Logout |
| 331 | |
| 332 | # Try redfish login with the recently unlocked account |
| 333 | Redfish.Login test_user TestPwd123 |
| 334 | |
| 335 | # Try SSH login with the unlocked account |
| 336 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 337 | SSHLibrary.Login test_user TestPwd123 |
| 338 | |
| 339 | |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 340 | Verify Admin User Privilege |
| 341 | [Documentation] Verify admin user privilege. |
| 342 | [Tags] Verify_Admin_User_Privilege |
| 343 | |
| 344 | Redfish Create User admin_user TestPwd123 Administrator ${True} |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 345 | Redfish Create User readonly_user TestPwd123 ReadOnly ${True} |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 346 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 347 | Redfish.Logout |
| 348 | |
Rahul Maheshwari | 3bc0864 | 2022-08-23 12:49:48 -0500 | [diff] [blame] | 349 | Redfish.Login admin_user TestPwd123 |
| 350 | |
| 351 | # Change password of 'readonly' user with admin user. |
| 352 | Redfish.Patch /redfish/v1/AccountService/Accounts/readonly_user body={'Password': 'NewTestPwd123'} |
| 353 | |
| 354 | # Verify modified user. |
| 355 | Redfish Verify User readonly_user NewTestPwd123 ReadOnly ${True} |
| 356 | |
| 357 | # Note: Delete user would work here because a root login is |
| 358 | # performed as part of "Redfish Verify User" keyword's teardown. |
| 359 | Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user |
| 360 | Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user |
| 361 | |
| 362 | |
| 363 | Verify Operator User Role Change Using Admin Privilege User |
| 364 | [Documentation] Verify operator user role change using admin privilege user |
| 365 | [Tags] Verify_Operator_User_Role_Change_Using_Admin_Privilege_User |
| 366 | |
| 367 | Redfish Create User admin_user TestPwd123 Administrator ${True} |
| 368 | Redfish Create User operator_user TestPwd123 Operator ${True} |
| 369 | |
| 370 | Redfish.Logout |
| 371 | |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 372 | # Change role ID of operator user with admin user. |
| 373 | # Login with admin user. |
| 374 | Redfish.Login admin_user TestPwd123 |
| 375 | |
| 376 | # Modify Role ID of Operator user. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 377 | Redfish.Patch /redfish/v1/AccountService/Accounts/operator_user body={'RoleId': 'Administrator'} |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 378 | |
| 379 | # Verify modified user. |
| 380 | Redfish Verify User operator_user TestPwd123 Administrator ${True} |
| 381 | |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 382 | Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user |
| 383 | Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user |
Rahul Maheshwari | 3bc0864 | 2022-08-23 12:49:48 -0500 | [diff] [blame] | 384 | |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 385 | |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 386 | Verify Operator User Privilege |
| 387 | [Documentation] Verify operator user privilege. |
George Keishing | 5236ec5 | 2022-01-31 12:07:58 -0600 | [diff] [blame] | 388 | [Tags] Verify_Operator_User_Privilege |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 389 | |
| 390 | Redfish Create User admin_user TestPwd123 Administrator ${True} |
| 391 | Redfish Create User operator_user TestPwd123 Operator ${True} |
| 392 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 393 | Redfish.Logout |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 394 | # Login with operator user. |
| 395 | Redfish.Login operator_user TestPwd123 |
| 396 | |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 397 | # Verify BMC reset. |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 398 | Run Keyword And Expect Error ValueError* Redfish BMC Reset Operation |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 399 | |
| 400 | # Attempt to change password of admin user with operator user. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 401 | Redfish.Patch /redfish/v1/AccountService/Accounts/admin_user body={'Password': 'NewTestPwd123'} |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 402 | ... valid_status_codes=[${HTTP_FORBIDDEN}] |
| 403 | |
| 404 | Redfish.Logout |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 405 | |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 406 | Redfish.Login |
| 407 | |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 408 | Redfish.Delete /redfish/v1/AccountService/Accounts/admin_user |
| 409 | Redfish.Delete /redfish/v1/AccountService/Accounts/operator_user |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 410 | |
| 411 | |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 412 | Verify ReadOnly User Privilege |
| 413 | [Documentation] Verify ReadOnly user privilege. |
| 414 | [Tags] Verify_ReadOnly_User_Privilege |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 415 | |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 416 | Redfish Create User readonly_user TestPwd123 ReadOnly ${True} |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 417 | Redfish.Logout |
| 418 | |
| 419 | # Login with read_only user. |
| 420 | Redfish.Login readonly_user TestPwd123 |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 421 | |
| 422 | # Read system level data. |
| 423 | ${system_model}= Redfish_Utils.Get Attribute |
| 424 | ... ${SYSTEM_BASE_URI} Model |
| 425 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 426 | Redfish.Logout |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 427 | Redfish.Login |
Anusha Dathatri | 4062b44 | 2020-02-03 04:39:15 -0600 | [diff] [blame] | 428 | Redfish.Delete ${REDFISH_ACCOUNTS_URI}readonly_user |
Sandhya Somashekar | 7a23747 | 2019-07-15 02:06:39 -0500 | [diff] [blame] | 429 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 430 | |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 431 | Verify Minimum Password Length For Redfish User |
| 432 | [Documentation] Verify minimum password length for new and existing user. |
| 433 | [Tags] Verify_Minimum_Password_Length_For_Redfish_User |
| 434 | |
| 435 | ${user_name}= Set Variable testUser |
| 436 | |
| 437 | # Make sure the user account in question does not already exist. |
| 438 | Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name} |
| 439 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 440 | |
| 441 | # Try to create a user with invalid length password. |
| 442 | ${payload}= Create Dictionary |
| 443 | ... UserName=${user_name} Password=UserPwd RoleId=Administrator Enabled=${True} |
| 444 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
| 445 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 446 | |
| 447 | # Create specified user with valid length password. |
| 448 | Set To Dictionary ${payload} Password UserPwd1 |
| 449 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
| 450 | ... valid_status_codes=[${HTTP_CREATED}] |
| 451 | |
| 452 | # Try to change to an invalid password. |
| 453 | Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd'} |
| 454 | ... valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 455 | |
| 456 | # Change to a valid password. |
| 457 | Redfish.Patch /redfish/v1/AccountService/Accounts/${user_name} body={'Password': 'UserPwd1'} |
| 458 | |
| 459 | # Verify login. |
| 460 | Redfish.Logout |
| 461 | Redfish.Login ${user_name} UserPwd1 |
| 462 | Redfish.Logout |
| 463 | Redfish.Login |
| 464 | Redfish.Delete /redfish/v1/AccountService/Accounts/${user_name} |
| 465 | |
| 466 | |
Tony Lee | 94335f4 | 2021-02-04 15:16:39 +0800 | [diff] [blame] | 467 | Verify Standard User Roles Defined By Redfish |
| 468 | [Documentation] Verify standard user roles defined by Redfish. |
| 469 | [Tags] Verify_Standard_User_Roles_Defined_By_Redfish |
| 470 | |
| 471 | ${member_list}= Redfish_Utils.Get Member List |
| 472 | ... /redfish/v1/AccountService/Roles |
| 473 | |
| 474 | @{roles}= Create List |
| 475 | ... /redfish/v1/AccountService/Roles/Administrator |
| 476 | ... /redfish/v1/AccountService/Roles/Operator |
| 477 | ... /redfish/v1/AccountService/Roles/ReadOnly |
| 478 | |
| 479 | List Should Contain Sub List ${member_list} ${roles} |
| 480 | |
| 481 | # The standard roles are: |
| 482 | |
| 483 | # | Role name | Assigned privileges | |
| 484 | # | Administrator | Login, ConfigureManager, ConfigureUsers, ConfigureComponents, ConfigureSelf | |
| 485 | # | Operator | Login, ConfigureComponents, ConfigureSelf | |
| 486 | # | ReadOnly | Login, ConfigureSelf | |
| 487 | |
| 488 | @{admin}= Create List Login ConfigureManager ConfigureUsers ConfigureComponents ConfigureSelf |
| 489 | @{operator}= Create List Login ConfigureComponents ConfigureSelf |
| 490 | @{readOnly}= Create List Login ConfigureSelf |
| 491 | |
| 492 | ${roles_dict}= create dictionary admin_privileges=${admin} operator_privileges=${operator} |
| 493 | ... readOnly_privileges=${readOnly} |
| 494 | |
| 495 | ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Administrator |
| 496 | List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['admin_privileges']} |
| 497 | |
| 498 | ${resp}= redfish.Get /redfish/v1/AccountService/Roles/Operator |
| 499 | List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['operator_privileges']} |
| 500 | |
| 501 | ${resp}= redfish.Get /redfish/v1/AccountService/Roles/ReadOnly |
| 502 | List Should Contain Sub List ${resp.dict['AssignedPrivileges']} ${roles_dict['readOnly_privileges']} |
| 503 | |
| 504 | |
manashsarma | 4910aa2 | 2021-07-26 09:12:36 -0500 | [diff] [blame] | 505 | Verify Error While Deleting Root User |
| 506 | [Documentation] Verify error while deleting root user. |
| 507 | [Tags] Verify_Error_While_Deleting_Root_User |
| 508 | |
| 509 | Redfish.Delete /redfish/v1/AccountService/Accounts/root valid_status_codes=[${HTTP_FORBIDDEN}] |
| 510 | |
| 511 | |
manashsarma | 654cbc1 | 2021-09-23 02:28:12 -0500 | [diff] [blame] | 512 | Verify SSH Login Access With Admin User |
George Keishing | f8e1819 | 2023-07-05 14:26:27 +0530 | [diff] [blame] | 513 | [Documentation] Verify that admin user have SSH login access. |
| 514 | ... By default, admin should have access but there could be |
| 515 | ... case where admin user shell access is restricted by design |
| 516 | ... in the community sphere.. |
manashsarma | 654cbc1 | 2021-09-23 02:28:12 -0500 | [diff] [blame] | 517 | [Tags] Verify_SSH_Login_Access_With_Admin_User |
| 518 | |
| 519 | # Create an admin User. |
| 520 | Redfish Create User new_admin TestPwd1 Administrator ${True} |
| 521 | |
| 522 | # Attempt SSH login with admin user. |
| 523 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 524 | ${status}= Run Keyword And Return Status SSHLibrary.Login new_admin TestPwd1 |
George Keishing | f8e1819 | 2023-07-05 14:26:27 +0530 | [diff] [blame] | 525 | |
| 526 | # By default ssh_status is True, user can change the status via CLI |
| 527 | # -v ssh_status:False |
| 528 | Should Be Equal As Strings "${status}" "${ssh_status}" |
manashsarma | 654cbc1 | 2021-09-23 02:28:12 -0500 | [diff] [blame] | 529 | |
George Keishing | e8015b3 | 2022-09-19 09:38:47 -0500 | [diff] [blame] | 530 | Redfish.Login |
| 531 | Redfish.Delete /redfish/v1/AccountService/Accounts/new_admin |
| 532 | |
manashsarma | 654cbc1 | 2021-09-23 02:28:12 -0500 | [diff] [blame] | 533 | |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 534 | Verify Configure BasicAuth Enable And Disable |
| 535 | [Documentation] Verify configure basicauth enable and disable |
| 536 | [Tags] Verify_Configure_BasicAuth_Enable_And_Disable |
| 537 | [Template] Template For Configure Auth Methods |
| 538 | |
| 539 | # auth_method |
| 540 | BasicAuth |
| 541 | XToken |
| 542 | |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 543 | *** Keywords *** |
| 544 | |
Sivas SRR | 6aa101f | 2019-02-19 22:31:55 -0600 | [diff] [blame] | 545 | Test Teardown Execution |
| 546 | [Documentation] Do the post test teardown. |
| 547 | |
Anusha Dathatri | db76970 | 2020-02-12 01:02:30 -0600 | [diff] [blame] | 548 | Run Keyword And Ignore Error Redfish.Logout |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 549 | FFDC On Test Case Fail |
| 550 | |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 551 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 552 | Redfish Create User |
| 553 | [Documentation] Redfish create user. |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 554 | [Arguments] ${username} ${password} ${role_id} ${enabled} ${login_check}=${True} |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 555 | |
| 556 | # Description of argument(s): |
| 557 | # username The username to be created. |
| 558 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 559 | # role_id The role ID of the user to be created |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 560 | # (e.g. "Administrator", "Operator", etc.). |
| 561 | # enabled Indicates whether the username being created |
| 562 | # should be enabled (${True}, ${False}). |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 563 | # login_check Checks user login for created user. |
| 564 | # (e.g. ${True}, ${False}). |
Sandhya Somashekar | 8c5b249 | 2019-05-16 05:19:03 -0500 | [diff] [blame] | 565 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 566 | # Make sure the user account in question does not already exist. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 567 | Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 568 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 569 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 570 | # Create specified user. |
| 571 | ${payload}= Create Dictionary |
| 572 | ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled} |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 573 | Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{payload} |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 574 | ... valid_status_codes=[${HTTP_CREATED}] |
| 575 | |
Rahul Maheshwari | 9928b1d | 2021-07-19 04:59:55 -0500 | [diff] [blame] | 576 | # Resetting faillock count as a workaround for issue |
Anusha Dathatri | f7268b5 | 2020-02-19 01:03:49 -0600 | [diff] [blame] | 577 | # openbmc/phosphor-user-manager#4 |
Rahul Maheshwari | 638a598 | 2024-04-19 07:35:15 -0500 | [diff] [blame] | 578 | ${cmd}= Catenate /usr/sbin/faillock --user ${username} --reset |
Alagiridhilipank | b9c9377 | 2024-04-02 10:04:27 +0000 | [diff] [blame] | 579 | |
Anusha Dathatri | f7268b5 | 2020-02-19 01:03:49 -0600 | [diff] [blame] | 580 | Bmc Execute Command ${cmd} |
| 581 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 582 | # Verify login with created user. |
George Keishing | 79fc7f0 | 2025-05-02 00:37:49 +0530 | [diff] [blame] | 583 | IF '${login_check}' == '${True}' |
| 584 | ${status}= Run Keyword And Return Status |
| 585 | ... Verify Redfish User Login ${username} ${password} |
| 586 | ELSE |
| 587 | ${status}= Set Variable ${False} |
| 588 | END |
| 589 | |
| 590 | IF '${login_check}' == '${True}' Should Be Equal ${status} ${enabled} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 591 | |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 592 | # Validate Role ID of created user. |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 593 | ${role_config}= Redfish_Utils.Get Attribute |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 594 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 595 | Should Be Equal ${role_id} ${role_config} |
| 596 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 597 | |
| 598 | Redfish Verify User |
| 599 | [Documentation] Redfish user verification. |
| 600 | [Arguments] ${username} ${password} ${role_id} ${enabled} |
| 601 | |
| 602 | # Description of argument(s): |
| 603 | # username The username to be created. |
| 604 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 605 | # role_id The role ID of the user to be created |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 606 | # (e.g. "Administrator", "Operator", etc.). |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 607 | # enabled Indicates whether the username being created |
| 608 | # should be enabled (${True}, ${False}). |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 609 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 610 | ${status}= Verify Redfish User Login ${username} ${password} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 611 | # Doing a check of the returned status. |
| 612 | Should Be Equal ${status} ${enabled} |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 613 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 614 | # Validate Role Id of user. |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 615 | ${role_config}= Redfish_Utils.Get Attribute |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 616 | ... /redfish/v1/AccountService/Accounts/${username} RoleId |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 617 | Should Be Equal ${role_id} ${role_config} |
| 618 | |
| 619 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 620 | Verify Redfish User Login |
| 621 | [Documentation] Verify Redfish login with given user id. |
| 622 | [Teardown] Run Keywords Run Keyword And Ignore Error Redfish.Logout AND Redfish.Login |
| 623 | [Arguments] ${username} ${password} |
| 624 | |
| 625 | # Description of argument(s): |
| 626 | # username Login username. |
| 627 | # password Login password. |
| 628 | |
| 629 | # Logout from current Redfish session. |
George Keishing | 1cf2a42 | 2021-02-02 22:59:29 -0600 | [diff] [blame] | 630 | # We don't really care if the current session is flushed out since we are going to login |
| 631 | # with new credential in next. |
| 632 | Run Keyword And Ignore Error Redfish.Logout |
| 633 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 634 | ${status}= Run Keyword And Return Status Redfish.Login ${username} ${password} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 635 | RETURN ${status} |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 636 | |
| 637 | |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 638 | Redfish Create And Verify User |
| 639 | [Documentation] Redfish create and verify user. |
| 640 | [Arguments] ${username} ${password} ${role_id} ${enabled} |
| 641 | |
| 642 | # Description of argument(s): |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 643 | # username The username to be created. |
| 644 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 645 | # role_id The role ID of the user to be created |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 646 | # (e.g. "Administrator", "Operator", etc.). |
| 647 | # enabled Indicates whether the username being created |
| 648 | # should be enabled (${True}, ${False}). |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 649 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 650 | # Example: |
| 651 | #{ |
| 652 | #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount", |
| 653 | #"@odata.id": "/redfish/v1/AccountService/Accounts/test1", |
| 654 | #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount", |
| 655 | #"Description": "User Account", |
| 656 | #"Enabled": true, |
| 657 | #"Id": "test1", |
| 658 | #"Links": { |
| 659 | # "Role": { |
| 660 | # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator" |
| 661 | # } |
| 662 | #}, |
| 663 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 664 | Redfish Create User ${username} ${password} ${role_id} ${enabled} |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 665 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 666 | Redfish Verify User ${username} ${password} ${role_id} ${enabled} |
Sandhya Somashekar | 00f59cc | 2019-03-05 03:39:47 -0600 | [diff] [blame] | 667 | |
| 668 | # Delete Specified User |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 669 | Redfish.Delete /redfish/v1/AccountService/Accounts/${username} |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 670 | |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 671 | Verify Redfish User with Wrong Password |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 672 | [Documentation] Verify Redfish User with Wrong Password. |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 673 | [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password} |
| 674 | |
| 675 | # Description of argument(s): |
| 676 | # username The username to be created. |
| 677 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 678 | # role_id The role ID of the user to be created |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 679 | # (e.g. "Administrator", "Operator", etc.). |
| 680 | # enabled Indicates whether the username being created |
| 681 | # should be enabled (${True}, ${False}). |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 682 | # wrong_password Any invalid password. |
| 683 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 684 | Redfish Create User ${username} ${password} ${role_id} ${enabled} |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 685 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 686 | Redfish.Logout |
| 687 | |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 688 | # Attempt to login with created user with invalid password. |
| 689 | Run Keyword And Expect Error InvalidCredentialsError* |
| 690 | ... Redfish.Login ${username} ${wrong_password} |
| 691 | |
| 692 | Redfish.Login |
| 693 | |
| 694 | # Delete newly created user. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 695 | Redfish.Delete /redfish/v1/AccountService/Accounts/${username} |
Sandhya Somashekar | 33aa48c | 2019-03-13 05:54:49 -0500 | [diff] [blame] | 696 | |
| 697 | |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 698 | Verify Login with Deleted Redfish User |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 699 | [Documentation] Verify Login with Deleted Redfish User. |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 700 | [Arguments] ${username} ${password} ${role_id} ${enabled} |
| 701 | |
| 702 | # Description of argument(s): |
| 703 | # username The username to be created. |
| 704 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 705 | # role_id The role ID of the user to be created |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 706 | # (e.g. "Administrator", "Operator", etc.). |
| 707 | # enabled Indicates whether the username being created |
| 708 | # should be enabled (${True}, ${False}). |
| 709 | |
Sandhya Somashekar | aa280aa | 2019-04-01 04:15:06 -0500 | [diff] [blame] | 710 | Redfish Create User ${username} ${password} ${role_id} ${enabled} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 711 | |
| 712 | # Delete newly created user. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 713 | Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 714 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 715 | Redfish.Logout |
| 716 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 717 | # Attempt to login with deleted user account. |
| 718 | Run Keyword And Expect Error InvalidCredentialsError* |
| 719 | ... Redfish.Login ${username} ${password} |
| 720 | |
| 721 | Redfish.Login |
| 722 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 723 | |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 724 | Verify Create User Without Enabling |
| 725 | [Documentation] Verify Create User Without Enabling. |
| 726 | [Arguments] ${username} ${password} ${role_id} ${enabled} |
| 727 | |
| 728 | # Description of argument(s): |
| 729 | # username The username to be created. |
| 730 | # password The password to be assigned. |
Sandhya Somashekar | d7d46c0 | 2019-06-26 05:10:25 -0500 | [diff] [blame] | 731 | # role_id The role ID of the user to be created |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 732 | # (e.g. "Administrator", "Operator", etc.). |
| 733 | # enabled Indicates whether the username being created |
| 734 | # should be enabled (${True}, ${False}). |
| 735 | |
Anusha Dathatri | e0dddcf | 2020-06-18 05:23:16 -0500 | [diff] [blame] | 736 | Redfish Create User ${username} ${password} ${role_id} ${enabled} ${False} |
Sandhya Somashekar | e92b1e6 | 2019-04-25 05:27:45 -0500 | [diff] [blame] | 737 | |
| 738 | Redfish.Logout |
| 739 | |
| 740 | # Login with created user. |
| 741 | Run Keyword And Expect Error InvalidCredentialsError* |
| 742 | ... Redfish.Login ${username} ${password} |
| 743 | |
| 744 | Redfish.Login |
Sandhya Somashekar | af402ca | 2019-03-18 05:59:19 -0500 | [diff] [blame] | 745 | |
| 746 | # Delete newly created user. |
Anusha Dathatri | 466816f | 2020-01-30 05:12:36 -0600 | [diff] [blame] | 747 | Redfish.Delete /redfish/v1/AccountService/Accounts/${username} |
George Keishing | 07fb41f | 2020-06-16 08:09:19 -0500 | [diff] [blame] | 748 | |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 749 | Template For Configure Auth Methods |
| 750 | [Documentation] Template to configure auth methods. |
| 751 | [Arguments] ${auth_method} |
| 752 | [Teardown] Configure AuthMethods ${auth_method}=${initial_value} |
| 753 | |
| 754 | # Description of Argument(s): |
| 755 | # authmethods The authmethod setting which needs to be |
| 756 | # set in account service URI. |
| 757 | # valid values BasicAuth, XToken. |
| 758 | |
| 759 | Get AuthMethods Default Values ${auth_method} |
| 760 | |
| 761 | # Patch basicauth to TRUE |
| 762 | Configure AuthMethods ${auth_method}=${TRUE} |
| 763 | |
George Keishing | 79fc7f0 | 2025-05-02 00:37:49 +0530 | [diff] [blame] | 764 | IF "${auth_method}" == "XToken" |
| 765 | Check XToken Works Fine ${HTTP_OK} |
| 766 | ELSE |
| 767 | Check BasicAuth Works Fine ${HTTP_OK} |
| 768 | END |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 769 | |
| 770 | # Patch basicauth to FALSE |
| 771 | Configure AuthMethods ${auth_method}=${FALSE} |
| 772 | |
George Keishing | 79fc7f0 | 2025-05-02 00:37:49 +0530 | [diff] [blame] | 773 | IF "${auth_method}" == "BasicAuth" |
| 774 | Check BasicAuth Works Fine ${HTTP_UNAUTHORIZED} |
| 775 | ELSE |
| 776 | Check XToken Works Fine ${HTTP_UNAUTHORIZED} |
| 777 | END |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 778 | |
| 779 | Configure AuthMethods |
| 780 | [Documentation] Enable/disable authmethod types. |
| 781 | [Arguments] &{authmethods} |
| 782 | |
| 783 | # Description of argument(s): |
| 784 | # authmethods The authmethod setting which needs to be |
| 785 | # set in account service URI. |
| 786 | # Usage Example Configure AuthMethods XToken=${TRUE} BasicAuth=${TRUE} |
| 787 | # This will set the value of "XToken" and "BasicAuth" |
| 788 | # property in accountservice uri to TRUE. |
| 789 | |
| 790 | ${openbmc}= Create Dictionary AuthMethods=${authmethods} |
| 791 | ${oem}= Create Dictionary OpenBMC=${openbmc} |
| 792 | ${payload}= Create Dictionary Oem=${oem} |
| 793 | |
| 794 | # Setting authmethod properties using Redfish session based auth |
| 795 | ${status}= Run Keyword And Return Status |
| 796 | ... Redfish.Patch ${REDFISH_BASE_URI}AccountService |
| 797 | ... body=${payload} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}] |
| 798 | |
George Keishing | c63bfe6 | 2023-11-15 19:09:59 +0530 | [diff] [blame] | 799 | # Setting authmethod properties using basic auth in case the former fails |
aravinth0510 | 746884b | 2022-09-29 16:04:07 +0000 | [diff] [blame] | 800 | IF ${status}==${FALSE} |
| 801 | # Payload dictionary pre-process to match json formatting |
| 802 | ${payload}= Convert To String ${payload} |
| 803 | ${payload}= Replace String ${payload} ' " |
| 804 | ${payload}= Replace String ${payload} False false |
| 805 | ${payload}= Replace String ${payload} True true |
| 806 | |
| 807 | # Curl Command Framing for PATCH authmethod |
| 808 | ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD} |
| 809 | ... -X PATCH '${AUTH_URI}${REDFISH_ACCOUNTS_SERVICE_URI}' |
| 810 | ... -H 'content-type:application/json' -H 'If-Match:*' |
| 811 | ... -d '${payload}' |
| 812 | ${rc} ${out}= Run And Return Rc And Output ${cmd} |
| 813 | |
| 814 | # Check the response of curl command is 200 or 204 |
| 815 | ${check_no_content}= |
| 816 | ... Run Keyword and Return Status Should Contain ${out} 204 |
| 817 | ${check_ok}= |
| 818 | ... Run Keyword and Return Status Should Contain ${out} 200 |
| 819 | Pass Execution If ${check_no_content}==${TRUE} |
| 820 | ... OR ${check_ok}==${TRUE} |
| 821 | END |
| 822 | |
| 823 | |
| 824 | Get AuthMethods Default Values |
| 825 | [Documentation] Get enabled/disabled status of all authmethods |
| 826 | ... from Redfish account service URI |
| 827 | [Arguments] ${authmethod} |
| 828 | |
| 829 | # Description of argument(s): |
| 830 | # authmethod The authmethod property whose value needs to be |
| 831 | # retrieved from account service URI. |
| 832 | # Usage Example Get AuthMethods Default Values BasicAuth |
| 833 | # returns >> ${TRUE} |
| 834 | # Example: |
| 835 | # { |
| 836 | # "@odata.id": "/redfish/v1/AccountService", |
| 837 | # (...) |
| 838 | # "Oem": { |
| 839 | # "OpenBMC": { |
| 840 | # "AuthMethods": { |
| 841 | # "BasicAuth": true, |
| 842 | # "Cookie": true, |
| 843 | # "SessionToken": true, |
| 844 | # "TLS": true, |
| 845 | # "XToken": true |
| 846 | # } |
| 847 | # } |
| 848 | # } |
| 849 | # } |
| 850 | |
| 851 | ${resp}= Redfish.Get Attribute ${REDFISH_ACCOUNTS_SERVICE_URI} Oem |
| 852 | ${authmethods}= Set Variable ${resp['OpenBMC']['AuthMethods']} |
| 853 | ${initial_value}= Get From Dictionary ${authmethods} ${authmethod} |
| 854 | Set Test Variable ${initial_value} |
| 855 | |
| 856 | Check XToken Works Fine |
| 857 | [Documentation] Verify Xtoken works fine. |
| 858 | [Arguments] ${status_code} |
| 859 | |
| 860 | # Description of Argument(s): |
| 861 | # status_code : 200, 401. |
| 862 | |
| 863 | # Verify xtoken auth works for xtoken |
| 864 | Redfish.Get ${REDFISH_ACCOUNTS_SERVICE_URI} |
| 865 | ... valid_status_codes=[${status_code}] |
| 866 | |
| 867 | Check BasicAuth Works Fine |
| 868 | [Documentation] Verify Basic Auth works fine. |
| 869 | [Arguments] ${status_code} |
| 870 | |
| 871 | # Description of Argument(s): |
| 872 | # status_code : 200, 401. |
| 873 | |
| 874 | # Verify basic auth works based on basic auth. |
| 875 | ${cmd}= Catenate curl -k -i -u ${OPENBMC_USERNAME}:${OPENBMC_PASSWORD} |
| 876 | ... ${AUTH_URI}/redfish/v1/AccountService |
| 877 | ${rc} ${out}= Run And Return Rc And Output ${cmd} |
| 878 | |
| 879 | # Check the response of curl command is 200/401 |
| 880 | Should Contain ${out} ${status_code} |