blob: e77f303389a64a00077a4cd5239f11404c4e99d3 [file] [log] [blame]
Sushma M Mef474f42020-07-29 16:25:39 -05001*** Settings ***
2
Rahul Maheshwari142642d2021-08-24 00:00:15 -05003Documentation Test OpenBMC GUI "LDAP" sub-menu of "Security and access".
Sushma M Mef474f42020-07-29 16:25:39 -05004
Rahul Maheshwari41747da2020-11-17 09:09:52 -06005Resource ../../lib/gui_resource.robot
Anves Kumar rayankulab44c9572021-04-27 00:44:06 -05006Resource ../../../lib/bmc_ldap_utils.robot
Sushma M Mef474f42020-07-29 16:25:39 -05007
Anves Kumar rayankula010efe62021-06-09 09:00:58 -05008Suite Setup Suite Setup Execution
Sushma M Mef474f42020-07-29 16:25:39 -05009Suite Teardown Close Browser
Sushma M Mef474f42020-07-29 16:25:39 -050010
11
12*** Variables ***
13
Sushma M M26302992020-08-31 01:15:26 -050014${xpath_ldap_heading} //h1[text()="LDAP"]
Sweta Potthurifd889f52021-08-17 02:45:12 -050015${xpath_enable_ldap_checkbox} //*[@data-test-id='ldap-checkbox-ldapAuthenticationEnabled']//following-sibling::label
Rahul Maheshwari062dceb2021-01-19 04:16:30 -060016${xpath_secure_ldap_checkbox} //*[@data-test-id='ldap-checkbox-secureLdapEnabled']
Sushma M Mef474f42020-07-29 16:25:39 -050017${xpath_service_radio_button} //*[@data-test-id="ldap-radio-activeDirectoryEnabled"]
18${xpath_add_role_group_button} //button[contains(text(),'Add role group')]
Anves Kumar rayankula47892a22021-03-26 03:57:02 -050019${xpath_ldap_url} //*[@data-test-id='ldap-input-serverUri']
20${xpath_ldap_bind_dn} //*[@data-test-id='ldap-input-bindDn']
21${xpath_ldap_password} //*[@id='bind-password']
22${xpath_ldap_base_dn} //*[@data-test-id='ldap-input-baseDn']
23${xpath_ldap_save_settings} //*[@data-test-id='ldap-button-saveSettings']
24${xpath_select_refresh_button} //*[text()[contains(.,"Refresh")]]
Anves Kumar rayankulab44c9572021-04-27 00:44:06 -050025${xpath_add_group_name} //*[@id="role-group-name"]
26${xpath_add_group_Privilege} //*[@id="privilege"]
27${xpath_add_privilege_button} //button[text()=" Add "]
28${xpath_delete_group_button} //*[@title="Delete"]
29${xpath_delete_button} //button[text()="Delete"]
Rahul Maheshwari062dceb2021-01-19 04:16:30 -060030
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050031
32${incorrect_ip} 1.2.3.4
Priya Sinhac1294c92022-08-02 00:33:02 -050033${wrong_ldap_port} 135
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050034
Sushma M Mef474f42020-07-29 16:25:39 -050035*** Test Cases ***
36
Sushma M M26302992020-08-31 01:15:26 -050037Verify Navigation To LDAP Page
38 [Documentation] Verify navigation to LDAP page.
39 [Tags] Verify_Navigation_To_LDAP_Page
40
41 Page Should Contain Element ${xpath_ldap_heading}
42
43
Sushma M Mef474f42020-07-29 16:25:39 -050044Verify Existence Of All Sections In LDAP Page
45 [Documentation] Verify existence of all sections in LDAP page.
46 [Tags] Verify_Existence_Of_All_Sections_In_LDAP_Page
47
48 Page Should Contain Settings
49 Page Should Contain Role groups
50
51
52Verify Existence Of All Buttons In LDAP Page
53 [Documentation] Verify existence of all buttons in LDAP page.
54 [Tags] Verify_Existence_Of_All_Buttons_In_LDAP_Page
55
56 # Buttons under settings section.
57 Page Should Contain Element ${xpath_service_radio_button}
58 Page Should Contain Element ${xpath_save_settings_button}
59
60 # Buttons under role groups section.
61 Page Should Contain Element ${xpath_add_role_group_button}
62
63
64Verify Existence Of All Checkboxes In LDAP Page
65 [Documentation] Verify existence of all checkboxes in LDAP page.
66 [Tags] Verify_Existence_Of_All_Checkboxes_In_LDAP_Page
67
68 # Checkboxes under settings section.
69 Page Should Contain Element ${xpath_enable_ldap_checkbox}
70 Page Should Contain Element ${xpath_secure_ldap_checkbox}
71
72
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050073Verify LDAP Configurations Editable
74 [Documentation] Verify LDAP configurations are editable.
75 [Tags] Verify_LDAP_Configurations_Editable
76
Anves Kumar rayankula010efe62021-06-09 09:00:58 -050077 Create LDAP Configuration ${LDAP_SERVER_URI} ${LDAP_TYPE} ${LDAP_BIND_DN}
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050078 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN}
79 Wait Until Page Contains Element ${xpath_ldap_url}
80 Textfield Value Should Be ${xpath_ldap_url} ${LDAP_SERVER_URI}
81 Textfield Value Should Be ${xpath_ldap_bind_dn} ${LDAP_BIND_DN}
82 Textfield Value Should Be ${xpath_ldap_password} ${empty}
83 Textfield Value Should Be ${xpath_ldap_base_dn} ${LDAP_BASE_DN}
84
85
Anves Kumar rayankula47892a22021-03-26 03:57:02 -050086Verify Create LDAP Configuration
87 [Documentation] Verify created LDAP configuration.
George Keishingd6a77972022-01-31 12:50:29 -060088 [Tags] Verify_Create_LDAP_Configuration
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050089 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login
Anves Kumar rayankula47892a22021-03-26 03:57:02 -050090
91 Create LDAP Configuration
92 Get LDAP Configuration ${LDAP_TYPE}
Anves Kumar rayankula010efe62021-06-09 09:00:58 -050093 Redfish.Logout
Anves Kumar rayankula47892a22021-03-26 03:57:02 -050094 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Anves Kumar rayankula298b6842021-05-24 04:25:19 -050095
96
97Verify LDAP Config Update With Incorrect LDAP IP Address
98 [Documentation] Verify that LDAP login fails with incorrect LDAP IP Address.
99 [Tags] Verify_LDAP_Config_Update_With_Incorrect_LDAP_IP_Address
100 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login
101
102 Create LDAP Configuration ${incorrect_ip} ${LDAP_TYPE} ${LDAP_BIND_DN}
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500103 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN} ${LDAP_MODE}
Anves Kumar rayankula298b6842021-05-24 04:25:19 -0500104
105 Get LDAP Configuration ${LDAP_TYPE}
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500106 Redfish.Logout
Anves Kumar rayankula298b6842021-05-24 04:25:19 -0500107
108 ${resp}= Run Keyword And Return Status
109 ... Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
110 Should Be Equal ${resp} ${False}
111 ... msg=LDAP user was able to login though the incorrect LDAP IP Address.
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500112
Anves Kumar rayankula95752762021-04-06 05:14:55 -0500113
114Verify LDAP Service Disable
115 [Documentation] Verify that LDAP user cannot login when LDAP service is disabled.
116 [Tags] Verify_LDAP_Service_Disable
Anves Kumar rayankula298b6842021-05-24 04:25:19 -0500117 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login
Anves Kumar rayankula95752762021-04-06 05:14:55 -0500118
119 ${status}= Run Keyword And Return Status
120 ... Checkbox Should Be Selected ${xpath_enable_ldap_checkbox}
121
122 Run Keyword If ${status} == ${True}
123 ... Click Element At Coordinates ${xpath_enable_ldap_checkbox} 0 0
124
125 Checkbox Should Not Be Selected ${xpath_enable_ldap_checkbox}
126 Click Element ${xpath_ldap_save_settings}
127 Wait Until Page Contains Successfully saved Open LDAP settings
128 Click Element ${xpath_refresh_button}
129 Wait Until Page Contains Element ${xpath_ldap_heading}
Anves Kumar rayankula298b6842021-05-24 04:25:19 -0500130 Redfish.Logout
Anves Kumar rayankula95752762021-04-06 05:14:55 -0500131
Anves Kumar rayankula298b6842021-05-24 04:25:19 -0500132 ${resp}= Run Keyword And Return Status
133 ... Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Anves Kumar rayankula95752762021-04-06 05:14:55 -0500134 Should Be Equal ${resp} ${False}
135 ... msg=LDAP user was able to login even though the LDAP service was disabled.
Anves Kumar rayankula95752762021-04-06 05:14:55 -0500136
137
Anves Kumar rayankulab44c9572021-04-27 00:44:06 -0500138Verify LDAP User With Admin Privilege
139 [Documentation] Verify that LDAP user with administrator privilege is able to do BMC reboot.
140 [Tags] Verify_LDAP_User_With_Admin_Privilege
141 [Teardown] Run Keywords Redfish.Login AND Delete LDAP Role Group ${GROUP_NAME}
142
143 Update LDAP Configuration with LDAP User Role And Group ${GROUP_NAME} ${GROUP_PRIVILEGE}
144 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
145 Redfish OBMC Reboot (off)
146 Redfish.Logout
147
148
Anves Kumar rayankula454b7912021-06-21 06:54:23 -0500149Verify Enabling LDAP
150 [Documentation] Verify that LDAP can be enabled from disabled state.
151 [Tags] Verify_Enabling_LDAP
152
153 Disable LDAP Configuration
154 Create LDAP Configuration
155
156
Anves Kumar rayankula272acf42021-06-23 01:51:24 -0500157Read Network Configuration Via Different User Roles And Verify Using GUI
158 [Documentation] Read network configuration via different user roles and verify.
159 [Tags] Read_Network_Configuration_Via_Different_User_Roles_And_Verify_Using_GUI
160 [Template] Update LDAP User Role And Read Network Configuration Via GUI
161
162 # group_name user_role valid_status_code
163 ${GROUP_NAME} Administrator ${HTTP_OK}
164 ${GROUP_NAME} Operator ${HTTP_OK}
165 ${GROUP_NAME} ReadOnly ${HTTP_OK}
166 ${GROUP_NAME} NoAccess ${HTTP_FORBIDDEN}
167
168
Priya Sinhac1294c92022-08-02 00:33:02 -0500169Verify LDAP Login Fails On Wrong LDAP Port
170 [Documentation] Verify that LDAP login fails when wrong port is entered in LDAP URL.
171 [Tags] Verify_LDAP_Login_Fails_On_Wrong_LDAP_Port
172 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login
173
174 ${ldap_uri_wrong_port}= Catenate SEPARATOR=: ${LDAP_SERVER_URI} ${wrong_ldap_port}
175 Create LDAP Configuration ${ldap_uri_wrong_port} ${LDAP_TYPE} ${LDAP_BIND_DN}
176 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN} ${LDAP_MODE}
177
178 Get LDAP Configuration ${LDAP_TYPE}
179 Redfish.Logout
180
181 ${resp}= Run Keyword And Return Status
182 ... Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
183 Should Be Equal ${resp} ${False}
184 ... msg=LDAP user was able to login though the wrong port in LDAP URL
185
Sushma M Mef474f42020-07-29 16:25:39 -0500186*** Keywords ***
187
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500188Suite Setup Execution
Sushma M Mef474f42020-07-29 16:25:39 -0500189 [Documentation] Do test case setup tasks.
190
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500191 Launch Browser And Login GUI
192
Rahul Maheshwari142642d2021-08-24 00:00:15 -0500193 # Navigate to https://xx.xx.xx.xx/#/security-and-access/ldap LDAP page.
194 Click Element ${xpath_secuity_and_accesss_menu}
Sushma M Mef474f42020-07-29 16:25:39 -0500195 Click Element ${xpath_ldap_sub_menu}
196 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain ldap
Sweta Potthurifd889f52021-08-17 02:45:12 -0500197 Wait Until Element Is Enabled ${xpath_enable_ldap_checkbox} timeout=10s
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500198
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500199 Valid Value LDAP_TYPE valid_values=["ActiveDirectory", "LDAP"]
200 Valid Value LDAP_USER
201 Valid Value LDAP_USER_PASSWORD
202 Valid Value GROUP_PRIVILEGE
203 Valid Value GROUP_NAME
204 Valid Value LDAP_SERVER_URI
205 Valid Value LDAP_BIND_DN_PASSWORD
206 Valid Value LDAP_BIND_DN
207 Valid Value LDAP_BASE_DN
208 Valid Value LDAP_MODE valid_values=["secure", "nonsecure"]
209
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500210
211Create LDAP Configuration
212 [Documentation] Create LDAP configuration.
213 [Arguments] ${ldap_server_uri}=${LDAP_SERVER_URI} ${ldap_servicetype}=${LDAP_TYPE}
214 ... ${ldap_bind_dn}=${LDAP_BIND_DN} ${ldap_bind_dn_password}=${LDAP_BIND_DN_PASSWORD}
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500215 ... ${ldap_base_dn}=${LDAP_BASE_DN} ${ldap_mode}=${LDAP_MODE}
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500216
217 # Description of argument(s):
218 # ldap_server_uri LDAP server uri (e.g. ldap://XX.XX.XX.XX).
219 # ldap_type The LDAP type ("ActiveDirectory" or "LDAP").
220 # ldap_bind_dn The LDAP bind distinguished name.
221 # ldap_bind_dn_password The LDAP bind distinguished name password.
222 # ldap_base_dn The LDAP base distinguished name.
223
Sweta Potthurifd889f52021-08-17 02:45:12 -0500224 # Clearing existing LDAP configuration by disabling it.
225 Redfish.Patch ${REDFISH_BASE_URI}AccountService
226 ... body={'${LDAP_TYPE}': {'ServiceEnabled': ${False}}}
227
228 # Wait for GUI to reflect LDAP disabled status.
229 Run Keywords Refresh GUI AND Sleep 10s
230
231 Click Element ${xpath_enable_ldap_checkbox}
232 ${radio_buttons}= Get WebElements ${xpath_service_radio_button}
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500233
Anves Kumar rayankula30a62452021-05-17 00:27:21 -0500234 Run Keyword If '${ldap_service_type}' == 'LDAP'
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500235 ... Click Element At Coordinates ${radio_buttons}[${0}] 0 0
236 ... ELSE Click Element At Coordinates ${radio_buttons}[${1}] 0 0
237
238 Wait Until Page Contains Element ${xpath_ldap_url}
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500239 Run Keyword If '${ldap_mode}' == 'secure'
240 ... Click Element At Coordinates ${xpath_secure_ldap_checkbox} 0 0
Anves Kumar rayankula010efe62021-06-09 09:00:58 -0500241
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500242 Input Text ${xpath_ldap_url} ${ldap_server_uri}
243 Input Text ${xpath_ldap_bind_dn} ${ldap_bind_dn}
244 Input Text ${xpath_ldap_password} ${ldap_bind_dn_password}
245 Input Text ${xpath_ldap_base_dn} ${ldap_base_dn}
246 Click Element ${xpath_ldap_save_settings}
247
Anves Kumar rayankula30a62452021-05-17 00:27:21 -0500248 Run Keyword If '${ldap_service_type}'=='LDAP'
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500249 ... Wait Until Page Contains Successfully saved Open LDAP settings
250 ... ELSE
251 ... Wait Until Page Contains Successfully saved Active Directory settings
252
253 Click Element ${xpath_refresh_button}
254 Wait Until Page Contains Element ${xpath_ldap_heading}
255
256
257Get LDAP Configuration
258 [Documentation] Retrieve LDAP Configuration.
259 [Arguments] ${ldap_type}
260
261 # Description of argument(s):
Anves Kumar rayankula30a62452021-05-17 00:27:21 -0500262 # ldap_type The LDAP type ("ActiveDirectory" or "LDAP").
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500263
264 ${radio_buttons}= Get WebElements ${xpath_service_radio_button}
265
266 ${status}= Run Keyword And Return Status
Anves Kumar rayankula30a62452021-05-17 00:27:21 -0500267 ... Run Keyword If '${ldap_type}'=='LDAP'
Anves Kumar rayankula47892a22021-03-26 03:57:02 -0500268 ... Checkbox Should Be Selected ${radio_buttons}[${0}]
269 ... ELSE
270 ... Checkbox Should Be Selected ${radio_buttons}[${1}]
271 Should Be Equal ${status} ${True}
Anves Kumar rayankulab44c9572021-04-27 00:44:06 -0500272
273
274Update LDAP Configuration With LDAP User Role And Group
275 [Documentation] Update LDAP configuration update with LDAP user role and group.
276 [Arguments] ${group_name} ${group_privilege}
277
278 # Description of argument(s):
279 # group_name The group name of LDAP user.
280 # group_privilege The group privilege for LDAP user
281 # (e.g. "Administrator", "Operator", "ReadOnly" or "NoAcccess").
282
283 Create LDAP Configuration
284 Click Element ${xpath_add_role_group_button}
285 Input Text ${xpath_add_group_name} ${group_name}
286 Select From List By Value ${xpath_add_group_Privilege} ${group_privilege}
287 Click Element ${xpath_add_privilege_button}
288
289 # Verify group name after adding.
290 ${ldap_group_name}= Get LDAP Privilege And Group Name Via Redfish
291 List Should Contain Value ${ldap_group_name} ${group_name}
292
293
294Delete LDAP Role Group
295 [Documentation] Delete LDAP role group.
296 [Arguments] ${group_name}
297
298 # Description of argument(s):
299 # group_name The group name of LDAP user.
300
301 # Verify given group name is exist before deleting.
302 ${ldap_group_name}= Get LDAP Privilege And Group Name Via Redfish
303 List Should Contain Value ${ldap_group_name} ${group_name} msg=${group_name} not available.
304
305 ${get_groupname_index}= Get Index From List ${ldap_group_name} ${group_name}
306 ${delete_group_elements}= Get WebElements ${xpath_delete_group_button}
307 Click Element ${delete_group_elements}[${get_groupname_index}]
308 Click Element ${xpath_delete_button}
309
310 # Verify group name after deleting.
311 ${ldap_group_name}= Get LDAP Privilege And Group Name Via Redfish
312 List Should Not Contain Value ${ldap_group_name} ${group_name} msg=${group_name} not available.
Anves Kumar rayankula454b7912021-06-21 06:54:23 -0500313
314
315Disable LDAP Configuration
316 [Documentation] Disable LDAP configuration on BMC.
317
318 ${status}= Run Keyword And Return Status
319 ... Checkbox Should Be Selected ${xpath_enable_ldap_checkbox}
320
321 Run Keyword If ${status} == ${True}
322 ... Click Element At Coordinates ${xpath_enable_ldap_checkbox} 0 0
323
324 Checkbox Should Not Be Selected ${xpath_enable_ldap_checkbox}
325 Click Element ${xpath_ldap_save_settings}
326 Wait Until Page Contains Successfully saved Open LDAP settings
327 Click Element ${xpath_refresh_button}
328 Wait Until Page Contains Element ${xpath_ldap_heading}
329
Anves Kumar rayankula272acf42021-06-23 01:51:24 -0500330
331Login BMC And Navigate To LDAP Page
332 [Documentation] Login BMC and navigate to ldap page.
333 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
334
335 # Description of argument(s):
336 # username The username to be used for login.
337 # password The password to be used for login.
338
339 Login GUI ${username} ${password}
Rahul Maheshwari142642d2021-08-24 00:00:15 -0500340 # Navigate to https://xx.xx.xx.xx/#/security-and-access/ldap LDAP page.
341 Click Element ${xpath_secuity_and_accesss_menu}
Anves Kumar rayankula272acf42021-06-23 01:51:24 -0500342 Click Element ${xpath_ldap_sub_menu}
343 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain ldap
344
345
346Update LDAP User Role And Read Network Configuration Via GUI
347 [Documentation] Update LDAP user role and read network configuration via GUI.
348 [Arguments] ${group_name} ${user_role} ${valid_status_codes}
349 [Teardown] Run Keywords Logout GUI AND Login BMC And Navigate To LDAP Page
350 ... AND Delete LDAP Role Group ${group_name}
351
352 # Description of argument(s):
353 # group_privilege The group privilege ("Administrator", "Operator", "ReadOnly" or "NoAccess").
354 # group_name The group name of user.
355 # valid_status_code The expected valid status code.
356
357
358 Update LDAP Configuration with LDAP User Role And Group ${group_name} ${user_role}
359 Logout GUI
360 Login GUI ${LDAP_USER} ${LDAP_USER_PASSWORD}
361 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
362
363 Click Element ${xpath_server_configuration}
364 Click Element ${xpath_select_network_settings}
365 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain network-settings
366
367 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} valid_status_codes=[${valid_status_codes}]
368 Return From Keyword If ${valid_status_codes} == ${HTTP_FORBIDDEN}
369
370 ${host_name}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
371 Textfield Value Should Be ${xpath_hostname_input} ${host_name}
372
373 ${mac_address}= Redfish.Get Attribute ${REDFISH_NW_ETH0_URI} MACAddress
374 Textfield Value Should Be ${xpath_mac_address_input} ${mac_address}
Priya Sinhac1294c92022-08-02 00:33:02 -0500375