Debian Codegraph @

dirsrvtests/tests/suites/filter/filter_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2025 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 ldap
10 import logging
11 import pytest
12 import time
13 from ldap import SCOPE_SUBTREE
14 from lib389.dirsrv_log import DirsrvAccessLog
15 from lib389.tasks import *
16 from lib389.backend import Backends
17 from lib389.dbgen import dbgen_users, dbgen_groups
18 from test389.topologies import topology_st
19 from lib389._constants import PASSWORD, DEFAULT_SUFFIX, DN_DM, SUFFIX
20 from lib389.idm.user import UserAccount, UserAccounts
21 from lib389.utils import *
22 from lib389.config import BDB_LDBMConfig, LMDB_LDBMConfig
23
24 pytestmark = pytest.mark.tier1
25
26 logging.getLogger(__name__).setLevel(logging.DEBUG)
27 log = logging.getLogger(__name__)
28
29 ENTRY_NAME = 'test_entry'
30
31
32 def test_filter_escaped(topology_st):
33 """Test we can search for an '*' in a attribute value.
34
35 :id: 5c9aa40c-c641-4603-bce3-b19f4c1f2031
36 :setup: Standalone instance
37 :steps:
38 1. Add a test user with an '*' in its attribute value
39 i.e. 'cn=test * me'
40 2. Add another similar test user without '*' in its attribute value
41 3. Search test user using search filter "cn=*\\**"
42 :expectedresults:
43 1. This should pass
44 2. This should pass
45 3. Test user with 'cn=test * me' only, should be listed
46 """
47 log.info('Running test_filter_escaped...')
48
49 USER1_DN = 'uid=test_entry,' + DEFAULT_SUFFIX
50 USER2_DN = 'uid=test_entry2,' + DEFAULT_SUFFIX
51
52 try:
53 topology_st.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
54 'sn': '1',
55 'cn': 'test * me',
56 'uid': 'test_entry',
57 'userpassword': PASSWORD})))
58 except ldap.LDAPError as e:
59 log.fatal('test_filter_escaped: Failed to add test user ' + USER1_DN + ': error ' +
60 e.message['desc'])
61 assert False
62
63 try:
64 topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
65 'sn': '2',
66 'cn': 'test me',
67 'uid': 'test_entry2',
68 'userpassword': PASSWORD})))
69 except ldap.LDAPError as e:
70 log.fatal('test_filter_escaped: Failed to add test user ' + USER2_DN + ': error ' + e.message['desc'])
71 assert False
72
73 try:
74 entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 'cn=*\\**')
75 if not entry or len(entry) > 1:
76 log.fatal('test_filter_escaped: Entry was not found using "cn=*\\**"')
77 assert False
78 except ldap.LDAPError as e:
79 log.fatal('test_filter_escaped: Failed to search for user(%s), error: %s' %
80 (USER1_DN, e.message('desc')))
81 assert False
82
83 log.info('test_filter_escaped: PASSED')
84
85
86 def test_filter_search_original_attrs(topology_st):
87 """Search and request attributes with extra characters. The returned entry
88 should not have these extra characters: objectclass EXTRA"
89
90 :id: d30d8a1c-84ac-47ba-95f9-41e3453fbf3a
91 :setup: Standalone instance
92 :steps:
93 1. Execute a search operation for attributes with extra characters
94 2. Check the search result have these extra characters or not
95 :expectedresults:
96 1. Search should pass
97 2. Search result should not have these extra characters attribute
98 """
99
100 log.info('Running test_filter_search_original_attrs...')
101
102 try:
103 entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_BASE,
104 'objectclass=top', ['objectclass-EXTRA'])
105 if entry[0].hasAttr('objectclass-EXTRA'):
106 log.fatal('test_filter_search_original_attrs: Entry does not have the original attribute')
107 assert False
108 except ldap.LDAPError as e:
109 log.fatal('test_filter_search_original_attrs: Failed to search suffix(%s), error: %s' %
110 (DEFAULT_SUFFIX, e.message('desc')))
111 assert False
112
113 log.info('test_filter_search_original_attrs: PASSED')
114
115
116 def test_filter_scope_one(topology_st):
117 """Test ldapsearch with scope one gives only single entry
118
119 :id: cf5a6078-bbe6-4d43-ac71-553c45923f91
120 :setup: Standalone instance
121 :steps:
122 1. Search ou=services,dc=example,dc=com using ldapsearch with
123 scope one using base as dc=example,dc=com
124 2. Check that search should return only one entry
125 :expectedresults:
126 1. This should pass
127 2. This should pass
128 """
129
130 log.info('Search user using ldapsearch with scope one')
131 results = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_ONELEVEL,'ou=services',['ou'] )
132 log.info(results)
133
134 log.info('Search should only have one entry')
135 assert len(results) == 1
136
137
138 def test_filter_with_attribute_subtype(topology_st):
139 """Adds 2 test entries and Search with
140 filters including subtype and !
141
142 :id: 0e69f5f2-6a0a-480e-8282-fbcc50231908
143 :setup: Standalone instance
144 :steps:
145 1. Add 2 entries and create 3 filters
146 2. Search for entry with filter: (&(cn=test_entry en only)(!(cn=test_entry fr)))
147 3. Search for entry with filter: (&(cn=test_entry en only)(!(cn;fr=test_entry fr)))
148 4. Search for entry with filter: (&(cn=test_entry en only)(!(cn;en=test_entry en)))
149 5. Delete the added entries
150 :expectedresults:
151 1. Operation should be successful
152 2. Search should be successful
153 3. Search should be successful
154 4. Search should not be successful
155 5. Delete the added entries
156 """
157
158 # bind as directory manager
159 topology_st.standalone.log.info("Bind as %s" % DN_DM)
160 topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
161
162 # enable filter error logging
163 # mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '32')]
164 # topology_st.standalone.modify_s(DN_CONFIG, mod)
165
166 topology_st.standalone.log.info("\n\n######################### ADD ######################\n")
167
168 # Prepare the entry with cn;fr & cn;en
169 entry_name_fr = '%s fr' % (ENTRY_NAME)
170 entry_name_en = '%s en' % (ENTRY_NAME)
171 entry_name_both = '%s both' % (ENTRY_NAME)
172 entry_dn_both = 'cn=%s, %s' % (entry_name_both, SUFFIX)
173 entry_both = Entry(entry_dn_both)
174 entry_both.setValues('objectclass', 'top', 'person')
175 entry_both.setValues('sn', entry_name_both)
176 entry_both.setValues('cn', entry_name_both)
177 entry_both.setValues('cn;fr', entry_name_fr)
178 entry_both.setValues('cn;en', entry_name_en)
179
180 # Prepare the entry with one member
181 entry_name_en_only = '%s en only' % (ENTRY_NAME)
182 entry_dn_en_only = 'cn=%s, %s' % (entry_name_en_only, SUFFIX)
183 entry_en_only = Entry(entry_dn_en_only)
184 entry_en_only.setValues('objectclass', 'top', 'person')
185 entry_en_only.setValues('sn', entry_name_en_only)
186 entry_en_only.setValues('cn', entry_name_en_only)
187 entry_en_only.setValues('cn;en', entry_name_en)
188
189 topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_both,
190 entry_both))
191 topology_st.standalone.add_s(entry_both)
192
193 topology_st.standalone.log.info("Try to add Add %s: %r" % (entry_dn_en_only,
194 entry_en_only))
195 topology_st.standalone.add_s(entry_en_only)
196
197 topology_st.standalone.log.info("\n\n######################### SEARCH ######################\n")
198
199 # filter: (&(cn=test_entry en only)(!(cn=test_entry fr)))
200 myfilter = '(&(sn=%s)(!(cn=%s)))' % (entry_name_en_only, entry_name_fr)
201 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
202 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
203 assert len(ents) == 1
204 assert ensure_str(ents[0].sn) == entry_name_en_only
205 topology_st.standalone.log.info("Found %s" % ents[0].dn)
206
207 # filter: (&(cn=test_entry en only)(!(cn;fr=test_entry fr)))
208 myfilter = '(&(sn=%s)(!(cn;fr=%s)))' % (entry_name_en_only, entry_name_fr)
209 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
210 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
211 assert len(ents) == 1
212 assert ensure_str(ents[0].sn) == entry_name_en_only
213 topology_st.standalone.log.info("Found %s" % ents[0].dn)
214
215 # filter: (&(cn=test_entry en only)(!(cn;en=test_entry en)))
216 myfilter = '(&(sn=%s)(!(cn;en=%s)))' % (entry_name_en_only, entry_name_en)
217 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
218 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
219 assert len(ents) == 0
220 topology_st.standalone.log.info("Found none")
221
222 topology_st.standalone.log.info("\n\n######################### DELETE ######################\n")
223
224 topology_st.standalone.log.info("Try to delete %s " % entry_dn_both)
225 topology_st.standalone.delete_s(entry_dn_both)
226
227 topology_st.standalone.log.info("Try to delete %s " % entry_dn_en_only)
228 topology_st.standalone.delete_s(entry_dn_en_only)
229
230 log.info('Testcase PASSED')
231
232
233 def test_extended_search(topology_st):
234 """Test we can search with equality extended matching rule
235
236 :id: 396942ac-467b-435b-8d9f-e80c7ec4ba6c
237 :setup: Standalone instance
238 :steps:
239 1. Add a test user with 'sn: ext-test-entry'
240 2. Search '(cn:de:=ext-test-entry)'
241 3. Search '(sn:caseIgnoreIA5Match:=EXT-TEST-ENTRY)'
242 4. Search '(sn:caseIgnoreMatch:=EXT-TEST-ENTRY)'
243 5. Search '(sn:caseExactMatch:=EXT-TEST-ENTRY)'
244 6. Search '(sn:caseExactMatch:=ext-test-entry)'
245 7. Search '(sn:caseExactIA5Match:=EXT-TEST-ENTRY)'
246 8. Search '(sn:caseExactIA5Match:=ext-test-entry)'
247 :expectedresults:
248 1. This should pass
249 2. This should return one entry
250 3. This should return one entry
251 4. This should return one entry
252 5. This should return NO entry
253 6. This should return one entry
254 7. This should return NO entry
255 8. This should return one entry
256 """
257 log.info('Running test_filter_escaped...')
258
259 ATTR_VAL = 'ext-test-entry'
260 USER1_DN = "uid=%s,%s" % (ATTR_VAL, DEFAULT_SUFFIX)
261
262 try:
263 topology_st.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
264 'sn': ATTR_VAL.encode(),
265 'cn': ATTR_VAL.encode(),
266 'uid': ATTR_VAL.encode()})))
267 except ldap.LDAPError as e:
268 log.fatal('test_extended_search: Failed to add test user ' + USER1_DN + ': error ' +
269 e.message['desc'])
270 assert False
271
272 # filter: '(cn:de:=ext-test-entry)'
273 myfilter = '(cn:de:=%s)' % ATTR_VAL
274 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
275 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
276 assert len(ents) == 1
277
278 # filter: '(sn:caseIgnoreIA5Match:=EXT-TEST-ENTRY)'
279 myfilter = '(cn:caseIgnoreIA5Match:=%s)' % ATTR_VAL.upper()
280 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
281 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
282 assert len(ents) == 1
283
284 # filter: '(sn:caseIgnoreMatch:=EXT-TEST-ENTRY)'
285 myfilter = '(cn:caseIgnoreMatch:=%s)' % ATTR_VAL.upper()
286 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
287 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
288 assert len(ents) == 1
289
290 # filter: '(sn:caseExactMatch:=EXT-TEST-ENTRY)'
291 myfilter = '(cn:caseExactMatch:=%s)' % ATTR_VAL.upper()
292 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
293 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
294 assert len(ents) == 0
295
296 # filter: '(sn:caseExactMatch:=ext-test-entry)'
297 myfilter = '(cn:caseExactMatch:=%s)' % ATTR_VAL
298 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
299 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
300 assert len(ents) == 1
301
302 # filter: '(sn:caseExactIA5Match:=EXT-TEST-ENTRY)'
303 myfilter = '(cn:caseExactIA5Match:=%s)' % ATTR_VAL.upper()
304 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
305 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
306 assert len(ents) == 0
307
308 # filter: '(sn:caseExactIA5Match:=ext-test-entry)'
309 myfilter = '(cn:caseExactIA5Match:=%s)' % ATTR_VAL
310 topology_st.standalone.log.info("Try to search with filter %s" % myfilter)
311 ents = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, myfilter)
312 assert len(ents) == 1
313
314
315 def test_match_large_valueset(topology_st):
316 """Test that when returning a big number of entries
317 and that we need to match the filter from a large valueset
318 we get benefit to use the sorted valueset
319
320 :id: 7db5aa88-50e0-4c31-85dd-1d2072cb674c
321
322 :setup: Standalone instance
323
324 :steps:
325 1. Create a users and groups backends and tune them
326 2. Generate a test ldif (2k users and 1K groups with all users)
327 3. Import test ldif file using Offline import (ldif2db).
328 4. Prim the 'groups' entrycache with a "fast" search
329 5. Search the 'groups' with a difficult matching value
330 6. check that etime from step 5 is less than a second
331
332 :expectedresults:
333 1. Create a users and groups backends should PASS
334 2. Generate LDIF should PASS.
335 3. Offline import should PASS.
336 4. Priming should PASS.
337 5. Performance search should PASS.
338 6. Etime of performance search should PASS.
339 """
340
341 log.info('Running test_match_large_valueset...')
342 #
343 # Test online/offline LDIF imports
344 #
345 inst = topology_st.standalone
346 inst.start()
347 backends = Backends(inst)
348 users_suffix = "ou=users,%s" % DEFAULT_SUFFIX
349 users_backend = 'users'
350 users_ldif = 'users_import.ldif'
351 groups_suffix = "ou=groups,%s" % DEFAULT_SUFFIX
352 groups_backend = 'groups'
353 groups_ldif = 'groups_import.ldif'
354 groups_entrycache = '200000000'
355 users_number = 2000
356 groups_number = 1000
357
358
359 # For priming the cache we just want to be fast
360 # taking the first value in the valueset is good
361 # whether the valueset is sorted or not
362 priming_user_rdn = "user0001"
363
364 # For performance testing, this is important to use
365 # user1000 rather then user0001
366 # Because user0001 is the first value in the valueset
367 # whether we use the sorted valuearray or non sorted
368 # valuearray the performance will be similar.
369 # With middle value user1000, the performance boost of
370 # the sorted valuearray will make the difference.
371 perf_user_rdn = "user1000"
372
373 # Step 1. Prepare the backends and tune the groups entrycache
374 backends.create(properties={'parent': DEFAULT_SUFFIX,
375 'nsslapd-suffix': users_suffix,
376 'name': users_backend})
377 be_groups = backends.create(properties={'parent': DEFAULT_SUFFIX,
378 'nsslapd-suffix': groups_suffix,
379 'name': groups_backend})
380
381 # Set the entry cache to 200Mb as the 1K groups of 2K users require at
382 # least 170Mb
383 if get_default_db_lib() == "bdb":
384 config_ldbm = BDB_LDBMConfig(inst)
385 else:
386 config_ldbm = LMDB_LDBMConfig(inst)
387 config_ldbm.set('nsslapd-cache-autosize', '0')
388 be_groups.replace('nsslapd-cachememsize', groups_entrycache)
389
390 # Step 2. Generate a test ldif (10k users entries)
391 log.info("Generating users LDIF...")
392 ldif_dir = inst.get_ldif_dir()
393 users_import_ldif = "%s/%s" % (ldif_dir, users_ldif)
394 groups_import_ldif = "%s/%s" % (ldif_dir, groups_ldif)
395 dbgen_users(inst, users_number, users_import_ldif, suffix=DEFAULT_SUFFIX,
396 generic=True, parent=users_suffix)
397
398 # Generate a test ldif (800 groups with 10k members) that fit in 700Mb entry cache
399 props = {
400 "name": "group",
401 "suffix": groups_suffix,
402 "parent": groups_suffix,
403 "number": groups_number,
404 "numMembers": users_number,
405 "createMembers": False,
406 "memberParent": users_suffix,
407 "membershipAttr": "uniquemember",
408 }
409 dbgen_groups(inst, groups_import_ldif, props)
410
411 # Step 3. Do the both offline imports
412 inst.stop()
413 if not inst.ldif2db(users_backend, None, None, None, users_import_ldif):
414 log.fatal('test_basic_import_export: Offline users import failed')
415 assert False
416 if not inst.ldif2db(groups_backend, None, None, None, groups_import_ldif):
417 log.fatal('test_basic_import_export: Offline groups import failed')
418 assert False
419 inst.start()
420
421 # Step 4. first prime the cache
422 # Just request the 'DN'. We are interested by the time of matching not by the time of transfert
423 entries = topology_st.standalone.search_s(groups_suffix, ldap.SCOPE_SUBTREE, "(&(objectclass=groupOfUniqueNames)(uniquemember=uid=%s,%s))" % (priming_user_rdn, users_suffix), ['dn'])
424 assert len(entries) == groups_number
425
426 # Step 5. Now do the real performance checking it should take less than a second
427 # Just request the 'DN'. We are interested by the time of matching not by the time of transfert
428 search_start = time.time()
429 entries = topology_st.standalone.search_s(groups_suffix, ldap.SCOPE_SUBTREE, "(&(objectclass=groupOfUniqueNames)(uniquemember=uid=%s,%s))" % (perf_user_rdn, users_suffix), ['dn'])
430 duration = time.time() - search_start
431 log.info("Duration of the search was %f", duration)
432
433 # Step 6. Gather the etime from the access log
434 inst.stop()
435 access_log = DirsrvAccessLog(inst)
436 search_result = access_log.match(".*RESULT err=0 tag=101 nentries=%s.*" %
437 groups_number)
438 log.info("Found patterns are %s", search_result[0])
439 log.info("Found patterns are %s", search_result[1])
440 etime = float(search_result[1].split('etime=')[1])
441 log.info("Duration of the search from access log was %f", etime)
442 assert len(entries) == groups_number
443 assert etime < 5
444
445
446 def test_filter_not_operator(topology_st, request):
447 """Test ldapsearch with scope one gives only single entry
448
449 :id: b3711e02-7e76-444d-82f3-495c6dadd97f
450 :setup: Standalone instance
451 :steps:
452 1. Creating user1..user9
453 2. Adding specific 'telephonenumber' to the users
454 3. Check returned set (5 users) with the first filter
455 4. Check returned set (4 users) with the second filter
456 :expectedresults:
457 1. This should pass
458 2. This should pass
459 3. This should pass
460 4. This should pass
461 """
462
463 topology_st.standalone.start()
464 # Creating Users
465 log.info('Create users from user1 to user9')
466 users = UserAccounts(topology_st.standalone, "ou=people,%s" % DEFAULT_SUFFIX, rdn=None)
467
468 for user in ['user1',
469 'user2',
470 'user3',
471 'user4',
472 'user5',
473 'user6',
474 'user7',
475 'user8',
476 'user9']:
477 users.create(properties={
478 'mail': f'{user}@redhat.com',
479 'uid': user,
480 'givenName': user.title(),
481 'cn': f'bit {user}',
482 'sn': user.title(),
483 'manager': f'uid={user},{SUFFIX}',
484 'userpassword': "password",
485 'homeDirectory': '/home/' + user,
486 'uidNumber': '1000',
487 'gidNumber': '2000',
488 })
489 # Adding specific values to the users
490 log.info('Adding telephonenumber values')
491 user = UserAccount(topology_st.standalone,
492 'uid=user1, ou=people, %s' % DEFAULT_SUFFIX)
493 user.add('telephonenumber', ['1234', '2345'])
494
495 user = UserAccount(topology_st.standalone,
496 'uid=user2, ou=people, %s' % DEFAULT_SUFFIX)
497 user.add('telephonenumber', ['1234', '4567'])
498
499 user = UserAccount(topology_st.standalone,
500 'uid=user3, ou=people, %s' % DEFAULT_SUFFIX)
501 user.add('telephonenumber', ['1234', '4567'])
502
503 user = UserAccount(topology_st.standalone,
504 'uid=user4, ou=people, %s' % DEFAULT_SUFFIX)
505 user.add('telephonenumber', ['1234'])
506
507 user = UserAccount(topology_st.standalone,
508 'uid=user5, ou=people, %s' % DEFAULT_SUFFIX)
509 user.add('telephonenumber', ['2345'])
510
511 user = UserAccount(topology_st.standalone,
512 'uid=user6, ou=people, %s' % DEFAULT_SUFFIX)
513 user.add('telephonenumber', ['3456'])
514
515 user = UserAccount(topology_st.standalone,
516 'uid=user7, ou=people, %s' % DEFAULT_SUFFIX)
517 user.add('telephonenumber', ['4567'])
518
519 user = UserAccount(topology_st.standalone,
520 'uid=user8, ou=people, %s' % DEFAULT_SUFFIX)
521 user.add('telephonenumber', ['1234'])
522
523 user = UserAccount(topology_st.standalone,
524 'uid=user9, ou=people, %s' % DEFAULT_SUFFIX)
525 user.add('telephonenumber', ['1234', '4567'])
526
527 # Do a first test of filter containing a NOT
528 # and check the expected values are retrieved
529 log.info('Search with filter containing NOT')
530 log.info('expect user2, user3, user6, user8 and user9')
531 filter1 = "(|(telephoneNumber=3456)(&(telephoneNumber=1234)(!(|(uid=user1)(uid=user4)))))"
532 entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, SCOPE_SUBTREE,
533 filter1)
534 uids = []
535 for entry in entries:
536 assert entry.hasAttr('uid')
537 uids.append(entry.getValue('uid'))
538
539 assert len(uids) == 5
540 for uid in [b'user2', b'user3', b'user6', b'user8', b'user9']:
541 assert uid in uids
542
543 # Do a second test of filter containing a NOT
544 # and check the expected values are retrieved
545 log.info('Search with a second filter containing NOT')
546 log.info('expect user2, user3, user8 and user9')
547 filter1 = "(|(&(telephoneNumber=1234)(!(|(uid=user1)(uid=user4)))))"
548 entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, SCOPE_SUBTREE,
549 filter1)
550 uids = []
551 for entry in entries:
552 assert entry.hasAttr('uid')
553 uids.append(entry.getValue('uid'))
554
555 assert len(uids) == 4
556 for uid in [b'user2', b'user3', b'user8', b'user9']:
557 assert uid in uids
558
559 def fin():
560 """
561 Deletes entries after the test.
562 """
563 for user in users.list():
564 pass
565 user.delete()
566
567 request.addfinalizer(fin)
568
569
570 if __name__ == '__main__':
571 # Run isolated
572 # -s for DEBUG mode
573 CURRENT_FILE = os.path.realpath(__file__)
574 pytest.main("-s %s" % CURRENT_FILE)