1*** Settings *** 2 3Documentation Test OpenBMC GUI "User management" sub-menu of "Security and access". 4 5Resource ../../lib/gui_resource.robot 6 7Suite Setup Launch Browser And Login GUI 8Suite Teardown Suite Teardown Execution 9Test Setup Test Setup Execution 10 11Force Tags User_Management_Sub_Menu 12 13*** Variables *** 14 15 16${xpath_user_management_heading} //h1[text()="User management"] 17${xpath_select_user} //input[contains(@class,"custom-control-input")] 18${xpath_account_policy} //button[contains(text(),'Account policy settings')] 19${xpath_add_user} //button[contains(text(),'Add user')] 20${xpath_edit_user} //*[@data-test-id='userManagement-tableRowAction-edit-0'] 21${xpath_delete_user} //*[@data-test-id='userManagement-tableRowAction-delete-1'] 22${xpath_account_status_enabled_button} //*[@data-test-id='userManagement-radioButton-statusEnabled'] 23${xpath_account_status_disabled_button} //*[@data-test-id='userManagement-radioButton-statusDisabled'] 24${xpath_username_input_button} //*[@data-test-id='userManagement-input-username'] 25${xpath_privilege_list_button} //*[@data-test-id='userManagement-select-privilege'] 26${xpath_password_input_button} //*[@data-test-id='userManagement-input-password'] 27${xpath_password_confirm_button} //*[@data-test-id='userManagement-input-passwordConfirmation'] 28${xpath_cancel_button} //*[@data-test-id='userManagement-button-cancel'] 29${xpath_submit_button} //*[@data-test-id='userManagement-button-submit'] 30${xpath_delete_button} //button[text()='Delete user'] 31${xpath_add_user_heading} //h5[contains(text(),'Add user')] 32${xpath_policy_settings_header} //*[text()="Account policy settings"] 33${xpath_auto_unlock} //*[@data-test-id='userManagement-radio-automaticUnlock'] 34${xpath_manual_unlock} //*[@data-test-id='userManagement-radio-manualUnlock'] 35${xpath_max_failed_login} //*[@data-test-id='userManagement-input-lockoutThreshold'] 36${test_user_password} TestPwd1 37${xpath_user_creation_error_message} //*[contains(text(),'Error creating user')] 38${xpath_close_error_message} //*/*[contains(text(),'Error')]/following-sibling::button 39@{username} admin_user readonly_user disabled_user 40@{list_user_privilege} Administrator ReadOnly 41 42 43*** Test Cases *** 44 45Verify Navigation To User Management Page 46 [Documentation] Verify navigation to user management page. 47 [Tags] Verify_Navigation_To_User_Management_Page 48 49 Page Should Contain Element ${xpath_user_management_heading} 50 51 52Verify Existence Of All Sections In User Management Page 53 [Documentation] Verify existence of all sections in user management page. 54 [Tags] Verify_Existence_Of_All_Sections_In_User_Management_Page 55 56 Page should contain View privilege role descriptions 57 58 59Verify Existence Of All Input Boxes In User Management Page 60 [Documentation] Verify existence of all sections in user managemnet page. 61 [Tags] Verify_Existence_Of_All_Input_Boxes_In_User_Management_Page 62 63 Page Should Contain Checkbox ${xpath_select_user} 64 65 66Verify Existence Of All Buttons In User Management Page 67 [Documentation] Verify existence of all buttons in user management page. 68 [Tags] Verify_Existence_Of_All_Buttons_In_User_Management_Page 69 70 Page should contain Button ${xpath_account_policy} 71 Page should contain Button ${xpath_add_user} 72 Page Should Contain Element ${xpath_edit_user} 73 Page Should Contain Element ${xpath_delete_user} 74 75 76Verify Existence Of All Button And Fields In Add User 77 [Documentation] Verify existence of all buttons and fields in add user page. 78 [Tags] Verify_Existence_Of_All_Button_And_Fields_In_Add_User 79 [Teardown] Click Element ${xpath_cancel_button} 80 81 Click Element ${xpath_add_user} 82 Wait Until Page Contains Element ${xpath_add_user_heading} 83 Page Should Contain Element ${xpath_account_status_enabled_button} 84 Page Should Contain Element ${xpath_account_status_disabled_button} 85 Page Should Contain Element ${xpath_username_input_button} 86 Page Should Contain Element ${xpath_privilege_list_button} 87 Page Should Contain Element ${xpath_password_input_button} 88 Page Should Contain Element ${xpath_password_confirm_button} 89 Page Should Contain Element ${xpath_cancel_button} 90 Page Should Contain Element ${xpath_submit_button} 91 92 93Verify Existence Of All Buttons And Fields In Account Policy Settings 94 [Documentation] Verify existence of all buttons and fields in account policy settings page. 95 [Tags] Verify_Existence_Of_All_Buttons_And_Fields_In_Account_Policy_Settings 96 [Teardown] Click Element ${xpath_cancel_button} 97 98 Click Element ${xpath_account_policy} 99 Wait Until Page Contains Element ${xpath_policy_settings_header} 100 Page Should Contain Element ${xpath_auto_unlock} 101 Page Should Contain Element ${xpath_manual_unlock} 102 Page Should Contain Element ${xpath_max_failed_login} 103 Page Should Contain Element ${xpath_submit_button} 104 Page Should Contain Element ${xpath_cancel_button} 105 106 107Verify User Access Privilege 108 [Documentation] Create a new user with a privilege and verify that user is created. 109 [Tags] Verify_User_Access_Privilege 110 [Teardown] Delete Users Via Redfish @{username} 111 [Template] Create User And Verify 112 113 # username privilege_level enabled 114 ${username}[0] Administrator ${True} 115 ${username}[1] ReadOnly ${True} 116 ${username}[2] Administrator ${False} 117 118 119Verify Operator And No Access User Privilege 120 [Documentation] Create users with different access privilege 121 ... and verify that the user is getting created. 122 [Tags] Verify_Operator_And_No_Access_User_Privilege 123 [Template] Create User And Verify 124 125 # username privilege_level enabled 126 operator_user Operator ${True} 127 noaccess_user NoAccess ${True} 128 129 130Verify User Account And Properties Saved Through Reboots 131 [Documentation] Verify that user account and properties saved through reboots. 132 [Teardown] Delete Users Via Redfish my_admin_user 133 [Tags] Verify_User_Account_And_Properties_Saved_Through_Reboots 134 135 # Create an User account. 136 Create User And Verify my_admin_user Administrator ${True} 137 138 # Reboot BMC. 139 Redfish OBMC Reboot (off) stack_mode=normal 140 141 Click Element ${xpath_refresh_button} 142 Wait Until Page Contains my_admin_user timeout=15 143 144 145Delete User Account Via GUI 146 [Documentation] Delete user account via GUI. 147 [Tags] Delete_User_Account_Via_GUI 148 149 # Create new user account via GUI. 150 Create User And Verify ${username}[0] Administrator ${True} 151 152 # Delete the user created via GUI. 153 Delete Users Via GUI ${username}[0] 154 155 156Verify Error While Creating Users With Same Name 157 [Documentation] Verify proper error message while creating two user accounts with same username. 158 [Tags] Verify_Error_While_Creating_Users_With_Same_Name 159 [Teardown] Delete Users Via Redfish ${username} 160 161 # Get random username and user privilege level. 162 ${username}= Generate Random String 8 [LETTERS] 163 ${privilege_level}= Evaluate random.choice(${list_user_privilege}) random 164 165 # Create new user account. 166 Create User And Verify ${username} ${privilege_level} ${True} 167 168 # Expect failure while creating second user account with same username. 169 Create User And Verify ${username} ${privilege_level} ${True} Failure 170 171 172Test Modifying User Privilege Of Existing User Via GUI 173 [Documentation] Modify user privilege of existing user via GUI and verify the changes using Redfish. 174 [Tags] Test_Modifying_User_Privilege_Of_Existing_User_Via_GUI 175 [Teardown] Delete Users Via Redfish ${username} 176 177 # Get random username and user privilege level. 178 ${username}= Generate Random String 8 [LETTERS] 179 ${privilege_level}= Evaluate random.choice(${list_user_privilege}) random 180 181 # Create new user account. 182 Create User And Verify ${username} ${privilege_level} ${True} 183 184 # Get user privilege role details distinct from the current ones. 185 FOR ${privilege} IN @{list_user_privilege} 186 IF '${privilege}' != '${privilege_level}' 187 ${modify_privilege}= Set Variable ${privilege} 188 END 189 END 190 191 # Modify user privilege via GUI. 192 Wait Until Keyword Succeeds 30 sec 5 sec Click Element 193 ... //td[text()='${username}']/following-sibling::*/*/*[@title='Edit user'] 194 Select From List by Value ${xpath_privilege_list_button} ${modify_privilege} 195 196 # Submit changes. 197 Click Element ${xpath_submit_button} 198 199 # Confirm the successful update. 200 Wait Until Element Is Visible ${xpath_success_message} timeout=30 201 Wait Until Element Is Not Visible ${xpath_success_message} timeout=30 202 203 # Verify user privilege via Redfish. 204 Redfish.Login 205 ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/${username} 206 Should Be Equal ${resp.dict["RoleId"]} ${modify_privilege} 207 Redfish.Logout 208 209 210Test Modifying User Account Status Of Existing User Via GUI 211 [Documentation] Test modifying user account status of existing user via GUI and verify changes using Redfish. 212 [Tags] Test_Modifying_User_Account_Status_Of_Existing_User_Via_GUI 213 [Teardown] Delete Users Via Redfish ${username} 214 215 # Get random username, user privilege level and account status. 216 ${username}= Generate Random String 8 [LETTERS] 217 ${privilege_level}= Evaluate random.choice(${list_user_privilege}) random 218 ${initial_account_status}= Evaluate random.choice([True, False]) random 219 220 # Create new user account. 221 Create User And Verify ${username} ${privilege_level} ${initial_account_status} 222 223 # Modify user account status via GUI. 224 Wait Until Keyword Succeeds 30 sec 5 sec Click Element 225 ... //td[text()='${username}']/following-sibling::*/*/*[@title='Edit user'] 226 Wait Until Element Is Visible ${xpath_submit_button} timeout=30 227 228 # Switch the user account status to its opposite state. 229 IF ${initial_account_status} == ${True} 230 Click Element At Coordinates ${xpath_account_status_disabled_button} 0 0 231 ELSE 232 Click Element At Coordinates ${xpath_account_status_enabled_button} 0 0 233 END 234 235 # Submit changes. 236 Click Element ${xpath_submit_button} 237 238 # Confirm the successful update. 239 Wait Until Element Is Visible ${xpath_success_message} timeout=30 240 Wait Until Element Is Not Visible ${xpath_success_message} timeout=60 241 242 # Verify account status via Redfish. 243 IF ${initial_account_status} == ${True} 244 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${test_user_password} 245 Should Be Equal ${status} ${False} 246 ELSE 247 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${test_user_password} 248 Should Be Equal ${status} ${True} 249 END 250 251 252Test Modifying User Password Of Existing User Via GUI 253 [Documentation] Modify user password of existing user via GUI and verify changes using Redfish. 254 [Tags] Test_Modifying_User_Password_Of_Existing_User_Via_GUI 255 [Teardown] Delete Users Via Redfish ${username} 256 257 # Get random username, user privilege level and account status. 258 ${username}= Generate Random String 8 [LETTERS] 259 ${privilege_level}= Evaluate random.choice(${list_user_privilege}) random 260 ${initial_account_status}= Evaluate random.choice([True, False]) random 261 262 # Initialize the new password for the account. 263 ${new_password}= Set Variable Testpassword1 264 265 # Create new user account. 266 Create User And Verify ${username} ${privilege_level} ${initial_account_status} 267 268 # Wait for newly created user to appear on the page. 269 Wait Until Element Is Visible //td[text()='${username}'] 270 271 # Modify user password via GUI. 272 Click Element //td[text()='${username}']/following-sibling::*/*/*[@title='Edit user'] 273 Input Text ${xpath_password_input_button} ${new_password} 274 Input Text ${xpath_password_confirm_button} ${new_password} 275 276 # Submit changes. 277 Click Element ${xpath_submit_button} 278 279 # Confirm the successful update. 280 Wait Until Element Is Visible ${xpath_success_message} timeout=30 281 Wait Until Element Is Not Visible ${xpath_success_message} timeout=60 282 283 # Verify changes via Redfish. 284 ${status}= Run Keyword And Return Status Redfish.Login ${username} ${new_password} 285 Should Be Equal ${status} ${True} 286 287 288*** Keywords *** 289 290Create User And Verify 291 [Documentation] Create a user with given user name and privilege and verify that the 292 ... user is created successfully via GUI and Redfish. 293 [Arguments] ${user_name} ${user_privilege} ${enabled} ${expected_status}=Success 294 295 # Description of argument(s): 296 # user_name The name of the user to be created (e.g. "test", "robert", etc.). 297 # user_privilege Privilege of the user. 298 # enabled If the user is enabled (e.g True if enabled, False if disabled). 299 # expected_status Expected status of user creation (e.g. Success, Failure). 300 301 Click Element ${xpath_add_user} 302 Wait Until Page Contains Element ${xpath_add_user_heading} 303 304 # Select disabled radio button if user needs to be disabled 305 Run Keyword If ${enabled} == ${False} 306 ... Click Element At Coordinates ${xpath_account_status_disabled_button} 0 0 307 308 # Input username, password and privilege. 309 Input Text ${xpath_username_input_button} ${user_name} 310 Select From List by Value ${xpath_privilege_list_button} ${user_privilege} 311 312 Input Text ${xpath_password_input_button} ${test_user_password} 313 314 Input Text ${xpath_password_confirm_button} ${test_user_password} 315 316 # Submit. 317 Click Element ${xpath_submit_button} 318 319 # Proceed with future steps based on the expected execution status. 320 IF '${expected_status}' == 'Success' 321 Wait Until Element Is Visible ${xpath_success_message} timeout=30 322 323 # Refresh page and check new user is available. 324 Wait Until Page Contains Element ${xpath_add_user} 325 Click Element ${xpath_refresh_button} 326 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=30 327 Wait Until Page Contains ${user_name} timeout=15 328 329 # Cross check the privilege of newly added user via Redfish. 330 Redfish.Login 331 ${user_priv_redfish}= Redfish_Utils.Get Attribute 332 ... /redfish/v1/AccountService/Accounts/${user_name} RoleId 333 Should Be Equal ${user_privilege} ${user_priv_redfish} 334 Redfish.Logout 335 336 # Check enable/disable status for user. 337 ${status}= Run Keyword And Return Status Redfish.Login ${user_name} ${test_user_password} 338 Run Keyword If ${enabled} == ${False} 339 ... Should Be Equal ${status} ${False} 340 ... ELSE Should Be Equal ${status} ${True} 341 Redfish.Logout 342 343 ELSE IF '${expected_status}' == 'Failure' 344 Wait Until Element Is Visible ${xpath_user_creation_error_message} timeout=60 345 346 # Close error message popup. 347 Click Element ${xpath_close_error_message} 348 Wait Until Element Is Not Visible ${xpath_user_creation_error_message} timeout=60 349 END 350 351 352Test Setup Execution 353 [Documentation] Do test case setup tasks. 354 355 # Navigate to https://xx.xx.xx.xx/#/access-control/user-management user management page. 356 357 Click Element ${xpath_secuity_and_accesss_menu} 358 Click Element ${xpath_user_management_sub_menu} 359 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain user-management 360 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=30 361 362 363Delete Users Via Redfish 364 [Documentation] Delete given users using Redfish. 365 [Arguments] @{user_list} 366 # Description of argument(s): 367 # user_list List of user name to be deleted. 368 369 FOR ${user} IN @{user_list} 370 Redfish.Login 371 Redfish.Delete /redfish/v1/AccountService/Accounts/${user} 372 Redfish.Logout 373 END 374 375 376Delete Users Via GUI 377 [Documentation] Delete given users via GUI. 378 [Arguments] @{user_list} 379 # Description of argument(s): 380 # user_list List of user name to be deleted. 381 382 FOR ${user} IN @{user_list} 383 Wait Until Keyword Succeeds 30 sec 5 sec Click Element 384 ... //td[text()='${user}']/following-sibling::*/*/*[@title='Delete user'] 385 Wait Until Keyword Succeeds 30 sec 5 sec Click Element ${xpath_delete_button} 386 Wait Until Element Is Visible ${xpath_success_message} timeout=30 387 Wait Until Element Is Not Visible ${xpath_success_message} timeout=60 388 END 389 390 391Suite Teardown Execution 392 [Documentation] Do suite teardown tasks. 393 394 Run Keyword And Ignore Error Logout GUI 395 Close Browser 396 Redfish.Logout 397