Debian Codegraph @

dirsrvtests/tests/suites/indexes/regression_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2022 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 time
10 import os
11 import pytest
12 import ldap
13 import logging
14 import glob
15 import re
16 from lib389.backend import Backend, Backends, DatabaseConfig
17 from lib389.cli_ctl.dblib import DbscanHelper
18 from lib389.config import LDBMConfig
19 from lib389._constants import DEFAULT_BENAME, DEFAULT_SUFFIX, PW_DM, SER_ROOT_DN, SER_ROOT_PW
20 from lib389.cos import CosClassicDefinition, CosTemplate
21 from lib389.dbgen import dbgen_users
22 from lib389.dirsrv_log import DirsrvErrorLog
23 from lib389.idm.domain import Domain
24 from lib389.idm.group import Groups
25 from lib389.idm.nscontainer import nsContainer
26 from lib389.idm.user import UserAccount, UserAccounts
27 from lib389.index import Index
28 from lib389._mapped_object import DSLdapObject, DSLdapObjects
29 from lib389.plugins import MemberOfPlugin
30 from lib389.properties import TASK_WAIT
31 from lib389.tasks import Tasks, Task
32 from test389.topologies import topology_st as topo
33 from lib389.utils import ds_is_older
34
35 pytestmark = pytest.mark.tier1
36
37 SUFFIX2 = 'dc=example2,dc=com'
38 BENAME2 = 'be2'
39 CN_INDEX_DN = f'cn=cn,cn=index,cn={DEFAULT_BENAME},cn=ldbm database,cn=plugins,cn=config'
40
41 DEBUGGING = os.getenv("DEBUGGING", default=False)
42 logging.getLogger(__name__).setLevel(logging.INFO)
43 log = logging.getLogger(__name__)
44
45
46 @pytest.fixture(scope="function")
47 def add_backend_and_ldif_50K_users(request, topo):
48 """
49 Add an empty backend and associated 50K users ldif file
50 """
51
52 tasks = Tasks(topo.standalone)
53 import_ldif = f'{topo.standalone.ldifdir}/be2_50K_users.ldif'
54 be2 = Backend(topo.standalone)
55 be2.create(properties={
56 'cn': BENAME2,
57 'nsslapd-suffix': SUFFIX2,
58 },
59 )
60
61 def fin():
62 nonlocal be2
63 if not DEBUGGING:
64 be2.delete()
65
66 request.addfinalizer(fin)
67 parent = f'ou=people,{SUFFIX2}'
68 dbgen_users(topo.standalone, 50000, import_ldif, SUFFIX2, generic=True, parent=parent)
69 assert tasks.importLDIF(
70 suffix=SUFFIX2,
71 input_file=import_ldif,
72 args={TASK_WAIT: True}
73 ) == 0
74
75 return import_ldif
76
77
78 @pytest.fixture(scope="function")
79 def add_a_group_with_users(request, topo):
80 """
81 Add a group and users, which are members of this group.
82 """
83 groups = Groups(topo.standalone, DEFAULT_SUFFIX, rdn=None)
84 group = groups.create(properties={'cn': 'test_group'})
85 users_list = []
86 users_num = 100
87 users = UserAccounts(topo.standalone, DEFAULT_SUFFIX, rdn=None)
88 for num in range(users_num):
89 USER_NAME = f'test_{num}'
90 user = users.create(properties={
91 'uid': USER_NAME,
92 'sn': USER_NAME,
93 'cn': USER_NAME,
94 'uidNumber': f'{num}',
95 'gidNumber': f'{num}',
96 'description': f'Description for {USER_NAME}',
97 'homeDirectory': f'/home/{USER_NAME}'
98 })
99 users_list.append(user)
100 group.add_member(user.dn)
101
102 def fin():
103 """
104 Removes group and users.
105 """
106 # If the server crashed, start it again to do the cleanup
107 if not topo.standalone.status():
108 topo.standalone.start()
109 if not DEBUGGING:
110 for user in users_list:
111 user.delete()
112 group.delete()
113
114 request.addfinalizer(fin)
115
116
117 @pytest.fixture(scope="function")
118 def set_small_idlistscanlimit(request, topo):
119 """
120 Set nsslapd-idlistscanlimit to a smaller value to accelerate the reproducer
121 """
122 db_cfg = DatabaseConfig(topo.standalone)
123 old_idlistscanlimit = db_cfg.get_attr_vals_utf8('nsslapd-idlistscanlimit')
124 db_cfg.set([('nsslapd-idlistscanlimit', '100')])
125 topo.standalone.restart()
126
127 def fin():
128 """
129 Set nsslapd-idlistscanlimit back to the default value
130 """
131 # If the server crashed, start it again to do the cleanup
132 if not topo.standalone.status():
133 topo.standalone.start()
134 db_cfg.set([('nsslapd-idlistscanlimit', old_idlistscanlimit)])
135 topo.standalone.restart()
136
137 request.addfinalizer(fin)
138
139
140 @pytest.fixture(scope="function")
141 def set_description_index(request, topo, add_a_group_with_users):
142 """
143 Set some description values and description index without reindexing.
144 """
145 inst = topo.standalone
146 backends = Backends(inst)
147 backend = backends.get(DEFAULT_BENAME)
148 indexes = backend.get_indexes()
149 attr = 'description'
150
151 def fin(always=False):
152 if always or not DEBUGGING:
153 try:
154 idx = indexes.get(attr)
155 idx.delete()
156 except ldap.NO_SUCH_OBJECT:
157 pass
158
159 request.addfinalizer(fin)
160 fin(always=True)
161 index = indexes.create(properties={
162 'cn': attr,
163 'nsSystemIndex': 'false',
164 'nsIndexType': ['eq', 'pres', 'sub']
165 })
166 # Restart needed with lmdb (to open the dbi handle)
167 inst.restart()
168 return (indexes, attr)
169
170
171 @pytest.fixture(scope="function")
172 def homeDirectory_index_cleanup(request, topo):
173 """
174 Ensure homeDirectory index is not present at start and end of test
175 """
176 inst = topo.standalone
177 backends = Backends(inst)
178 backend = backends.get(DEFAULT_BENAME)
179 indexes = backend.get_indexes()
180
181 try:
182 idx = indexes.get('homeDirectory')
183 idx.delete()
184 except ldap.NO_SUCH_OBJECT:
185 pass
186
187 def cleanup():
188 try:
189 idx = indexes.get('homeDirectory')
190 idx.delete()
191 except ldap.NO_SUCH_OBJECT:
192 pass
193
194 request.addfinalizer(cleanup)
195
196
197 def check_dbi(dbsh, attr_name, expected = True, lowercase=False):
198 dbsh.resync()
199 # mdb dbi names are always lowercase while bdb names are case sensitive
200 if dbsh.dblib == 'mdb':
201 lowercase=True
202 try:
203 dbi = dbsh.get_dbi(attr_name)
204 except KeyError:
205 dbi = None
206 log.info(f'Found dbi {dbi} for attribute {attr_name}. (expected={expected})')
207 if expected:
208 assert dbi is not None
209 if lowercase:
210 assert attr_name.lower() in dbi
211 assert attr_name not in dbi
212 else:
213 assert attr_name.lower() not in dbi
214 assert attr_name in dbi
215 else:
216 assert dbi is None
217
218
219 class PersonPosix(DSLdapObject):
220 def __init__(self, instance, dn=None):
221 super(PersonPosix, self).__init__(instance, dn)
222 self._rdn_attribute = 'cn'
223 self._must_attributes = [ 'uid', 'cn', 'sn', 'uidNumber', 'gidNumber', 'homeDirectory' ]
224 self._create_objectclasses = ['person', 'posixAccount', 'top']
225 self._protected = False
226
227 def bind(self, password=None, *args, **kwargs):
228 inst_clone = self._instance.clone({SER_ROOT_DN: self.dn, SER_ROOT_PW: password})
229 inst_clone.open(*args, **kwargs)
230 return inst_clone
231
232
233 class PersonPosixs(DSLdapObjects):
234 def __init__(self, instance, basedn):
235 super(PersonPosixs, self).__init__(instance)
236 self._objectclasses = ['person', 'posixAccount', 'top']
237 self._filterattrs = None
238 self._childobject = PersonPosix
239 self._basedn = basedn
240
241
242 class PersonOrg(DSLdapObject):
243 def __init__(self, instance, dn=None):
244 super(PersonOrg, self).__init__(instance, dn)
245 self._rdn_attribute = 'cn'
246 self._must_attributes = [ 'cn', 'sn' ]
247 self._create_objectclasses = ['person', 'nsOrgPerson', 'top']
248 self._protected = False
249
250
251 class PersonOrgs(DSLdapObjects):
252 def __init__(self, instance, basedn):
253 super(PersonOrgs, self).__init__(instance)
254 self._objectclasses = ['person', 'nsOrgPerson', 'top']
255 self._filterattrs = None
256 self._childobject = PersonOrg
257 self._basedn = basedn
258
259
260 @pytest.fixture(scope="function")
261 def add_some_entries(topo, request):
262 inst = topo.standalone
263 added_entries = []
264 e1 = PersonPosixs(inst, DEFAULT_SUFFIX)
265 e2 = PersonOrgs(inst, DEFAULT_SUFFIX)
266 # It is easier to add aci to all entries than to modify the suffix aci then revert it later
267 aci='(targetattr="*")(version 3.0; acl "Enable anyone ou read"; allow (read, search, compare)(userdn="ldap:///anyone");)'
268
269 for idx in range(100):
270 p1 = {
271 'cn': f'p1_{idx}',
272 'sn': 'foo',
273 'uid': f'uid1_{idx}',
274 'uidNumber': str(1000+idx),
275 'gidNumber': str(1000+idx),
276 'homeDirectory': f'/home/uid1_{idx}',
277 'userPassword': PW_DM,
278 'aci': aci,
279 }
280 p2 = {
281 'cn': f'p2_{idx}',
282 'sn': f'sn2_{idx}',
283 'aci': aci,
284 }
285 added_entries.append(e1.create(properties=p1))
286 added_entries.append(e2.create(properties=p2))
287 for idx in range(3):
288 p3 = {
289 'cn': f'p3_{idx}',
290 'sn': 'foo',
291 'uid': f'uid3_{idx}',
292 'aci': aci,
293 }
294 added_entries.append(e2.create(properties=p3))
295
296 # Prepare finalizer
297 def fin():
298 for e in added_entries:
299 e.delete()
300
301 if not DEBUGGING:
302 request.addfinalizer(fin)
303
304 return added_entries
305
306
307 @pytest.mark.skipif(ds_is_older("1.4.4.4"), reason="Not implemented")
308 def test_reindex_task_creates_abandoned_index_file(topo):
309 """
310 Recreating an index for the same attribute but changing
311 the case of for example 1 letter, results in abandoned indexfile
312
313 :id: 07ae5274-481a-4fa8-8074-e0de50d89ac6
314 :customerscenario: True
315 :setup: Standalone instance
316 :steps:
317 1. Create a user object with additional attributes:
318 objectClass: mozillaabpersonalpha
319 mozillaCustom1: xyz
320 2. Add an index entry mozillacustom1
321 3. Reindex the backend
322 4. Check the content of the index (after it has been flushed to disk) mozillacustom1.db
323 5. Remove the index
324 6. Notice the mozillacustom1.db is removed
325 7. Recreate the index but now use the exact case as mentioned in the schema
326 8. Reindex the backend
327 9. Check the content of the index (after it has been flushed to disk) mozillaCustom1.db
328 10. Check that an ldapsearch does not return a result (mozillacustom1=xyz)
329 11. Check that an ldapsearch returns the results (mozillaCustom1=xyz)
330 12. Restart the instance
331 13. Notice that an ldapsearch does not return a result(mozillacustom1=xyz)
332 14. Check that an ldapsearch does not return a result (mozillacustom1=xyz)
333 15. Check that an ldapsearch returns the results (mozillaCustom1=xyz)
334 16. Reindex the backend
335 17. Notice the second indexfile for this attribute
336 18. Check the content of the index (after it has been flushed to disk) no mozillacustom1.db
337 19. Check the content of the index (after it has been flushed to disk) mozillaCustom1.db
338 :expectedresults:
339 1. Should Success.
340 2. Should Success.
341 3. Should Success.
342 4. Should Success.
343 5. Should Success.
344 6. Should Success.
345 7. Should Success.
346 8. Should Success.
347 9. Should Success.
348 10. Should Success.
349 11. Should Success.
350 12. Should Success.
351 13. Should Success.
352 14. Should Success.
353 15. Should Success.
354 16. Should Success.
355 17. Should Success.
356 18. Should Success.
357 19. Should Success.
358 """
359
360 inst = topo.standalone
361 attr_name = "mozillaCustom1"
362 attr_value = "xyz"
363
364 users = UserAccounts(inst, DEFAULT_SUFFIX)
365 user = users.create_test_user()
366 user.add("objectClass", "mozillaabpersonalpha")
367 user.add(attr_name, attr_value)
368
369 backends = Backends(inst)
370 backend = backends.get(DEFAULT_BENAME)
371 indexes = backend.get_indexes()
372 index = indexes.create(properties={
373 'cn': attr_name.lower(),
374 'nsSystemIndex': 'false',
375 'nsIndexType': ['eq', 'pres']
376 })
377
378 backend.reindex()
379 time.sleep(3)
380 dbsh = DbscanHelper(inst)
381 check_dbi(dbsh, attr_name,lowercase=True)
382 index.delete()
383 check_dbi(dbsh, attr_name, expected=False)
384
385 index = indexes.create(properties={
386 'cn': attr_name,
387 'nsSystemIndex': 'false',
388 'nsIndexType': ['eq', 'pres']
389 })
390
391 backend.reindex()
392 time.sleep(3)
393 check_dbi(dbsh, attr_name)
394
395 entries = inst.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, f"{attr_name}={attr_value}")
396 assert len(entries) > 0
397 inst.restart()
398 entries = inst.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, f"{attr_name}={attr_value}")
399 assert len(entries) > 0
400
401 backend.reindex()
402 time.sleep(3)
403 check_dbi(dbsh, attr_name)
404
405
406 def test_unindexed_internal_search_crashes_server(topo, add_a_group_with_users, set_small_idlistscanlimit):
407 """
408 An internal unindexed search was able to crash the server due to missing logging function.
409
410 :id: 2d0e4070-96d6-46e5-b2c8-9495925e3e87
411 :customerscenario: True
412 :setup: Standalone instance
413 :steps:
414 1. Add a group with users
415 2. Change nsslapd-idlistscanlimit to a smaller value to accelerate the reproducer
416 3. Enable memberOf plugin
417 4. Restart the instance
418 5. Run memberOf fixup task
419 6. Wait for the task to complete
420 :expectedresults:
421 1. Should succeed
422 2. Should succeed
423 3. Should succeed
424 4. Should succeed
425 5. Should succeed
426 6. Server should not crash
427 """
428 inst = topo.standalone
429 memberof = MemberOfPlugin(inst)
430 memberof.enable()
431 inst.restart()
432 task = memberof.fixup(DEFAULT_SUFFIX)
433 task.wait()
434 assert inst.status()
435
436
437 def test_reject_virtual_attr_for_indexing(topo):
438 """Reject trying to add an index for a virtual attribute (nsrole and COS)
439
440 :id: 0fffa7a8-aaec-44d6-bdbc-93cf4b197b56
441 :customerscenario: True
442 :setup: Standalone instance
443 :steps:
444 1. Create COS
445 2. Adding index for nsRole is rejected
446 3. Adding index for COS attribute is rejected
447 :expectedresults:
448 1. Success
449 2. Success
450 3. Success
451 """
452 # Create COS: add container, create template, and definition
453 nsContainer(topo.standalone, f'cn=cosClassicTemplates,{DEFAULT_SUFFIX}').create(properties={'cn': 'cosClassicTemplates'})
454 properties = {'employeeType': 'EngType',
455 'cn': '"cn=filterRoleEngRole,dc=example,dc=com",cn=cosClassicTemplates,dc=example,dc=com'
456 }
457 CosTemplate(topo.standalone,
458 'cn="cn=filterRoleEngRole,dc=example,dc=com",cn=cosClassicTemplates,{}'.format(
459 DEFAULT_SUFFIX)) \
460 .create(properties=properties)
461 properties = {'cosTemplateDn': 'cn=cosClassicTemplate,{}'.format(DEFAULT_SUFFIX),
462 'cosAttribute': 'employeeType',
463 'cosSpecifier': 'nsrole',
464 'cn': 'cosClassicGenerateEmployeeTypeUsingnsrole'}
465 CosClassicDefinition(topo.standalone, 'cn=cosClassicGenerateEmployeeTypeUsingnsrole,{}'.format(DEFAULT_SUFFIX)) \
466 .create(properties=properties)
467
468 # Test nsrole and cos attribute
469 be_insts = Backends(topo.standalone).list()
470 for be in be_insts:
471 if be.get_attr_val_utf8_l('nsslapd-suffix') == DEFAULT_SUFFIX:
472 # Attempt to add nsRole as index
473 with pytest.raises(ValueError):
474 be.add_index('nsrole', ['eq'])
475 # Attempt to add COS attribute as index
476 with pytest.raises(ValueError):
477 be.add_index('employeeType', ['eq'])
478 break
479
480
481 def test_reject_ns_index_type_comma_packed_value(topo):
482 """Reject nsIndexType given as one comma-packed value
483
484 Types must be separate attribute values (e.g. ``eq`` and ``pres``), not ``eq,pres``.
485
486 :id: 92295258-d0f4-41d0-8a38-675e2e5ee450
487 :setup: Standalone instance
488 :steps:
489 1. MOD_ADD nsIndexType ``eq,pres`` on the ``cn`` index entry
490 :expectedresults:
491 1. ldap.UNWILLING_TO_PERFORM
492 """
493 cn_index = Index(topo.standalone, CN_INDEX_DN)
494 with pytest.raises(ldap.UNWILLING_TO_PERFORM):
495 cn_index.set('nsIndexType', 'eq,pres', action=ldap.MOD_ADD)
496
497
498 def test_task_status(topo):
499 """Check that finished tasks have both a status and exit code
500
501 :id: 56d03656-79a6-11ee-bfc3-482ae39447e5
502 :setup: Standalone instance
503 :steps:
504 1. Start a Reindex task on 'cn' and wait until it is completed
505 2. Check that task has a status
506 3. Check that exit code is 0
507 4. Start a Reindex task on 'badattr' and wait until it is completed
508 5. Check that task has a status
509 6. Check that exit code is 0
510 :expectedresults:
511 1. Success
512 2. Success
513 3. Success
514 4. Success
515 5. Success
516 6. Success
517 """
518
519 tasks = Tasks(topo.standalone)
520 # completed reindex tasks MUST have a status because freeipa check it.
521
522 # Reindex 'cn'
523 tasks.reindex(
524 suffix=DEFAULT_SUFFIX,
525 attrname='cn',
526 args={TASK_WAIT: True}
527 )
528 reindex_task = Task(topo.standalone, tasks.dn)
529 assert reindex_task.status()
530 assert reindex_task.get_exit_code() == 0
531
532 # Reindex 'badattr'
533 tasks.reindex(
534 suffix=DEFAULT_SUFFIX,
535 attrname='badattr',
536 args={TASK_WAIT: True}
537 )
538 reindex_task = Task(topo.standalone, tasks.dn)
539 assert reindex_task.status()
540 # Bad attribute are skipped without setting error code
541 assert reindex_task.get_exit_code() == 0
542
543
544 def count_keys(inst, bename, attr, prefix=''):
545 indexfile = os.path.join(inst.dbdir, bename, attr + '.db')
546 # (bdb - we should also accept a version number for .db suffix)
547 for f in glob.glob(f'{indexfile}*'):
548 indexfile = f
549
550 inst.stop()
551 output = inst.dbscan(None, None, args=['-f', indexfile, '-A'], stopping=False).decode()
552 inst.start()
553 count = 0
554 regexp = f'^KEY: {re.escape(prefix)}'
555 for match in re.finditer(regexp, output, flags=re.MULTILINE):
556 count += 1
557 log.info(f"count_keys found {count} keys starting with '{prefix}' in {indexfile}")
558 return count
559
560
561 def test_reindex_task_with_type(topo, set_description_index):
562 """Check that reindex task works as expected when index type is specified.
563
564 :id: 0c7f2fda-69f6-11ef-9eb8-083a88554478
565 :setup: Standalone instance
566 - with 100 users having description attribute
567 - with description:eq,pres,sub index entry but not yet reindexed
568 :steps:
569 1. Set description in suffix entry
570 2. Count number of equality keys in description index
571 3. Start a Reindex task on description:eq,pres and wait for completion
572 4. Check the task status and exit code
573 5. Count the equality, presence and substring keys in description index
574 6. Start a Reindex task on description and wait for completion
575 7. Check the task status and exit code
576 8. Count the equality, presence and substring keys in description index
577
578 :expectedresults:
579 1. Success
580 2. Should be either no key (bdb) or a single one (lmdb)
581 3. Success
582 4. Success
583 5. Should have: more equality keys than in step 2
584 one presence key
585 some substrings keys
586 6. Success
587 7. Success
588 8. Should have same counts than in step 5
589 """
590 (indexes, attr) = set_description_index
591 inst = topo.standalone
592 if not inst.is_dbi_supported():
593 pytest.skip('This test requires that dbscan supports -A option')
594 # modify indexed value
595 Domain(inst, DEFAULT_SUFFIX).replace(attr, f'test_before_reindex')
596
597 keys1 = count_keys(inst, DEFAULT_BENAME, attr, prefix='=')
598 assert keys1 <= 1
599
600 tasks = Tasks(topo.standalone)
601 # completed reindex tasks MUST have a status because freeipa check it.
602
603 # Reindex attr with eq,pres types
604 log.info(f'Reindex {attr} with eq,pres types')
605 tasks.reindex(
606 suffix=DEFAULT_SUFFIX,
607 attrname=f'{attr}:eq,pres',
608 args={TASK_WAIT: True}
609 )
610 reindex_task = Task(topo.standalone, tasks.dn)
611 assert reindex_task.status()
612 assert reindex_task.get_exit_code() == 0
613
614 keys2e = count_keys(inst, DEFAULT_BENAME, attr, prefix='=')
615 keys2p = count_keys(inst, DEFAULT_BENAME, attr, prefix='+')
616 keys2s = count_keys(inst, DEFAULT_BENAME, attr, prefix='*')
617 assert keys2e > keys1
618 assert keys2p > 0
619 assert keys2s > 0
620
621 # Reindex attr without types
622 log.info(f'Reindex {attr} without types')
623 tasks.reindex(
624 suffix=DEFAULT_SUFFIX,
625 attrname=attr,
626 args={TASK_WAIT: True}
627 )
628 reindex_task = Task(topo.standalone, tasks.dn)
629 assert reindex_task.status()
630 assert reindex_task.get_exit_code() == 0
631
632 keys3e = count_keys(inst, DEFAULT_BENAME, attr, prefix='=')
633 keys3p = count_keys(inst, DEFAULT_BENAME, attr, prefix='+')
634 keys3s = count_keys(inst, DEFAULT_BENAME, attr, prefix='*')
635 assert keys3e == keys2e
636 assert keys3p == keys2p
637 assert keys3s == keys2s
638
639
640 def test_task_and_be(topo, add_backend_and_ldif_50K_users):
641 """Check that backend is writable after finishing a tasks
642
643 :id: 047869da-7a4d-11ee-895c-482ae39447e5
644 :setup: Standalone instance + a second backend with 50K users
645 :steps:
646 1. Start an Import task and wait until it is completed
647 2. Modify the suffix entry description
648 3. Start a Reindex task on all attributes and wait until it is completed
649 4. Modify the suffix entry description
650 5. Start an Export task and wait until it is completed
651 6. Modify the suffix entry description
652 :expectedresults:
653 1. Success
654 2. Success
655 3. Success
656 4. Success
657 5. Success
658 6. Success
659 """
660
661 tasks = Tasks(topo.standalone)
662 user = UserAccount(topo.standalone, f'uid=user00001,ou=people,{SUFFIX2}')
663 ldif_file = add_backend_and_ldif_50K_users
664
665 # Import
666 tasks.importLDIF(
667 suffix=SUFFIX2,
668 input_file=ldif_file,
669 args={TASK_WAIT: True}
670 ) == 0
671 descval = 'test_task_and_be tc1'
672 user.set('description', descval)
673 assert user.get_attr_val_utf8_l('description') == descval
674
675 # Reindex some attributes
676 assert tasks.reindex(
677 suffix=SUFFIX2,
678 attrname=[ 'description', 'rdn', 'uid', 'cn', 'sn', 'badattr' ],
679 args={TASK_WAIT: True}
680 ) == 0
681 descval = 'test_task_and_be tc2'
682 user.set('description', descval)
683 assert user.get_attr_val_utf8_l('description') == descval
684 users = UserAccounts(topo.standalone, SUFFIX2, rdn=None)
685 user = users.create(properties={
686 'uid': 'user1',
687 'sn': 'user1',
688 'cn': 'user1',
689 'uidNumber': '1001',
690 'gidNumber': '1001',
691 'homeDirectory': '/home/user1'
692 })
693
694 # Export
695 assert tasks.exportLDIF(
696 suffix=SUFFIX2,
697 output_file=f'{ldif_file}2',
698 args={TASK_WAIT: True}
699 ) == 0
700 descval = 'test_task_and_be tc3'
701 user.set('description', descval)
702 assert user.get_attr_val_utf8_l('description') == descval
703
704
705 def test_reindex_extended_matching_rule(topo, add_backend_and_ldif_50K_users):
706 """Check that index with extended matching rule are reindexed properly.
707
708 :id: 8a3198e8-cc5a-11ef-a3e7-482ae39447e5
709 :setup: Standalone instance + a second backend with 50K users
710 :steps:
711 1. Configure uid with 2.5.13.2 matching rule
712 1. Configure cn with 2.5.13.2 matching rule
713 2. Reindex
714 :expectedresults:
715 1. Success
716 2. Success
717 """
718
719 inst = topo.standalone
720 tasks = Tasks(inst)
721 be2 = Backends(topo.standalone).get_backend(SUFFIX2)
722 index = be2.get_index('uid')
723 index.replace('nsMatchingRule', '2.5.13.2')
724 index = be2.get_index('cn')
725 index.replace('nsMatchingRule', '2.5.13.2')
726
727 assert tasks.reindex(
728 suffix=SUFFIX2,
729 args={TASK_WAIT: True}
730 ) == 0
731
732
733 def test_update_eq_index_after_deleting_and_readding_attribute_in_one_step(topo):
734 """ Test that 'eq' index is properly updated
735 when deleting and re-adding an attribute in one step
736
737 :id: d306b511-01bd-4400-96fa-9838a310f086
738 :setup: Standalone instance
739 :steps:
740 1. Create a user with a 3 valued attribute (mail)
741 2. Modify the user in one step: delete two mail attribute values and re-add one of the values back
742 3. Search for an entry using deleted value as filter
743 4. Search for an entry using the re-added value as filter
744 5. Delete all mail attribute values
745 6. Search for an entry using the re-added value as filter
746 7. Search for an entry using 'mail=*' as a filter
747 8. Re-add two values for mail attribute in order to test with different amount of original values
748 9. Rerun modification in step 2
749 10. Search for an entry using deleted value as filter
750 11. Search for an entry using the re-added value as filter
751 :expectedresults:
752 1. Success
753 2. Success
754 3. No entry found
755 4. Original user found
756 5. Success
757 6. No entry found
758 7. No entry found
759 8. Success
760 9. Success
761 10. No entry found
762 11. Original user found
763 """
764
765 rdn = 'user0099'
766 name = 'Test User'
767 users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
768 user = users.create(properties={
769 'uid': rdn,
770 'sn': rdn,
771 'cn': rdn,
772 'uidNumber': '10099',
773 'gidNumber': '10099',
774 'givenname': name,
775 'gecos': name,
776 'description': name,
777 'homeDirectory': '/home/{}'.format(rdn),
778 'mail': ['{}@dev.null'.format(rdn),
779 '[email protected]',
780 '{}@redhat.com'.format(rdn)]
781 })
782
783 #
784 # Remove mail values and re-add one of them in the same step
785 #
786 try:
787 user.apply_mods([(ldap.MOD_DELETE, 'mail', b'[email protected]'),
788 (ldap.MOD_DELETE, 'mail', b'[email protected]'),
789 (ldap.MOD_ADD, 'mail', b'[email protected]')])
790 except ldap.LDAPError as e:
791 log.fatal('Failed to modify user: {}'.format(e))
792 assert False
793
794 #
795 # Search using deleted attribute value - no entries should be returned
796 #
797 try:
798 entry = user.search(filter='[email protected]')
799 if entry:
800 log.fatal('Entry incorrectly returned')
801 assert False
802 except ldap.LDAPError as e:
803 log.fatal('Failed to search for user: {}'.format(e))
804 assert False
805
806 #
807 # Search using existing attribute value - the entry should be returned
808 #
809 try:
810 entry = user.search(filter='[email protected]')
811 if not entry:
812 log.fatal('Entry not found, but it should have been')
813 assert False
814 except ldap.LDAPError as e:
815 log.fatal('Failed to search for user: {}'.format(e))
816 assert False
817
818 #
819 # Delete the last values
820 #
821 try:
822 user.remove_all('mail')
823 except ldap.LDAPError as e:
824 log.fatal('Failed to modify user: {}'.format(e))
825 assert False
826
827 #
828 # Search using deleted attribute value - no entries should be returned
829 #
830 try:
831 entry = user.search(filter='[email protected]')
832 if entry:
833 log.fatal('Entry incorrectly returned')
834 assert False
835 except ldap.LDAPError as e:
836 log.fatal('Failed to search for user: {}'.format(e))
837 assert False
838
839 #
840 # Make sure presence index is correctly updated - no entries should be
841 # returned
842 #
843 try:
844 entry = user.search(filter='mail=*')
845 if entry:
846 log.fatal('Entry incorrectly returned')
847 assert False
848 except ldap.LDAPError as e:
849 log.fatal('Failed to search for user: {}'.format(e))
850 assert False
851
852 #
853 # Now add the attributes back, and lets run a set of tests with
854 # a different number of attributes
855 #
856 try:
857 user.add('mail', [b'[email protected]', b'[email protected]'])
858 except ldap.LDAPError as e:
859 log.fatal('Failed to modify user: {}'.format(e))
860 assert False
861
862 #
863 # Remove and re-add some attributes
864 #
865 try:
866 user.apply_mods([(ldap.MOD_DELETE, 'mail', b'[email protected]'),
867 (ldap.MOD_DELETE, 'mail', b'[email protected]'),
868 (ldap.MOD_ADD, 'mail', b'[email protected]')])
869 except ldap.LDAPError as e:
870 log.fatal('Failedto modify user: {}'.format(e))
871 assert False
872
873 #
874 # Search using deleted attribute value - no entries should be returned
875 #
876 try:
877 entry = user.search(filter='[email protected]')
878 if entry:
879 log.fatal('Entry incorrectly returned')
880 assert False
881 except ldap.LDAPError as e:
882 log.fatal('Failed to search for user: {}'.format(e))
883 assert False
884
885 #
886 # Search using existing attribute value - the entry should be returned
887 #
888 try:
889 entry = user.search(filter='[email protected]')
890 if not entry:
891 log.fatal('Entry not found, but it should have been')
892 assert False
893 except ldap.LDAPError as e:
894 log.fatal('Failed to search for user: {}'.format(e))
895 assert False
896
897
898 def test_concurrent_modifications_during_indexing(topo, homeDirectory_index_cleanup):
899 """Test that concurrent modifications are rejected during index rebuilding
900
901 :id: 1df16d5a-1b92-46b7-8435-876b87545748
902 :setup: Standalone Instance
903 :steps:
904 1. Create homeDirectory index with substring matching
905 2. Create 100 users with large homeDirectory values to slow down indexing
906 3. Start an indexing task WITHOUT waiting for its completion
907 4. Monitor task status and verify modifications are rejected with UNWILLING_TO_PERFORM
908 5. Verify modifications work once indexing is complete
909 :expectedresults:
910 1. Index configuration succeeds
911 2. Users are successfully created
912 3. Indexing task starts
913 4. Modifications return UNWILLING_TO_PERFORM while indexing is in progress
914 5. Modifications succeed once indexing is complete
915 """
916
917 inst = topo.standalone
918
919 backends = Backends(inst)
920 backend = backends.get(DEFAULT_BENAME)
921 indexes = backend.get_indexes()
922
923 log.info("Creating homeDirectory index")
924 index = indexes.create(properties={
925 'cn': 'homeDirectory',
926 'nsSystemIndex': 'false',
927 'nsMatchingRule': ['caseIgnoreIA5Match', 'caseExactIA5Match'],
928 'nsIndexType': ['eq', 'sub', 'pres']
929 })
930
931 inst.restart()
932
933 log.info("Creating 100 users with large homeDirectory values")
934 users = UserAccounts(inst, DEFAULT_SUFFIX)
935 test_users = []
936 home_value = 'x' * (32 * 1024)
937
938 for i in range(100):
939 user_name = f'testuser{i}'
940 user = users.create(properties={
941 'uid': user_name,
942 'cn': user_name,
943 'sn': f'_{user_name}',
944 'uidNumber': str(1000 + i),
945 'gidNumber': str(2000 + i),
946 'homeDirectory': home_value
947 })
948 test_users.append(user)
949
950 log.info("Starting indexing task without waiting for completion")
951 tasks = Tasks(inst)
952 tasks.reindex(
953 suffix=DEFAULT_SUFFIX,
954 attrname='homeDirectory',
955 args={TASK_WAIT: False}
956 )
957
958 reindex_task = Task(inst, tasks.dn)
959
960 finish_pattern = re.compile(r".*Finished indexing.*")
961 max_attempts = 20
962 unwilling_to_perform_seen = False
963
964 for attempt in range(max_attempts):
965 log.info(f"Monitoring task status, attempt {attempt + 1}/{max_attempts}")
966
967 try:
968 task_status = reindex_task.status()
969 if task_status:
970 log.info(f"Task status: {task_status}")
971 is_finished = finish_pattern.search(task_status)
972 else:
973 log.info("Task status: NO STATUS")
974 is_finished = False
975
976 if not is_finished:
977 try:
978 test_users[0].replace('sn', f'modified_{attempt}')
979 log.info("Modification succeeded - indexing might have just finished")
980 final_status = reindex_task.status()
981 if final_status and finish_pattern.search(final_status):
982 log.info("Confirmed: indexing just finished")
983 break
984 else:
985 log.info("Unexpected: modification succeeded but indexing not finished")
986 except ldap.UNWILLING_TO_PERFORM:
987 log.info("Expected UNWILLING_TO_PERFORM during indexing")
988 unwilling_to_perform_seen = True
989 else:
990 test_users[0].replace('sn', f'final_modification_{attempt}')
991 log.info("Modification succeeded after indexing completed")
992 break
993
994 except ldap.NO_SUCH_OBJECT:
995 log.info("Task completed and cleaned up")
996 break
997
998 time.sleep(3)
999
1000 if unwilling_to_perform_seen:
1001 log.info("Successfully observed UNWILLING_TO_PERFORM during indexing")
1002 else:
1003 log.info("Indexing completed too quickly to observe UNWILLING_TO_PERFORM")
1004
1005 test_users[0].replace('sn', 'final_test')
1006 assert test_users[0].get_attr_val_utf8('sn') == 'final_test'
1007
1008 log.info("Cleaning up test data")
1009 for user in test_users:
1010 user.delete()
1011
1012
1013 @pytest.fixture(scope="function")
1014 def homeDirectory_setup(request, topo, homeDirectory_index_cleanup):
1015 """ Create test entries and index for homeDirectory"""
1016 log.info("Add POSIX users with per-entry homeDirectory values")
1017 users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
1018 user_list = []
1019 for cpt in range(20):
1020 name = f"new_account{cpt}"
1021 u = users.create(properties={
1022 'uid': name,
1023 'cn': name,
1024 'sn': name,
1025 'uidNumber': f'1{cpt}',
1026 'gidNumber': f'2{cpt}',
1027 'homeDirectory': f"/home/{name}_{cpt}",
1028 })
1029 user_list.append(u)
1030
1031 backends = Backends(topo.standalone)
1032 backend = backends.get(DEFAULT_BENAME)
1033 indexes = backend.get_indexes()
1034 index = indexes.create(properties={
1035 'cn': 'homeDirectory',
1036 'nsSystemIndex': 'false',
1037 'nsIndexType': 'eq'
1038 })
1039
1040 def fin():
1041 for user in user_list:
1042 user.delete()
1043 index.delete()
1044 topo.standalone.restart()
1045
1046 request.addfinalizer(fin)
1047
1048 return user_list, index
1049
1050
1051 MIXED_VALUE = "/home/mYhOmEdIrEcToRy"
1052 LOWER_VALUE = "/home/myhomedirectory"
1053
1054
1055 def setup_matching_rule(topo, index):
1056 index.replace('nsMatchingRule',
1057 ['caseIgnoreIA5Match', 'caseExactIA5Match'])
1058 topo.standalone.restart()
1059
1060 log.info("Reindex homeDirectory")
1061 tasks = Tasks(topo.standalone)
1062 assert tasks.reindex(
1063 suffix=DEFAULT_SUFFIX,
1064 attrname='homeDirectory',
1065 args={TASK_WAIT: True}
1066 ) == 0
1067
1068
1069 def _reindex_homedirectory(inst):
1070 """Run a blocking reindex task for homeDirectory on the default suffix."""
1071 tasks = Tasks(inst)
1072 assert (
1073 tasks.reindex(
1074 suffix=DEFAULT_SUFFIX,
1075 attrname="homeDirectory",
1076 args={TASK_WAIT: True},
1077 )
1078 == 0
1079 )
1080
1081
1082 def _assert_homedirectory_errlog_clean(inst):
1083 """Assert reindex did not log an unknown or invalid matching rule."""
1084 errlog = DirsrvErrorLog(inst)
1085 assert not errlog.match("unknown or invalid matching rule")
1086
1087
1088 def test_reindex_homedirectory_matching_rules(topo, homeDirectory_setup):
1089 """Reindexing homeDirectory succeeds when both caseIgnoreIA5Match and caseExactIA5Match are
1090 set on the index, with no "unknown or invalid matching rule" in the error log.
1091
1092 The homeDirectory_setup fixture creates multiple POSIX users, adds a default eq index
1093 for homeDirectory, and defers index and entry cleanup. This test then applies the dual
1094 IA5 matching rules, restarts, and runs a reindex. The log is scanned to ensure the server
1095 does not report an invalid matching rule after that configuration and reindex.
1096 Pre-existing error log content is removed first so the scan is limited to this test run.
1097
1098 :id: 48270a0b-1c2d-3e4f-5a6b-7c8d9e0f1a2b
1099 :setup: Standalone instance, homeDirectory_setup (sample users, homeDirectory index)
1100 :steps:
1101 1. Delete the instance error log files and restart the server (empty log)
1102 2. Set nsMatchingRule to caseIgnoreIA5Match and caseExactIA5Match, restart, reindex
1103 3. Scan the error log for the substring unknown or invalid matching rule
1104 :expectedresults:
1105 1. Server is back up with no prior error log lines
1106 2. Reindex task completes with return code 0; no such error line appears
1107 3. Assertion holds (no match found)
1108 """
1109
1110 _, index = homeDirectory_setup
1111
1112 log.info("Remove existing error logs so the scan is limited to reindex/matching-rule output")
1113 topo.standalone.deleteErrorLogs(restart=True)
1114
1115 setup_matching_rule(topo, index)
1116
1117 log.info("Scan error log for bad matching rule")
1118 _assert_homedirectory_errlog_clean(topo.standalone)
1119
1120
1121 def test_reindex_homedirectory_mixed_value(topo, homeDirectory_setup):
1122 """Equality and extensible filters on homeDirectory with dual IA5 matching rules and mixed
1123 storage.
1124
1125 After the same index configuration and reindex as test_reindex_homedirectory_matching_rules,
1126 one user stores a mixed-case homeDirectory value. Base-scope searches use plain equality,
1127 caseExactIA5Match (case-sensitive to the stored IA5 value), and caseIgnoreIA5Match
1128 (casefolding). A lowercased path matches caseIgnore but not caseExact or default eq when it
1129 is not the same string as stored.
1130
1131 :id: 48270b1c-2d3e-4f5a-6b7c-8d9e0f1a2b3c
1132 :setup: Standalone instance, homeDirectory_setup, then setup_matching_rule (MRs, restart, reindex)
1133 :steps:
1134 1. On new_account1, replace homeDirectory with a mixed-case path
1135 2. Base search (homeDirectory=<mixed>); expect one entry
1136 3. Base search (homeDirectory:caseExactIA5Match:=<mixed>); expect one entry
1137 4. Base search (homeDirectory=<lower>); expect no entry
1138 5. Base search (homeDirectory:caseExactIA5Match:=<lower>); expect no entry
1139 6. Base search (homeDirectory:caseIgnoreIA5Match:=<lower>); expect one entry
1140 :expectedresults:
1141 1. Success
1142 2. One entry found
1143 3. One entry found
1144 4. No entry found
1145 5. No entry found
1146 6. One entry found
1147 """
1148 user_list, index = homeDirectory_setup
1149 setup_matching_rule(topo, index)
1150
1151 target = user_list[1]
1152 log.info("Replace homeDirectory with mixed-case value")
1153 target.replace('homeDirectory', MIXED_VALUE)
1154
1155 users = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
1156
1157 log.info("Search with plain eq search")
1158 r = users.filter(f"(homeDirectory={MIXED_VALUE})")
1159 assert len(r) == 1
1160
1161 log.info("Search with caseExactIA5Match")
1162 r = users.filter(f"(homeDirectory:caseExactIA5Match:={MIXED_VALUE})")
1163 assert len(r) == 1
1164
1165 log.info("Search with lower-case value")
1166 r = users.filter(f"(homeDirectory={LOWER_VALUE})")
1167 assert len(r) == 0
1168
1169 log.info("Search with caseExactIA5Match and lower-case value")
1170 r = users.filter(f"(homeDirectory:caseExactIA5Match:={LOWER_VALUE})")
1171 assert len(r) == 0
1172
1173 log.info("Search with caseIgnoreIA5Match and lower-case value")
1174 r = users.filter(f"(homeDirectory:caseIgnoreIA5Match:={LOWER_VALUE})")
1175 assert len(r) == 1
1176
1177 log.info("Subtree search with exact stored homeDirectory value")
1178 r = users.filter(f"(homeDirectory={MIXED_VALUE})")
1179 assert len(r) == 1
1180
1181 log.info("Subtree search with caseExactIA5Match and exact stored value")
1182 r = users.filter(f"(homeDirectory:caseExactIA5Match:={MIXED_VALUE})")
1183 assert len(r) == 1
1184
1185 log.info("Subtree search with lower-case value does not match default eq")
1186 r = users.filter(f"(homeDirectory={LOWER_VALUE})")
1187 assert len(r) == 0
1188
1189 log.info("Subtree search with caseExactIA5Match and lower-case value")
1190 r = users.filter(f"(homeDirectory:caseExactIA5Match:={LOWER_VALUE})")
1191 assert len(r) == 0
1192
1193 log.info("Subtree search with caseIgnoreIA5Match and lower-case value")
1194 r = users.filter(f"(homeDirectory:caseIgnoreIA5Match:={LOWER_VALUE})")
1195 assert len(r) == 1
1196
1197
1198 def test_homedirectory_caseexactia5_reindex_after_dual_ia5(topo, homeDirectory_setup):
1199 """homeDirectory caseExactIA5Match reindex after dual IA5 index (ticket 48746).
1200
1201 Covers the full ticket 48746 sequence on one index instance: index with
1202 caseIgnoreIA5Match and caseExactIA5Match, reindex, set a mixed-case value,
1203 base-scope extensible filter search, then replace matching rules with
1204 caseExactIA5Match only and reindex without crash or invalid-MR errors.
1205
1206 :id: 17636675-0273-42cd-afdc-1511cf3a1d7e
1207 :setup: Standalone instance, homeDirectory_setup fixture
1208 :steps:
1209 1. Set nsMatchingRule to caseIgnoreIA5Match and caseExactIA5Match, reindex
1210 2. Verify the error log has no unknown or invalid matching rule
1211 3. Set a mixed-case homeDirectory on new_account1
1212 4. Base-scope search with (homeDirectory:caseExactIA5Match:=<mixed>)
1213 5. Set nsMatchingRule to caseExactIA5Match only, reindex
1214 6. Verify the error log is still clean
1215 :expectedresults:
1216 1. Reindex succeeds
1217 2. No invalid matching-rule message in the error log
1218 3. Success
1219 4. One entry is returned (server stays up)
1220 5. Reindex succeeds
1221 6. No invalid matching-rule message in the error log
1222 """
1223 user_list, index = homeDirectory_setup
1224 inst = topo.standalone
1225 target = user_list[1]
1226
1227 inst.deleteErrorLogs(restart=True)
1228
1229 log.info("Index homeDirectory with caseIgnoreIA5Match and caseExactIA5Match")
1230 setup_matching_rule(topo, index)
1231 _assert_homedirectory_errlog_clean(inst)
1232
1233 log.info("Set mixed-case homeDirectory on new_account1")
1234 target.replace("homeDirectory", MIXED_VALUE)
1235
1236 log.info(
1237 "Base-scope caseExactIA5Match search with exact stored value "
1238 "(loads filter MR before CES-only reindex)"
1239 )
1240 results = target.search(
1241 scope="base",
1242 filter=f"(homeDirectory:caseExactIA5Match:={MIXED_VALUE})",
1243 )
1244 assert len(results) == 1
1245 assert results[0].dn.lower() == target.dn.lower()
1246
1247 log.info("Reindex homeDirectory with caseExactIA5Match only")
1248 index.replace("nsMatchingRule", ["caseExactIA5Match"])
1249 inst.restart()
1250 _reindex_homedirectory(inst)
1251 _assert_homedirectory_errlog_clean(inst)
1252
1253
1254 def test_idl_range_limit(topo, add_some_entries):
1255 """Test nsslapd-rangelookthroughlimit and AND shortcut
1256
1257 :id: 746a5af2-d755-11f0-8b62-c85309d5c3e3
1258 :setup: Standalone Instance with some entries
1259 :steps:
1260 1. Set nsslapd-rangelookthroughlimit
1261 2. Open a new connection and bound it as an user
1262 3. Perform Range search that hit nsslapd-rangelookthroughlimit and AND shortcut
1263 :expectedresults:
1264 1. Success
1265 2. Success
1266 3. Success
1267 """
1268
1269 inst = topo.standalone
1270 added_entries = add_some_entries
1271
1272 dbconfig = LDBMConfig(inst)
1273 dbconfig.set('nsslapd-rangelookthroughlimit', "50")
1274
1275 conn = added_entries[0].bind(PW_DM)
1276
1277 entries = conn.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "(&(objectclass=nsOrgPerson)(sn=foo)(uid>=a))")
1278 assert len(entries) == 3
1279
1280
1281 def test_large_multivalued_sn_attribute(topo):
1282 """Test adding a user entry with 512 values for sn attribute, each 512 bytes
1283
1284 :id: 8f2a9b3c-e8d7-11ef-9a5f-482ae39447e5
1285 :setup: Standalone Instance
1286 :steps:
1287 1. Create a user with 512 sn values, each 512 bytes long
1288 2. Verify the user was created successfully
1289 3. Search for the user and verify all sn values are present
1290 4. Clean up the user entry
1291 :expectedresults:
1292 1. User is created successfully
1293 2. User entry exists
1294 3. All 512 sn values are present and have correct length
1295 4. User is deleted successfully
1296 """
1297
1298 inst = topo.standalone
1299 users = UserAccounts(inst, DEFAULT_SUFFIX)
1300
1301 log.info("Creating user with 512 sn values, each 512 bytes")
1302
1303 # Generate 512 unique sn values, each 512 bytes long
1304 # Use a pattern that makes each value unique but predictable
1305 sn_values = []
1306 for i in range(512):
1307 # Create a 512-byte value with unique identifier at the start
1308 value = f'sn_value_{i:04d}_' + 'x' * (512 - len(f'sn_value_{i:04d}_'))
1309 sn_values.append(value)
1310
1311 # Create the user with first sn value
1312 user_name = 'test_user_large_sn'
1313 user = users.create(properties={
1314 'uid': user_name,
1315 'cn': user_name,
1316 'sn': sn_values,
1317 'uidNumber': '99999',
1318 'gidNumber': '99999',
1319 'homeDirectory': f'/home/{user_name}'
1320 })
1321
1322 # Verify the entry was created and has all sn values
1323 log.info("Verifying all sn values are present")
1324 sn_attr_values = user.get_attr_vals_utf8('sn')
1325
1326 assert len(sn_attr_values) == 512, f"Expected 512 sn values, got {len(sn_attr_values)}"
1327
1328 # Verify each value has the correct length
1329 for idx, value in enumerate(sn_attr_values):
1330 assert len(value) == 512, f"sn value {idx} has length {len(value)}, expected 512"
1331
1332 log.info("Successfully created and verified user with 512 sn values of 512 bytes each")
1333
1334 # Clean up
1335 user.delete()
1336 log.info("User entry deleted successfully")
1337
1338
1339 if __name__ == "__main__":
1340 # Run isolated
1341 # -s for DEBUG mode
1342 CURRENT_FILE = os.path.realpath(__file__)
1343 pytest.main("-s %s" % CURRENT_FILE)