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
11
12*** Variables ***
13
14
15${xpath_user_management_heading}         //h1[text()="User management"]
16${xpath_select_user}                     //input[contains(@class,"custom-control-input")]
17${xpath_account_policy}                  //button[contains(text(),'Account policy settings')]
18${xpath_add_user}                        //button[contains(text(),'Add user')]
19${xpath_edit_user}                       //*[@data-test-id='userManagement-tableRowAction-edit-0']
20${xpath_delete_user}                     //*[@data-test-id='userManagement-tableRowAction-delete-1']
21${xpath_account_status_enabled_button}   //*[@data-test-id='userManagement-radioButton-statusEnabled']
22${xpath_account_status_disabled_button}  //*[@data-test-id='userManagement-radioButton-statusDisabled']
23${xpath_username_input_button}           //*[@data-test-id='userManagement-input-username']
24${xpath_privilege_list_button}           //*[@data-test-id='userManagement-select-privilege']
25${xpath_password_input_button}           //*[@data-test-id='userManagement-input-password']
26${xpath_password_confirm_button}         //*[@data-test-id='userManagement-input-passwordConfirmation']
27${xpath_cancel_button}                   //*[@data-test-id='userManagement-button-cancel']
28${xpath_submit_button}                   //*[@data-test-id='userManagement-button-submit']
29${xpath_add_user_heading}                //h5[contains(text(),'Add user')]
30${xpath_policy_settings_header}          //*[text()="Account policy settings"]
31${xpath_auto_unlock}                     //*[@data-test-id='userManagement-radio-automaticUnlock']
32${xpath_manual_unlock}                   //*[@data-test-id='userManagement-radio-manualUnlock']
33${xpath_max_failed_login}                //*[@data-test-id='userManagement-input-lockoutThreshold']
34${test_user_password}                    TestPwd1
35@{username}                              admin_user  readonly_user  disabled_user
36
37
38*** Test Cases ***
39
40Verify Navigation To User Management Page
41    [Documentation]  Verify navigation to user management page.
42    [Tags]  Verify_Navigation_To_User_Management_Page
43
44    Page Should Contain Element  ${xpath_user_management_heading}
45
46
47Verify Existence Of All Sections In User Management Page
48    [Documentation]  Verify existence of all sections in user management page.
49    [Tags]  Verify_Existence_Of_All_Sections_In_User_Management_Page
50
51    Page should contain  View privilege role descriptions
52
53
54Verify Existence Of All Input Boxes In User Management Page
55    [Documentation]  Verify existence of all sections in user managemnet page.
56    [Tags]  Verify_Existence_Of_All_Input_Boxes_In_User_Management_Page
57
58    Page Should Contain Checkbox  ${xpath_select_user}
59
60
61Verify Existence Of All Buttons In User Management Page
62    [Documentation]  Verify existence of all buttons in user management page.
63    [Tags]  Verify_Existence_Of_All_Buttons_In_User_Management_Page
64
65    Page should contain Button  ${xpath_account_policy}
66    Page should contain Button  ${xpath_add_user}
67    Page Should Contain Element  ${xpath_edit_user}
68    Page Should Contain Element  ${xpath_delete_user}
69
70
71Verify Existence Of All Button And Fields In Add User
72    [Documentation]  Verify existence of all buttons and fields in add user page.
73    [Tags]  Verify_Existence_Of_All_Button_And_Fields_In_Add_User
74    [Teardown]  Click Element  ${xpath_cancel_button}
75
76    Click Element  ${xpath_add_user}
77    Wait Until Page Contains Element  ${xpath_add_user_heading}
78    Page Should Contain Element  ${xpath_account_status_enabled_button}
79    Page Should Contain Element  ${xpath_account_status_disabled_button}
80    Page Should Contain Element  ${xpath_username_input_button}
81    Page Should Contain Element  ${xpath_privilege_list_button}
82    Page Should Contain Element  ${xpath_password_input_button}
83    Page Should Contain Element  ${xpath_password_confirm_button}
84    Page Should Contain Element  ${xpath_cancel_button}
85    Page Should Contain Element  ${xpath_submit_button}
86
87
88Verify Existence Of All Buttons And Fields In Account Policy Settings
89    [Documentation]  Verify existence of all buttons and fields in account policy settings page.
90    [Tags]  Verify_Existence_Of_All_Buttons_And_Fields_In_Account_Policy_Settings
91    [Teardown]  Click Element  ${xpath_cancel_button}
92
93    Click Element  ${xpath_account_policy}
94    Wait Until Page Contains Element  ${xpath_policy_settings_header}
95    Page Should Contain Element  ${xpath_auto_unlock}
96    Page Should Contain Element  ${xpath_manual_unlock}
97    Page Should Contain Element  ${xpath_max_failed_login}
98    Page Should Contain Element  ${xpath_submit_button}
99    Page Should Contain Element  ${xpath_cancel_button}
100
101
102Verify User Access Privilege
103    [Documentation]  Create a new user with a privilege and verify that user is created.
104    [Tags]  Verify_User_Access_Privilege
105    [Teardown]  Delete Users Via Redfish  @{username}
106    [Template]  Create User And Verify
107
108    # username       privilege_level  enabled
109    ${username}[0]   Administrator    ${True}
110    ${username}[1]   ReadOnly         ${True}
111    ${username}[2]   Administrator    ${False}
112
113
114Verify Operator And No Access User Privilege
115    [Documentation]  Create users with different access privilege
116    ...  and verify that the user is getting created.
117    [Tags]  Verify_Operator_And_No_Access_User_Privilege
118    [Template]  Create User And Verify
119
120    # username      privilege_level  enabled
121    operator_user   Operator         ${True}
122    noaccess_user   NoAccess         ${True}
123
124
125Verify User Account And Properties Saved Through Reboots
126    [Documentation]  Verify that user account and properties saved through reboots.
127    [Teardown]  Delete Users Via Redfish  my_admin_user
128    [Tags]  Verify_User_Account_And_Properties_Saved_Through_Reboots
129
130    # Create an User account.
131    Create User And Verify  my_admin_user  Administrator  ${True}
132
133    # Reboot BMC.
134    Redfish OBMC Reboot (off)  stack_mode=normal
135
136    Click Element  ${xpath_refresh_button}
137    Wait Until Page Contains  my_admin_user  timeout=15
138
139
140*** Keywords ***
141
142Create User And Verify
143    [Documentation]  Create a user with given user name and privilege and verify that the
144    ...  user is created successfully via GUI and Redfish.
145    [Arguments]  ${user_name}  ${user_privilege}  ${enabled}
146
147    # Description of argument(s):
148    # user_name           The name of the user to be created (e.g. "test", "robert", etc.).
149    # user_privilege      Privilege of the user.
150    # enabled             If the user is enabled (e.g True if enabled, False if disabled).
151
152    Click Element  ${xpath_add_user}
153    Wait Until Page Contains Element  ${xpath_add_user_heading}
154
155    # Select disabled radio button if user needs to be disabled
156    Run Keyword If  ${enabled} == ${False}
157    ...  Click Element At Coordinates  ${xpath_account_status_disabled_button}  0  0
158
159    # Input username, password and privilege.
160    Input Text  ${xpath_username_input_button}  ${user_name}
161    Select From List by Value  ${xpath_privilege_list_button}  ${user_privilege}
162
163    Input Text  ${xpath_password_input_button}  ${test_user_password}
164
165    Input Text  ${xpath_password_confirm_button}  ${test_user_password}
166
167    # Submit.
168    Click Element  ${xpath_submit_button}
169
170    # Refresh page and check new user is available.
171    Wait Until Page Contains Element  ${xpath_add_user}
172    Click Element  ${xpath_refresh_button}
173    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
174    Wait Until Page Contains  ${user_name}  timeout=15
175
176    # Cross check the privilege of newly added user via Redfish.
177    Redfish.Login
178    ${user_priv_redfish}=  Redfish_Utils.Get Attribute
179    ...  /redfish/v1/AccountService/Accounts/${user_name}  RoleId
180    Should Be Equal  ${user_privilege}  ${user_priv_redfish}
181    Redfish.Logout
182
183    # Check enable/disable status for user.
184    ${status}=  Run Keyword And Return Status  Redfish.Login  ${user_name}  ${test_user_password}
185    Run Keyword If  ${enabled} == ${False}
186    ...  Should Be Equal  ${status}  ${False}
187    ...  ELSE  Should Be Equal  ${status}  ${True}
188    Redfish.Logout
189
190
191Test Setup Execution
192    [Documentation]  Do test case setup tasks.
193
194    # Navigate to https://xx.xx.xx.xx/#/access-control/user-management  user management page.
195
196    Click Element  ${xpath_secuity_and_accesss_menu}
197    Click Element  ${xpath_user_management_sub_menu}
198    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  user-management
199    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
200
201
202Delete Users Via Redfish
203    [Documentation]  Delete given users using Redfish.
204    [Arguments]  @{user_list}
205    # Description of argument(s):
206    # user_list          List of user name to be deleted.
207
208    FOR  ${user}  IN  @{user_list}
209      Redfish.Login
210      Redfish.Delete  /redfish/v1/AccountService/Accounts/${user}
211      Redfish.Logout
212    END
213
214
215Suite Teardown Execution
216    [Documentation]  Do suite teardown tasks.
217
218    Logout GUI
219    Close Browser
220    Redfish.Logout
221