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
10Force 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   Run Keyword If  '${account_status}' == 'Enabled'
112   ...  Click Element  ${xpath_enable_user}
113   ...  ELSE  Click Element  ${xpath_disable_user}
114   Input Text  ${xpath_input_user}  ${username}
115   Input Password  ${xpath_input_password}  ${password}
116   Input Password  ${xpath_confirm_password}  ${password}
117   Select User Privilege  ${privilege}
118   Click Element  ${xpath_add_user}
119
120Select User Privilege
121   [Documentation]  Select user privilege.
122   [Arguments]  ${privilege}=Administrator
123
124   # Description of argument(s):
125   # privilege  User privilege.
126
127   Click Element  ${xpath_select_privilege}
128   Click Element  //option[text()[contains(.,"${privilege}")]]
129
130Delete User
131   [Documentation]  Delete user.
132   [Arguments]  ${username}
133
134   # Description of argument(s):
135   # username   Name of the user to be created.
136
137   ${result}=  Run Keyword And Return Status  Page Should Contain  ${username}
138   Run Keyword If  '${result}' == '${True}'
139   ...  Run Keywords  Click Element  //*[text()="${username}"]//following::td[3]//button[@aria-label="Delete"]
140   ...  AND  Click Element  ${xpath_remove_button}
141   ...  ELSE  Log  User does not exist
142
143Test Login
144   [Documentation]  Try to login to Openbmc.
145   [Arguments]  ${username}  ${password}  ${expected_result}=${True}
146
147   # Description of argument(s):
148   # username   Username.
149   # password   User password.
150   # expected_result  Result of the test.
151
152    Open Browser  ${obmc_gui_url}  alias=2
153    Switch Browser  2
154    ${status}=  Run Keyword And Return Status  Login OpenBMC GUI  ${username}  ${password}
155    Should Be Equal  ${status}  ${expected_result}  Login expectation was not met
156    Run Keyword If  '${status}' == '${True}'
157    ...  LogOut OpenBMC GUI
158    ...  ELSE  Page Should Contain  Invalid username or password
159    Close Browser
160    Switch Browser  1
161
162