xref: /openbmc/openbmc-test-automation/gui/test/access_control/test_obmc_gui_local_users.robot (revision 069b266e40a93fda3992c888062745b1ac920473)
1*** Settings ***
2
3Documentation  Test OpenBMC GUI "Local users" sub-menu of "Access control".
4
5Resource        ../../lib/resource.robot
6
7Suite Setup     Launch Browser And Login OpenBMC GUI
8Suite Teardown  Close Browser
9Test Setup      Test Setup Execution
10Test Tags      Obmc_Gui_Local_Users
11
12*** Variables ***
13
14${xpath_select_user}              //input[contains(@class,"bmc-table__checkbox-input")]
15${xpath_edit_user}                //button[@aria-label="Edit"]
16${xpath_delete_user}              //button[@aria-label="Delete"]
17${xpath_account_policy}           //button[text()[contains(.,"Account policy settings")]]
18${xpath_add_user}                 //button[text()[contains(.,"Add user")]]
19${xpath_enable_user}              //label[text()[contains(.,"Enabled")]]
20${xpath_disable_user}             //label[text()[contains(.,"Disabled")]]
21${xpath_input_user}               //input[@id="username"]
22${xpath_select_privilege}         //select[@id="privilege"]
23${xpath_input_password}           //input[@id="password"]
24${xpath_confirm_password}         //input[@id="passwordConfirm"]
25${xpath_remove_button}            //button[text()[contains(.,"Remove")]]
26
27*** Test Cases ***
28
29Verify Existence Of All Sections In Local User Management Page
30    [Documentation]  Verify existence of all sections in local user management page.
31    [Tags]  Verify_Existence_Of_All_Sections_In_Local_User_Management_Page
32
33    Page should contain  View privilege role descriptions
34
35
36Verify Existence Of All Buttons In Local User Management Page
37    [Documentation]  Verify existence of all buttons in local user management page.
38    [Tags]  Verify_Existence_Of_All_Buttons_In_Local_User_Management_Page
39
40    Page should contain Button  ${xpath_account_policy}
41    Page should contain Button  ${xpath_add_user}
42    Page Should Contain Button  ${xpath_edit_user}
43    Page Should Contain Button  ${xpath_delete_user}
44
45
46Verify Existence Of All Input Boxes In Local User Management Page
47    [Documentation]  Verify existence of all input boxes in local user management page.
48    [Tags]  Verify_Existence_Of_All_Input_Boxes_In_Local_User_Management_Page
49
50    Page Should Contain Checkbox  ${xpath_select_user}
51
52
53Add User And Verify
54    [Documentation]  Add user and verify.
55    [Tags]  Add_User_And_Verify
56
57    # Confirm same user does not exist.
58    Delete User  testUser1
59    Add User  testUser1  testUserPwd1  Administrator
60    Test Login  testUser1  testUserPwd1
61
62
63Delete User And Verify
64    [Documentation]  Delete user and verify.
65    [Tags]  Delete_User_And_Verify
66
67    # Confirm same user does not exist.
68    Delete User  testUser2
69    Add User  testUser2  testUserPwd2  Callback
70    Delete User  testUser2
71    Click Element  ${xpath_select_refresh_button}
72    Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
73    Page Should Not Contain  testUser2
74    Test Login  testUser2  testUserPwd2  ${False}
75
76
77*** Keywords ***
78
79Test Setup Execution
80    [Documentation]  Do test case setup tasks.
81
82    Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
83    Click Element  ${xpath_select_access_control}
84    Click Element  ${xpath_select_local_users}
85    Wait Until Page Contains  Local user management
86
87Add User
88   [Documentation]  Create user.
89   [Arguments]  ${username}  ${password}  ${privilege}=Administrator
90   ...  ${account_status}=Enabled
91
92   # Description of argument(s):
93   # username   Name of the user to be created.
94   # password   New user password.
95   # privilege  User privilege.
96   # account_status  Enable or disable new user.
97
98   Click Element  ${xpath_add_user}
99   Add User Details  ${username}  ${password}  ${privilege}  ${account_status}
100
101Add User Details
102   [Documentation]  Add new user details.
103   [Arguments]  ${username}  ${password}  ${privilege}  ${account_status}
104
105   # Description of argument(s):
106   # username   User name.
107   # password   User password.
108   # privilege  User privilege.
109   # account_status  Enable or disable user.
110
111   IF  '${account_status}' == 'Enabled'
112     Click Element  ${xpath_enable_user}
113   ELSE
114     Click Element  ${xpath_disable_user}
115   END
116
117   Input Text  ${xpath_input_user}  ${username}
118   Input Password  ${xpath_input_password}  ${password}
119   Input Password  ${xpath_confirm_password}  ${password}
120   Select User Privilege  ${privilege}
121   Click Element  ${xpath_add_user}
122
123Select User Privilege
124   [Documentation]  Select user privilege.
125   [Arguments]  ${privilege}=Administrator
126
127   # Description of argument(s):
128   # privilege  User privilege.
129
130   Click Element  ${xpath_select_privilege}
131   Click Element  //option[text()[contains(.,"${privilege}")]]
132
133Delete User
134   [Documentation]  Delete user.
135   [Arguments]  ${username}
136
137   # Description of argument(s):
138   # username   Name of the user to be created.
139
140   ${result}=  Run Keyword And Return Status  Page Should Contain  ${username}
141   IF  '${result}' == '${True}'
142      Click Element  //*[text()="${username}"]//following::td[3]//button[@aria-label="Delete"]
143      Click Element  ${xpath_remove_button}
144   ELSE
145      Log  User does not exist
146   END
147
148Test Login
149   [Documentation]  Try to login to Openbmc.
150   [Arguments]  ${username}  ${password}  ${expected_result}=${True}
151
152   # Description of argument(s):
153   # username   Username.
154   # password   User password.
155   # expected_result  Result of the test.
156
157    Open Browser  ${OPENBMC_GUI_URL}  alias=2
158    Switch Browser  2
159    ${status}=  Run Keyword And Return Status  Login OpenBMC GUI  ${username}  ${password}
160    Should Be Equal  ${status}  ${expected_result}  Login expectation was not met
161    IF  '${status}' == '${True}'
162       LogOut OpenBMC GUI
163    ELSE
164       Page Should Contain  Invalid username or password
165    END
166    Close Browser
167    Switch Browser  1
168
169