Debian Codegraph @

dirsrvtests/tests/suites/webui/database/database_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2023 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8 #
9 import logging
10 import time
11 import subprocess
12 import pytest
13
14 from lib389.cli_idm.account import *
15 from lib389.tasks import *
16 from lib389.utils import *
17 from lib389.pwpolicy import PwPolicyManager
18 from test389.topologies import topology_st
19 from .. import setup_page, check_frame_assignment, setup_login
20
21 pytestmark = pytest.mark.skipif(os.getenv('WEBUI') is None, reason="These tests are only for WebUI environment")
22 pytest.importorskip('playwright')
23
24 SERVER_ID = 'standalone1'
25
26
27 def test_database_tab_availability(topology_st, page, browser_name):
28 """ Test Database tab visibility
29
30 :id: 863863e0-4ba7-4309-8f56-e6719cdf2bbe
31 :setup: Standalone instance
32 :steps:
33 1. Click on Database tab.
34 2. Check if Limits tab under Global Database Configuration is visible.
35 :expectedresults:
36 1. Success
37 2. Element is visible
38 """
39 setup_login(page)
40 time.sleep(1)
41 frame = check_frame_assignment(page, browser_name)
42
43 log.info('Check if database tab contents are loaded.')
44 frame.get_by_role('tab', name='Database', exact=True).click()
45 frame.get_by_role('tab', name='Limits').wait_for()
46 assert frame.get_by_role('tab', name='Limits').is_visible()
47
48
49 def test_global_database_configuration_availability(topology_st, page, browser_name):
50 """ Test Global Database Configuration tabs visibility
51
52 :id: d0efda45-4e8e-4703-b9c0-ab53249dafc3
53 :setup: Standalone instance
54 :steps:
55 1. Click on Database tab, click on Limits tab and check if ID List Scan Limit label is visible.
56 2. Click on Database Cache tab and check if Automatic Cache Tuning checkbox is visible.
57 3. Click on Import Cache tab and check if Automatic Import Cache Tuning checkbox is visible.
58 4. Click on NDN Cache tab and check if Normalized DN Cache Max Size label is visible.
59 5. Click on Database Locks tab and check if Enable DB Lock Monitoring checkbox is visible.
60 6. Click on Advanced Settings and check if Transaction Logs Directory input field is visible.
61 :expectedresults:
62 1. Element is visible
63 2. Element is visible
64 3. Element is visible
65 4. Element is visible
66 5. Element is visible
67 6. Element is visible
68 """
69 setup_login(page)
70 time.sleep(1)
71 frame = check_frame_assignment(page, browser_name)
72 instance = topology_st.standalone
73
74 if instance.get_db_lib() == 'mdb':
75 log.info('Check if element on Limits tab is loaded.')
76 frame.get_by_role('tab', name='Database', exact=True).click()
77
78 frame.get_by_role('tab', name='Database Size', exact=True).click()
79 frame.get_by_text('Database Maximum Size', exact=True).wait_for()
80 assert frame.get_by_text('Database Maximum Size', exact=True).is_visible()
81
82 frame.get_by_role('tab', name='Limits', exact=True).click()
83 frame.get_by_text('ID List Scan Limit', exact=True).wait_for()
84 assert frame.get_by_text('ID List Scan Limit', exact=True).is_visible()
85
86 log.info('Click on NDN Cache tab and check if element is loaded')
87 frame.get_by_role('tab', name='NDN Cache', exact=True).click()
88 assert frame.get_by_text('Normalized DN Cache Max Size').is_visible()
89
90 log.info('Click on Advanced Settings tab and check if element is loaded')
91 frame.get_by_role('tab', name='Advanced Settings', exact=True).click()
92 assert frame.locator('#dbhomedir').is_visible()
93 elif instance.get_db_lib() == 'bdb':
94 log.info('Check if element on Limits tab is loaded.')
95 frame.get_by_role('tab', name='Database', exact=True).click()
96 frame.get_by_text('ID List Scan Limit', exact=True).wait_for()
97 assert frame.get_by_text('ID List Scan Limit', exact=True).is_visible()
98
99 log.info('Click on Database Cache tab and check if element is loaded')
100 frame.get_by_role('tab', name='Database Cache', exact=True).click()
101 assert frame.locator('#db_cache_auto').is_visible()
102
103 log.info('Click on Import Cache tab and check if element is loaded')
104 frame.get_by_role('tab', name='Import Cache', exact=True).click()
105 assert frame.locator('#import_cache_auto').is_visible()
106
107 log.info('Click on NDN Cache tab and check if element is loaded')
108 frame.get_by_role('tab', name='NDN Cache', exact=True).click()
109 assert frame.get_by_text('Normalized DN Cache Max Size').is_visible()
110
111 log.info('Click on Database Locks tab and check if element is loaded')
112 frame.get_by_role('tab', name='Database Locks', exact=True).click()
113 assert frame.locator('#dblocksMonitoring').is_visible()
114
115 log.info('Click on Advanced Settings tab and check if element is loaded')
116 frame.get_by_role('tab', name='Advanced Settings', exact=True).click()
117 assert frame.locator('#txnlogdir').is_visible()
118
119
120 def test_chaining_configuration_availability(topology_st, page, browser_name):
121 """ Test Chaining Configuration settings visibility
122
123 :id: 1f936968-d2fc-4fee-beeb-caeeb5df8c3f
124 :setup: Standalone instance
125 :steps:
126 1. Click on Database tab, click on Chaining Configuration button on the side panel.
127 2. Check if Size Limit input field is visible.
128 3. Click on Controls & Components tab and check if Forwarded LDAP Controls heading is visible.
129 :expectedresults:
130 1. Success
131 2. Element is visible
132 3. Element is visible
133 """
134 setup_login(page)
135 time.sleep(1)
136 frame = check_frame_assignment(page, browser_name)
137
138 log.info('Click on Chaining Configuration and check if element is loaded.')
139 frame.get_by_role('tab', name='Database', exact=True).click()
140 frame.locator('#chaining-config').click()
141 frame.locator('#chaining-page').wait_for()
142 frame.locator('#defSizeLimit').wait_for()
143 assert frame.locator('#defSizeLimit').is_visible()
144
145 log.info('Click on Controls & Components tab and check if element is loaded')
146 frame.get_by_role('tab', name='Controls & Components').click()
147 assert frame.get_by_role('heading', name='Forwarded LDAP Controls').is_visible()
148
149
150 def test_backups_and_ldifs_availability(topology_st, page, browser_name):
151 """ Test Backups & LDIFs settings visibility.
152
153 :id: 90571e96-f3c9-4bec-83d6-04c61e8a0e78
154 :setup: Standalone instance
155 :steps:
156 1. Click on Database tab, click on Backups & LDIFs button on the side panel.
157 2. Check if Create Backup button is visible.
158 3. Click on LDIFs tab and check if Create LDIF button is visible.
159 :expectedresults:
160 1. Success
161 2. Element is visible
162 3. Element is visible
163 """
164 setup_login(page)
165 time.sleep(1)
166 frame = check_frame_assignment(page, browser_name)
167
168 log.info('Click on Backups & LDIFs button and check if element is loaded.')
169 frame.get_by_role('tab', name='Database', exact=True).click()
170 frame.locator('#backups').click()
171 assert frame.get_by_role('button', name='Create Backup').is_visible()
172
173 log.info('Click on LDIFs tab and check if element is loaded.')
174 frame.get_by_role('tab', name='LDIFs').click()
175 assert frame.get_by_role('button', name='Create LDIF').is_visible()
176
177
178 def test_global_policy_availability(topology_st, page, browser_name):
179 """ Check if Global Policy settings is visible
180
181 :id: 2bdd219d-c28d-411d-9758-18386f472ad2
182 :setup: Standalone instance
183 :steps:
184 1. Click on Database tab, click on Global Policy button on the side panel.
185 2. Check if Password Minimum Age input field is visible.
186 3. Click on Expiration tab and click on Enforce Password Expiration checkbox.
187 4. Check if Allowed Logins After Password Expires input field is visible.
188 5. Click on Account Lockout tab and click on Enable Account Lockout checkbox.
189 6. Check if Number of Failed Logins That Locks Out Account input field is visible.
190 7. Click on Syntax Checking tab and click on Enable Password Syntax Checking checkbox.
191 8. Check if Minimum Length input field is visible.
192 9. Click on Temporary Password Rules tab and check if Password Max Use input field is visible.
193 :expectedresults:
194 1. Success
195 2. Element is visible
196 3. Success
197 4. Element is visible
198 5. Success
199 6. Element is visible
200 7. Success
201 8. Element is visible
202 9. Element is visible
203 """
204 setup_login(page)
205 time.sleep(1)
206 frame = check_frame_assignment(page, browser_name)
207
208 log.info('Click on Global Policy button and check if element is loaded.')
209 frame.get_by_role('tab', name='Database', exact=True).click()
210 frame.locator('#pwpolicy').click()
211 frame.locator('#passwordminage').wait_for()
212 assert frame.locator('#passwordminage').is_visible()
213
214 log.info('Click on Expiration tab and check if element is loaded.')
215 frame.get_by_role('tab', name='Expiration').click()
216 frame.get_by_text('Enforce Password Expiration').click()
217 assert frame.locator('#passwordgracelimit').is_visible()
218
219 log.info('Click on Account Lockout tab and check if element is loaded.')
220 frame.get_by_role('tab', name='Account Lockout').click()
221 frame.get_by_text('Enable Account Lockout').click()
222 assert frame.locator('#passwordmaxfailure').is_visible()
223
224 log.info('Click on Syntax Checking tab and check if element is loaded.')
225 frame.get_by_role('tab', name='Syntax Checking').click()
226 frame.get_by_text('Enable Password Syntax Checking').click()
227 assert frame.locator('#passwordminlength').is_visible()
228
229 log.info('Click on Temporary Password Rules tab and check if element is loaded.')
230 frame.get_by_role('tab', name='Temporary Password Rules').click()
231 assert frame.locator('#passwordtprmaxuse').is_visible()
232
233
234 def test_local_policy_availability(topology_st, page, browser_name):
235 """ Test Local Policies settings visibility
236
237 :id: f540e0fa-a4c6-4c88-b97a-d21ada68f627
238 :setup: Standalone instance
239 :steps:
240 1. Click on Database tab, click on Local Policies button on side panel.
241 2. Check if Local Password Policies columnheader is visible.
242 3. Click on Edit Policy tab and check if Please choose a policy from the Local Policy Table heading is visible.
243 4. Click on Create A Policy tab and check if Target DN input field is visible.
244 :expectedresults:
245 1. Success
246 2. Element is visible
247 3. Element is visible
248 4. Element is visible
249 """
250 setup_login(page)
251 time.sleep(1)
252 frame = check_frame_assignment(page, browser_name)
253
254 log.info('Click on Local Policies button and check if element is loaded.')
255 frame.get_by_role('tab', name='Database', exact=True).click()
256 frame.locator('#localpwpolicy').click()
257 frame.get_by_role('columnheader', name='Local Password Policies').wait_for()
258 assert frame.get_by_role('columnheader', name='Local Password Policies').is_visible()
259
260 log.info('Click on Edit Policy tab and check if element is loaded.')
261 frame.get_by_role('tab', name='Edit Policy').click()
262 assert frame.get_by_role('heading', name='Please choose a policy from the Local Policy Table.').is_visible()
263
264 log.info('Click on Create A Policy tab and check if element is loaded.')
265 frame.get_by_role('tab', name='Create A Policy').click()
266 assert frame.locator('#policyDN').is_visible()
267
268
269 def test_suffixes_policy_availability(topology_st, page, browser_name):
270 """ Test Suffixes settings visibility
271
272 :id: b8399229-3b98-46d7-af15-f5ff0bcc6be9
273 :setup: Standalone instance
274 :steps:
275 1. Click on Database tab, click on dc=example,dc=com button.
276 2. Check if Entry Cache Size input field is visible.
277 3. Click on Referrals tab and check if Referrals columnheader is visible.
278 4. Click on Indexes tab and check if Database Indexes-sub tab is visible.
279 5. Click on VLV Indexes and check if VLV Indexes columnheader is visible.
280 6. Click on Encrypted Attributes and check if Encrypted Attribute columnheader is visible.
281 :expectedresults:
282 1. Success
283 2. Element is visible
284 3. Element is visible
285 4. Element is visible
286 5. Element is visible
287 6. Element is visible
288 """
289 setup_login(page)
290 time.sleep(1)
291 frame = check_frame_assignment(page, browser_name)
292
293 log.info('Click on Suffixes and check if element is loaded.')
294 frame.get_by_role('tab', name='Database', exact=True).click()
295 frame.locator(r'#dc\=example\,dc\=com').click()
296 frame.locator('#cachememsize').wait_for()
297 assert frame.locator('#cachememsize').is_visible()
298
299 log.info('Click on Referrals tab and check if element is loaded.')
300 frame.get_by_role('tab', name='Referrals').click()
301 frame.get_by_role('columnheader', name='Referrals').wait_for()
302 assert frame.get_by_role('columnheader', name='Referrals').is_visible()
303
304 log.info('Click on Indexes tab and check if element is loaded.')
305 frame.get_by_role('tab', name='Indexes', exact=True).click()
306 frame.get_by_role('tab', name='Database Indexes').wait_for()
307 assert frame.get_by_role('tab', name='Database Indexes').is_visible()
308
309 log.info('Click on VLV Indexes tab and check if element is loaded.')
310 frame.get_by_role('tab', name='VLV Indexes').click()
311 frame.get_by_role('columnheader', name='VLV Indexes').wait_for()
312 assert frame.get_by_role('columnheader', name='VLV Indexes').is_visible()
313
314 log.info('Click on Encrypted Attributes tab and check if element is loaded.')
315 frame.get_by_role('tab', name='Encrypted Attributes').click()
316 frame.get_by_role('columnheader', name='Encrypted Attribute').wait_for()
317 assert frame.get_by_role('columnheader', name='Encrypted Attribute').is_visible()
318
319
320 def test_dictionary_check_checkbox(topology_st, page, browser_name):
321 """ Test that Dictionary Check checkbox in WebUI is changed after cli command
322
323 :id: e1dcac6d-df45-4a89-a1f2-b18c65dfecba
324 :setup: Standalone instance
325 :steps:
326 1. Enable PasswordDictCheck through cli.
327 2. Open Database tab, Global Password Policies and click on Syntax Checking tab.
328 3. Check that Dictionary Check checkbox is checked.
329 4. Disable PasswordDictCheck through cli.
330 5. Reload Syntax Checking tab.
331 6. Check that Dictionary Check checkbox is unchecked.
332 :expectedresults:
333 1. Success
334 2. Success
335 3. Dictionary Check checkbox is checked
336 4. Success
337 5. Success
338 6. Dictionary Check checkbox is unchecked
339 """
340 log.info('Enable password syntax checking and enable dictionary check.')
341 ppm = PwPolicyManager(topology_st.standalone)
342 ppm.set_global_policy({"passworddictcheck": "on"})
343
344 setup_login(page)
345 time.sleep(1)
346 frame = check_frame_assignment(page, browser_name)
347
348 log.info('Click on Database tab, click on Global Policy, '
349 'click on Syntax Checking and check that Dictionary Check checkbox is checked.')
350 frame.get_by_role('tab', name='Database', exact=True).click()
351 frame.locator('#pwpolicy').click()
352 frame.get_by_role('tab', name='Syntax Checking').click()
353 frame.get_by_text('Enable Password Syntax Checking').click()
354 assert frame.get_by_text('Dictionary Check').is_checked()
355
356 log.info('Disable dictionary check, reload tab and check that Dictionary Check checkbox is unchecked.')
357 ppm.set_global_policy({"passworddictcheck": "off"})
358 ppm.set_global_policy({"passwordchecksyntax": "on"})
359 frame.get_by_role('button', name="Refresh global password policy settings").click()
360 assert not frame.get_by_text('Dictionary Check').is_checked()
361
362
363 if __name__ == '__main__':
364 # Run isolated
365 # -s for DEBUG mode
366 CURRENT_FILE = os.path.realpath(__file__)
367 pytest.main("-s %s" % CURRENT_FILE)