Debian Codegraph @

dirsrvtests/tests/suites/slapi_memberof/basic_interface_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 pytest, os
10
11 import logging
12 import ldap
13 from lib389.backend import Backends, Backend
14 from lib389.mappingTree import MappingTrees
15 from lib389.configurations.sample import create_base_domain
16 from ldap.extop import ExtendedRequest
17 from pyasn1.type import namedtype, univ
18 from pyasn1.codec.ber import encoder, decoder
19 from lib389.utils import ensure_bytes, get_plugin_dir
20 from ldap.extop import ExtendedRequest, ExtendedResponse
21 from pyasn1.type import namedtype, univ
22 from pyasn1.codec.ber import encoder, decoder
23 from lib389 import Entry
24
25 from lib389._constants import DEFAULT_SUFFIX, PW_DM
26 from test389.topologies import topology_st as topo
27 from lib389.plugins import MemberOfPlugin
28
29 from lib389.idm.user import UserAccount, UserAccounts
30 from lib389.idm.account import Accounts
31
32 pytestmark = pytest.mark.tier0
33 log = logging.getLogger(__name__)
34
35
36 class SlapiMemberofRequestValue(univ.Sequence):
37 pass
38
39 class SlapiMemberofRequest(ExtendedRequest):
40 def __init__(self, requestValidLifeTime=0):
41 self.requestName = '2.3.4.5.113730.6.7.1'
42
43 def encodedRequestValue(self):
44 v = SlapiMemberofRequestValue()
45 return encoder.encode(v)
46
47 @pytest.fixture(scope="module")
48 def install_test_plugin(topo):
49 import subprocess
50 import shutil
51 import os
52 import sys
53 import re
54 import pdb
55 import random
56
57 current_dir = os.getcwd()
58 # create a build directory
59 build_dir="/tmp/build.%d" % (random.randint(1, 10000))
60 os.makedirs(build_dir, exist_ok=True)
61 cmd_str="chmod 755 %s" % build_dir
62 subprocess.run(cmd_str, shell=True)
63 os.chdir(build_dir)
64
65 # Retrieve the path of the workspace (from the path of the test)
66 workspace = None
67 for i in range(0, len(sys.argv)):
68 if sys.argv[i].find("slapi_memberof") > -1:
69 log.info("Workspace is: %s" % sys.argv[i])
70 workspace=re.sub("dirsrvtest.*$", "", sys.argv[i])
71 else:
72 log.info("Workspace is not: %s" % sys.argv[i])
73
74 if not workspace:
75 log.info("Fail to Retrieve from the repos containing slapi_memberof test plugin source")
76 log.info("using the current directory as workspace")
77 workspace=current_dir
78
79 # Gather the include files from 'ldap/include' and 'ldap/servers/slapd'
80 for the_include in ["portable.h", "avl.h", "ldaprot.h"]:
81 include_file="%s/ldap/include/%s" % (workspace, the_include)
82 log.info("Retrieved from the repos: %s" % include_file)
83 file_path="%s/%s" % (build_dir, the_include)
84 shutil.copy(include_file, file_path)
85 cmd_str="chmod 666 %s" % file_path
86 subprocess.run(cmd_str, shell=True)
87
88 for the_include in ["slap.h", "slapi-private.h", "slapi-plugin.h", "haproxy.h",\
89 "slapi_pal.h", "csngen.h", "uuid.h", "disconnect_errors.h",\
90 "pw.h", "filter.h", "proto-slap.h", "intrinsics.h", "slapi-plugin-compat4.h"]:
91 include_file="%s/ldap/servers/slapd/%s" % (workspace, the_include)
92 log.info("Retrieve from the repos: %s" % include_file)
93 file_path="%s/%s" % (build_dir, the_include)
94 shutil.copy(include_file, file_path)
95 cmd_str="chmod 666 %s" % file_path
96 subprocess.run(cmd_str, shell=True)
97
98 # retrieve the test plugin source
99 log.info("use the default location")
100 src_file="%s/ldap/servers/slapd/test-plugins/test_slapi_memberof.c" % (workspace)
101 dst_file="%s/%s" % (build_dir, "test_slapi_memberof.c")
102 log.info("Retrieve from the repos: %s" % src_file)
103 shutil.copy(src_file, dst_file)
104 cmd_str="chmod 666 %s" % dst_file
105 subprocess.run(cmd_str, shell=True)
106 test_plugin_location=dst_file
107
108 #
109 # If needed (if PR not pushed yet) to craft slapi-plugin.h
110 #
111 file_path_old = "%s/slapi-plugin.h" % (build_dir)
112 file_path_new = "%s/slapi-plugin.h.new" % (build_dir)
113 slapi_plugin_old = open(file_path_old)
114
115 # before crafting check if slapi_memberof defs are present
116 need_to_craft = True
117 for line in slapi_plugin_old:
118 if "Slapi_MemberOfConfig" in line:
119 need_to_craft = False
120 break
121
122 if need_to_craft:
123 log.info("Need to craft slapi-plugin.h")
124 slapi_plugin_old.seek(0, 0)
125 slapi_plugin_new = open(file_path_new, "w")
126
127 # definitions that were missing, add them
128 struct_slapi_memberof = """
129
130 #include <plhash.h>
131 typedef enum {
132 MEMBEROF_REUSE_ONLY,
133 MEMBEROF_REUSE_IF_POSSIBLE,
134 MEMBEROF_RECOMPUTE
135 } memberof_flag_t;
136
137 typedef struct _slapi_memberofresult {
138 Slapi_ValueSet *nsuniqueid_vals;
139 Slapi_ValueSet *dn_vals;
140 PRBool maxgroups_reached; /* flag is true if the number of groups hit the max limit */
141 } Slapi_MemberOfResult;
142
143 typedef struct _slapi_memberofconfig
144 {
145 char **groupattrs;
146 PRBool subtree_search;
147 int allBackends;
148 Slapi_DN **entryScopes;
149 Slapi_DN **entryScopeExcludeSubtrees;
150 PRBool recurse;
151 int maxgroups;
152 memberof_flag_t flag;
153 char *error_msg;
154 int errot_msg_lenght;
155 int entryScopeCount; /* private to slapi_memberof */
156 int entryExcludeScopeCount; /* private to slapi_memberof */
157 PRBool maxgroups_reached; /* private to slapi_memberof */
158 const char *memberof_attr; /* private to slapi_memberof */
159 Slapi_Attr *dn_syntax_attr; /* private to slapi_memberof */
160 PLHashTable *ancestors_cache; /* private to slapi_memberof */
161 int current_maxgroup; /* private to slapi_memberof */
162 } Slapi_MemberOfConfig;
163
164 """
165 for line in slapi_plugin_old:
166 if re.search(r"^#endif.*SLAPIPLUGIN_H_.*$", line):
167 slapi_plugin_new.write(struct_slapi_memberof)
168 slapi_plugin_new.write("\n")
169 slapi_plugin_new.write(line)
170
171 slapi_plugin_old.close()
172 slapi_plugin_new.close()
173 os.remove(file_path_old)
174 shutil.move(file_path_new, file_path_old)
175
176 #
177 # If needed (if PR not pushed yet) to craft slapi-private.h
178 #
179 file_path_old = "%s/slapi-private.h" % (build_dir)
180 file_path_new = "%s/slapi-private.h.new" % (build_dir)
181 slapi_private_old = open(file_path_old)
182
183 # before crafting check if slapi_memberof defs are present
184 need_to_craft = True
185 for line in slapi_private_old:
186 if "slapi_memberof" in line:
187 need_to_craft = False
188 break
189
190 if need_to_craft:
191 log.info("Need to craft slapi-private.h")
192 slapi_private_old.seek(0, 0)
193 slapi_private_new = open(file_path_new, "w")
194
195 # definitions that were missing, add them
196 struct_slapi_memberof = """
197 int slapi_memberof(Slapi_MemberOfConfig *config, Slapi_DN *member_sdn, Slapi_MemberOfResult *result);
198 void slapi_memberof_free_memberof_plugin_config();
199 int slapi_memberof_load_memberof_plugin_config();
200
201 """
202
203 for line in slapi_private_old:
204 if re.search(r"^void dup_ldif_line.*$", line):
205 slapi_private_new.write(struct_slapi_memberof)
206 slapi_private_new.write("\n")
207 slapi_private_new.write(line)
208
209 slapi_private_old.close()
210 slapi_private_new.close()
211 os.remove(file_path_old)
212 shutil.move(file_path_new, file_path_old)
213
214 # build the plugin into a shared library
215 test_plugin_object="%s/test_slapi_memberof.o" % build_dir
216 test_plugin_sharedlib="%s/libtest_slapi_memberof-plugin.so" % build_dir
217 cmd_str="/usr/bin/gcc -I./ldap/include -I./ldap/servers/slapd -I./include -I. -I/usr/include -I/usr/include/nss3 -I%s -I/usr/include/nspr4 -g -O2 -Wall -c %s -fPIC -DPIC -o %s" % (build_dir, test_plugin_location, test_plugin_object)
218 subprocess.run(cmd_str, shell=True)
219 cmd_str="/usr/bin/gcc -shared -fPIC -DPIC %s -Wl,-rpath -Wl,/usr/lib64/dirsrv -L/usr/lib64/dirsrv/ /usr/lib64/dirsrv/libslapd.so.0 -lldap -llber -lc -Wl,-z,now -g -O2 -O2 -m64 -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -Wl,-soname -Wl,libtest_slapi_memberof-plugin.so -o %s" % (test_plugin_object, test_plugin_sharedlib)
220 subprocess.run(cmd_str, shell=True)
221
222 # install the test plugin
223 cmd_str="chmod 755 %s" % test_plugin_sharedlib
224 subprocess.run(cmd_str, shell=True)
225 shutil.copy(test_plugin_sharedlib, topo.standalone.get_plugin_dir())
226
227
228 def _check_res_vs_expected(msg, res, expected):
229 log.info("Checking %s expecting %d entries" % (msg, len(expected)))
230 assert len(expected) == len(res)
231 expected_str_lower = []
232 for i in expected:
233 expected_str_lower.append(str(i).lower())
234
235 res_str_lower = []
236 for i in res:
237 res_str_lower.append(str(i).lower())
238
239 for i in expected_str_lower:
240 log.info("Check that %s is present" % (i))
241 assert i in res_str_lower
242
243 EMPTY_RESULT="no error msg"
244
245 def _extop_test_slapi_member(server, dn, relation):
246 value = univ.OctetString(dn)
247 value_encoded = encoder.encode(value)
248
249 extop = ExtendedRequest(requestName = '2.3.4.5.113730.6.7.1', requestValue=value_encoded)
250 (oid_response, res) = server.extop_s(extop)
251 d1, d2 = decoder.decode(res)
252 log.info("The entries refering to %s as %s are:" % (dn, relation))
253 for i in d1:
254 log.info(" - %s" % i)
255 return d1
256
257
258 def replace_manager(server, dn, managers):
259 mod = [(ldap.MOD_REPLACE, 'manager', managers)]
260 server.modify_s(dn, mod)
261
262 def add_entry(server, uid, manager=None, subtree=None):
263 if (subtree):
264 dn = 'uid=%s,ou=%s,ou=People,%s' % (uid, subtree, DEFAULT_SUFFIX)
265 else:
266 dn = 'uid=%s,ou=People,%s' % (uid, DEFAULT_SUFFIX)
267 server.add_s(Entry((dn, {'objectclass': 'top person extensibleObject'.split(),
268 'uid': uid,
269 'cn': uid,
270 'sn': uid})))
271 if manager:
272 replace_manager(server, dn, manager)
273 return dn
274
275 def test_slapi_memberof_simple(topo, request, install_test_plugin):
276 """
277 Test that management hierarchy (manager) is computed with slapi_member
278 with following parameters
279 - membership attribute: 'manager'
280 - span over all backends: 'on'
281 - skip nesting membership: 'off'
282 - computation mode: recompute
283 - Scope: DEFAULT_SUFFIX
284 - ExcludeScope: None
285 - Maximum return entries: None
286
287 :id: 4c2595eb-a947-4c0b-996c-e499db67d11a
288 :setup: Standalone instance
289 :steps:
290 1. provision a set of entry
291 2. configure test_slapi_memberof as described above
292 3. check computed membership vs expected result
293 :expectedresults:
294 1. Operation should succeed
295 2. Operation should succeed
296 3. Operation should succeed
297
298 DIT is :
299 e_1_parent_0
300 - e_1_parent_1_0
301 -- e_1_parent_1_1_0
302 --- e_1_parent_1_1_1_0
303 --- e_2_parent_1_1_1_0
304 --- e_3_parent_1_1_1_0
305 --- e_4_parent_1_1_1_0
306 --- e_5_parent_1_1_1_0
307 -- e_2_parent_1_1_0
308 - e_2_parent_1_0
309 -- e_1_parent_2_1_0
310 -- e_2_parent_2_1_0
311 --- e_1_parent_2_2_1_0
312 -- e_3_parent_2_1_0
313 -- e_4_parent_2_1_0
314 e_2_parent_0
315 - e_1_parent_2_0
316 - e_2_parent_2_0
317 - e_3_parent_2_0
318 - e_4_parent_2_0
319 e_3_parent_0
320 - e_1_parent_3_0
321 -- e_1_parent_1_3_0
322 --- e_1_parent_1_1_3_0
323 ---- e_1_parent_1_1_1_3_0
324 """
325 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
326
327 # First subtree
328 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
329
330 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
331
332 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
333
334 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
335 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
336 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
337 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
338 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
339
340 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
341
342 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
343
344 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
345 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
346 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
347 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
348 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
349
350 # 2nd subtree
351 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
352
353 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
354 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
355 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
356 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
357
358 # third subtree
359 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
360
361 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
362
363 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
364
365 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
366
367 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
368
369 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
370 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
371 'cn': 'test_slapi_memberof',
372 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
373 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
374 'nsslapd-pluginType': 'extendedop',
375 'nsslapd-pluginEnabled': 'on',
376 'nsslapd-plugin-depends-on-type': 'database',
377 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
378 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
379 'slapimemberOfGroupAttr': 'manager',
380 'slapimemberOfAttr': 'memberof',
381 'slapimemberOfAllBackends': 'on',
382 'slapimemberOfSkipNested': 'off',
383 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
384 'slapimemberOfMaxGroup': '0',
385 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
386 'nsslapd-pluginVendor': '389 Project',
387 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
388 topo.standalone.restart()
389
390 # Check the first subtree
391 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
392 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
393 _check_res_vs_expected("first subtree", res, expected)
394
395 # Check the second subtree
396 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
397 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
398 _check_res_vs_expected("second subtree", res, expected)
399
400 # Check the third subtree
401 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
402 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
403 _check_res_vs_expected("third subtree", res, expected)
404
405 # check e_1_parent_1_0
406 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
407 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
408 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
409
410 # check e_1_parent_1_1_0
411 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
412 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
413 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
414
415 # check e_2_parent_1_1_0
416 expected = [EMPTY_RESULT]
417 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
418 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
419
420 # check e_2_parent_1_0
421 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
422 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
423 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
424
425 # check e_2_parent_2_1_0
426 expected = [e_1_parent_2_2_1_0]
427 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
428 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
429
430 # Check e_1_parent_3_0
431 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
432 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
433 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
434
435 # Check e_1_parent_1_3_0
436 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
437 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
438 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
439
440 # Check e_1_parent_1_1_3_0
441 expected = [e_1_parent_1_1_1_3_0]
442 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
443 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
444
445 # Check e_1_parent_1_1_1_3_0
446 expected = [EMPTY_RESULT]
447 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
448 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
449
450 def fin():
451 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
452 for entry in entries:
453 topo.standalone.delete_s(entry)
454 topo.standalone.delete_s(dn_config)
455
456 request.addfinalizer(fin)
457
458 def test_slapi_memberof_allbackends_on(topo, request, install_test_plugin):
459 """
460 Test that management hierarchy (manager) is computed with slapi_member
461 It exists several backends and manager relationship cross those backends
462 with following parameters
463 - membership attribute: 'manager'
464 - span over all backends: 'on' <----
465 - skip nesting membership: 'off'
466 - computation mode: recompute
467 - Scope: DEFAULT_SUFFIX
468 - ExcludeScope: None
469 - Maximum return entries: None
470
471 :id: 910c43a0-04ae-48f1-9e3c-6d97ba5bcb71
472 :setup: Standalone instance
473 :steps:
474 1. create a second backend with foo_bar entry
475 2. provision a set of entries in default backend with foo_bar being
476 manager of entry e_1_parent_1_1_1_3_0 that is in default backend
477 3. configure test_slapi_memberof as described above
478 4. check computed membership vs expected result
479 slapi_memberof(foo_bar, "manager") -> e_1_parent_1_1_1_3_0
480 :expectedresults:
481 1. Operation should succeed
482 2. Operation should succeed
483 3. Operation should succeed
484 4. Operation should succeed
485
486 DIT is :
487 e_1_parent_0
488 - e_1_parent_1_0
489 -- e_1_parent_1_1_0
490 --- e_1_parent_1_1_1_0
491 --- e_2_parent_1_1_1_0
492 --- e_3_parent_1_1_1_0
493 --- e_4_parent_1_1_1_0
494 --- e_5_parent_1_1_1_0
495 -- e_2_parent_1_1_0
496 - e_2_parent_1_0
497 -- e_1_parent_2_1_0
498 -- e_2_parent_2_1_0
499 --- e_1_parent_2_2_1_0
500 -- e_3_parent_2_1_0
501 -- e_4_parent_2_1_0
502 e_2_parent_0
503 - e_1_parent_2_0
504 - e_2_parent_2_0
505 - e_3_parent_2_0
506 - e_4_parent_2_0
507 e_3_parent_0
508 - e_1_parent_3_0
509 -- e_1_parent_1_3_0
510 --- e_1_parent_1_1_3_0
511 ---- e_1_parent_1_1_1_3_0
512 """
513 # create a second backend
514 second_suffix='dc=foo,dc=bar'
515 be_name='fooBar'
516 be1 = Backend(topo.standalone)
517 be1.create(properties={
518 'cn': be_name,
519 'nsslapd-suffix': second_suffix,
520 },
521 )
522 # Create the domain entry
523 create_base_domain(topo.standalone, second_suffix)
524 rdn='foo_bar'
525 dn_entry_foo_bar='uid=%s,%s' % (rdn, second_suffix)
526 topo.standalone.add_s(Entry((dn_entry_foo_bar, {'objectclass': 'top person extensibleObject'.split(),
527 'uid': rdn,
528 'cn': rdn,
529 'sn': rdn})))
530
531 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
532
533 # First subtree
534 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
535
536 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
537
538 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
539
540 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
541 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
542 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
543 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
544 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
545
546 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
547
548 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
549
550 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
551 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
552 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
553 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
554 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
555
556 # 2nd subtree
557 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
558
559 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
560 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
561 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
562 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
563
564 # third subtree
565 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
566
567 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
568
569 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
570
571 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
572
573 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
574
575 # make foo_bar entry manager of e_1_parent_1_1_1_3_0
576 replace_manager(topo.standalone, e_1_parent_1_1_1_3_0, [ensure_bytes(dn_entry_foo_bar)])
577
578 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
579 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
580 'cn': 'test_slapi_memberof',
581 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
582 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
583 'nsslapd-pluginType': 'extendedop',
584 'nsslapd-pluginEnabled': 'on',
585 'nsslapd-plugin-depends-on-type': 'database',
586 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
587 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
588 'slapimemberOfGroupAttr': 'manager',
589 'slapimemberOfAttr': 'memberof',
590 'slapimemberOfAllBackends': 'on',
591 'slapimemberOfSkipNested': 'off',
592 'slapimemberOfEntryScope': [DEFAULT_SUFFIX, second_suffix],
593 'slapimemberOfMaxGroup': '0',
594 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
595 'nsslapd-pluginVendor': '389 Project',
596 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
597 topo.standalone.restart()
598
599 # Check the first subtree
600 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
601 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
602 _check_res_vs_expected("first subtree", res, expected)
603
604 # Check the second subtree
605 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
606 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
607 _check_res_vs_expected("second subtree", res, expected)
608
609 # Check the third subtree
610 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0]
611 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
612 _check_res_vs_expected("third subtree", res, expected)
613
614 # check e_1_parent_1_0
615 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
616 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
617 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
618
619 # check e_1_parent_1_1_0
620 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
621 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
622 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
623
624 # check e_2_parent_1_1_0
625 expected = [EMPTY_RESULT]
626 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
627 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
628
629 # check e_2_parent_1_0
630 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
631 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
632 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
633
634 # check e_2_parent_2_1_0
635 expected = [e_1_parent_2_2_1_0]
636 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
637 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
638
639 # Check e_1_parent_3_0
640 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0]
641 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
642 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
643
644 # Check e_1_parent_1_3_0
645 expected = [e_1_parent_1_1_3_0]
646 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
647 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
648
649 # Check e_1_parent_1_1_3_0
650 expected = [EMPTY_RESULT]
651 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
652 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
653
654 # Check e_1_parent_1_1_1_3_0
655 expected = [EMPTY_RESULT]
656 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
657 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
658
659 # Check dn_entry_foo_bar
660 expected = [e_1_parent_1_1_1_3_0]
661 res = _extop_test_slapi_member(server=topo.standalone, dn=dn_entry_foo_bar, relation="manager")
662 _check_res_vs_expected("organisation reporting to dn_entry_foo_bar", res, expected)
663
664
665 def fin():
666 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
667 for entry in entries:
668 topo.standalone.delete_s(entry)
669 topo.standalone.delete_s(dn_config)
670 topo.standalone.delete_s(dn_entry_foo_bar)
671 be1.delete()
672
673 request.addfinalizer(fin)
674
675 def test_slapi_memberof_allbackends_off(topo, request, install_test_plugin):
676 """
677 Test that management hierarchy (manager) is computed with slapi_member
678 It exists several backends and manager relationship cross those backends
679 with following parameters
680 - membership attribute: 'manager'
681 - span over all backends: 'off' <----
682 - skip nesting membership: 'off'
683 - computation mode: recompute
684 - Scope: DEFAULT_SUFFIX
685 - ExcludeScope: None
686 - Maximum return entries: None
687
688 :id: 56fb0c16-8086-429b-adf0-fff0eb8e121e
689 :setup: Standalone instance
690 :steps:
691 1. create a second backend with foo_bar entry
692 2. provision a set of entries in default backend with foo_bar being
693 manager of entry e_1_parent_1_1_1_3_0 that is in default backend
694 3. configure test_slapi_memberof as described above
695 4. check computed membership vs expected result
696 slapi_memberof(foo_bar, "manager") NOT -> e_1_parent_1_1_1_3_0
697 :expectedresults:
698 1. Operation should succeed
699 2. Operation should succeed
700 3. Operation should succeed
701 4. Operation should succeed
702
703 DIT is :
704 e_1_parent_0
705 - e_1_parent_1_0
706 -- e_1_parent_1_1_0
707 --- e_1_parent_1_1_1_0
708 --- e_2_parent_1_1_1_0
709 --- e_3_parent_1_1_1_0
710 --- e_4_parent_1_1_1_0
711 --- e_5_parent_1_1_1_0
712 -- e_2_parent_1_1_0
713 - e_2_parent_1_0
714 -- e_1_parent_2_1_0
715 -- e_2_parent_2_1_0
716 --- e_1_parent_2_2_1_0
717 -- e_3_parent_2_1_0
718 -- e_4_parent_2_1_0
719 e_2_parent_0
720 - e_1_parent_2_0
721 - e_2_parent_2_0
722 - e_3_parent_2_0
723 - e_4_parent_2_0
724 e_3_parent_0
725 - e_1_parent_3_0
726 -- e_1_parent_1_3_0
727 --- e_1_parent_1_1_3_0
728 ---- e_1_parent_1_1_1_3_0
729 """
730 # Create second backend
731 second_suffix='dc=foo,dc=bar'
732 be_name='fooBar'
733 be1 = Backend(topo.standalone)
734 be1.create(properties={
735 'cn': be_name,
736 'nsslapd-suffix': second_suffix,
737 },
738 )
739 # Create the domain entry
740 create_base_domain(topo.standalone, second_suffix)
741 rdn='foo_bar'
742 dn_entry_foo_bar='uid=%s,%s' % (rdn, second_suffix)
743 topo.standalone.add_s(Entry((dn_entry_foo_bar, {'objectclass': 'top person extensibleObject'.split(),
744 'uid': rdn,
745 'cn': rdn,
746 'sn': rdn})))
747
748 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
749
750 # First subtree
751 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
752
753 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
754
755 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
756
757 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
758 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
759 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
760 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
761 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
762
763 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
764
765 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
766
767 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
768 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
769 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
770 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
771 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
772
773 # 2nd subtree
774 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
775
776 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
777 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
778 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
779 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
780
781 # third subtree
782 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
783
784 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
785
786 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
787
788 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
789
790 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
791
792 # make foo_bar entry manager of e_1_parent_1_1_1_3_0
793 replace_manager(topo.standalone, e_1_parent_1_1_1_3_0, [ensure_bytes(dn_entry_foo_bar)])
794
795 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
796 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
797 'cn': 'test_slapi_memberof',
798 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
799 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
800 'nsslapd-pluginType': 'extendedop',
801 'nsslapd-pluginEnabled': 'on',
802 'nsslapd-plugin-depends-on-type': 'database',
803 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
804 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
805 'slapimemberOfGroupAttr': 'manager',
806 'slapimemberOfAttr': 'memberof',
807 'slapimemberOfAllBackends': 'off',
808 'slapimemberOfSkipNested': 'off',
809 'slapimemberOfEntryScope': [DEFAULT_SUFFIX, second_suffix],
810 'slapimemberOfMaxGroup': '0',
811 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
812 'nsslapd-pluginVendor': '389 Project',
813 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
814 topo.standalone.restart()
815
816 # Check the first subtree
817 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
818 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
819 _check_res_vs_expected("first subtree", res, expected)
820
821 # Check the second subtree
822 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
823 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
824 _check_res_vs_expected("second subtree", res, expected)
825
826 # Check the third subtree
827 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0]
828 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
829 _check_res_vs_expected("third subtree", res, expected)
830
831 # check e_1_parent_1_0
832 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
833 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
834 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
835
836 # check e_1_parent_1_1_0
837 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
838 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
839 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
840
841 # check e_2_parent_1_1_0
842 expected = [EMPTY_RESULT]
843 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
844 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
845
846 # check e_2_parent_1_0
847 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
848 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
849 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
850
851 # check e_2_parent_2_1_0
852 expected = [e_1_parent_2_2_1_0]
853 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
854 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
855
856 # Check e_1_parent_3_0
857 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0]
858 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
859 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
860
861 # Check e_1_parent_1_3_0
862 expected = [e_1_parent_1_1_3_0]
863 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
864 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
865
866 # Check e_1_parent_1_1_3_0
867 expected = [EMPTY_RESULT]
868 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
869 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
870
871 # Check e_1_parent_1_1_1_3_0
872 expected = [EMPTY_RESULT]
873 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
874 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
875
876 # Check dn_entry_foo_bar is not manager of e_1_parent_1_1_1_3_0 because slapimemberOfAllBackends=off
877 expected = [EMPTY_RESULT]
878 res = _extop_test_slapi_member(server=topo.standalone, dn=dn_entry_foo_bar, relation="manager")
879 _check_res_vs_expected("organisation reporting to dn_entry_foo_bar", res, expected)
880
881
882 def fin():
883 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
884 for entry in entries:
885 topo.standalone.delete_s(entry)
886 topo.standalone.delete_s(dn_config)
887 topo.standalone.delete_s(dn_entry_foo_bar)
888 be1.delete()
889
890 request.addfinalizer(fin)
891
892
893 def test_slapi_memberof_memberattr(topo, request, install_test_plugin):
894 """
895 Test that membership hierarchy (member) is computed with slapi_member
896 the membership is done with 'manager' attribute but slapi_memberof
897 called with 'member' attribute. As there is no 'member' then
898 membership returns empty_results
899 with following parameters
900 - membership attribute: 'member' <----
901 - span over all backends: 'on'
902 - skip nesting membership: 'off'
903 - computation mode: recompute
904 - Scope: DEFAULT_SUFFIX
905 - ExcludeScope: None
906 - Maximum return entries: None
907
908 :id: 373f7f65-185f-4b06-a0a5-3e23692b87f1
909 :setup: Standalone instance
910 :steps:
911 1. provision a set of entries in default backend
912 with membership using 'manager'
913 2. configure test_slapi_memberof as described above
914 so checking membership using 'member'
915 3. check computed membership vs expected result
916 all empty_result because no entry has 'member'
917 :expectedresults:
918 1. Operation should succeed
919 2. Operation should succeed
920 3. Operation should succeed
921
922 DIT is :
923 e_1_parent_0
924 - e_1_parent_1_0
925 -- e_1_parent_1_1_0
926 --- e_1_parent_1_1_1_0
927 --- e_2_parent_1_1_1_0
928 --- e_3_parent_1_1_1_0
929 --- e_4_parent_1_1_1_0
930 --- e_5_parent_1_1_1_0
931 -- e_2_parent_1_1_0
932 - e_2_parent_1_0
933 -- e_1_parent_2_1_0
934 -- e_2_parent_2_1_0
935 --- e_1_parent_2_2_1_0
936 -- e_3_parent_2_1_0
937 -- e_4_parent_2_1_0
938 e_2_parent_0
939 - e_1_parent_2_0
940 - e_2_parent_2_0
941 - e_3_parent_2_0
942 - e_4_parent_2_0
943 e_3_parent_0
944 - e_1_parent_3_0
945 -- e_1_parent_1_3_0
946 --- e_1_parent_1_1_3_0
947 ---- e_1_parent_1_1_1_3_0
948 """
949 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
950
951 # First subtree
952 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
953
954 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
955
956 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
957
958 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
959 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
960 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
961 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
962 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
963
964 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
965
966 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
967
968 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
969 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
970 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
971 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
972 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
973
974 # 2nd subtree
975 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
976
977 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
978 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
979 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
980 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
981
982 # third subtree
983 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
984
985 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
986
987 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
988
989 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
990
991 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
992
993 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
994 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
995 'cn': 'test_slapi_memberof',
996 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
997 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
998 'nsslapd-pluginType': 'extendedop',
999 'nsslapd-pluginEnabled': 'on',
1000 'nsslapd-plugin-depends-on-type': 'database',
1001 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1002 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1003 'slapimemberOfGroupAttr': 'member',
1004 'slapimemberOfAttr': 'memberof',
1005 'slapimemberOfAllBackends': 'on',
1006 'slapimemberOfSkipNested': 'off',
1007 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
1008 'slapimemberOfMaxGroup': '0',
1009 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1010 'nsslapd-pluginVendor': '389 Project',
1011 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1012 topo.standalone.restart()
1013
1014 # Check the first subtree
1015 expected = [ EMPTY_RESULT ]
1016 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1017 _check_res_vs_expected("first subtree", res, expected)
1018
1019 # Check the second subtree
1020 expected = [ EMPTY_RESULT ]
1021 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1022 _check_res_vs_expected("second subtree", res, expected)
1023
1024 # Check the third subtree
1025 expected = [ EMPTY_RESULT ]
1026 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1027 _check_res_vs_expected("third subtree", res, expected)
1028
1029 # check e_1_parent_1_0
1030 expected = [ EMPTY_RESULT ]
1031 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1032 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1033
1034 # check e_1_parent_1_1_0
1035 expected = [ EMPTY_RESULT ]
1036 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1037 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1038
1039 # check e_2_parent_1_1_0
1040 expected = [EMPTY_RESULT]
1041 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1042 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
1043
1044 # check e_2_parent_1_0
1045 expected = [ EMPTY_RESULT ]
1046 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
1047 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
1048
1049 # check e_2_parent_2_1_0
1050 expected = [ EMPTY_RESULT ]
1051 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
1052 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
1053
1054 # Check e_1_parent_3_0
1055 expected = [ EMPTY_RESULT ]
1056 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
1057 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
1058
1059 # Check e_1_parent_1_3_0
1060 expected = [ EMPTY_RESULT ]
1061 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
1062 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
1063
1064 # Check e_1_parent_1_1_3_0
1065 expected = [ EMPTY_RESULT ]
1066 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
1067 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
1068
1069 # Check e_1_parent_1_1_1_3_0
1070 expected = [EMPTY_RESULT]
1071 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
1072 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
1073
1074 def fin():
1075 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1076 for entry in entries:
1077 topo.standalone.delete_s(entry)
1078 topo.standalone.delete_s(dn_config)
1079
1080 request.addfinalizer(fin)
1081
1082
1083 def test_slapi_memberof_scope(topo, request, install_test_plugin):
1084 """
1085 Test that membership hierarchy (member) is computed with slapi_member
1086 Only entries in the subtree scope (e_2_parent_1_0) gets valid
1087 computation of the membership
1088 with following parameters
1089 - membership attribute: 'manager'
1090 - span over all backends: 'on'
1091 - skip nesting membership: 'off'
1092 - computation mode: recompute
1093 - Scope: ou=subtree,ou=People,dc=example,dc=com <----
1094 - ExcludeScope: None
1095 - Maximum return entries: None
1096
1097 :id: 6c7587e0-0bc4-4847-b403-773d7314aa31
1098 :setup: Standalone instance
1099 :steps:
1100 1. provision a set of entries in default backend
1101 2. configure test_slapi_memberof as described above
1102 so only entries under e_2_parent_1_0 are taken into
1103 consideration
1104 3. check computed membership vs expected result
1105 Only entries under e_2_parent_1_0 get no empty results
1106 :expectedresults:
1107 1. Operation should succeed
1108 2. Operation should succeed
1109 3. Operation should succeed
1110
1111 DIT is :
1112 e_1_parent_0
1113 - e_1_parent_1_0
1114 -- e_1_parent_1_1_0
1115 --- e_1_parent_1_1_1_0
1116 --- e_2_parent_1_1_1_0
1117 --- e_3_parent_1_1_1_0
1118 --- e_4_parent_1_1_1_0
1119 --- e_5_parent_1_1_1_0
1120 -- e_2_parent_1_1_0
1121 - e_2_parent_1_0 (subtree) <----
1122 -- e_1_parent_2_1_0 (subtree) <----
1123 -- e_2_parent_2_1_0 (subtree) <----
1124 --- e_1_parent_2_2_1_0 (subtree) <----
1125 -- e_3_parent_2_1_0 (subtree) <----
1126 -- e_4_parent_2_1_0 (subtree) <----
1127 e_2_parent_0
1128 - e_1_parent_2_0
1129 - e_2_parent_2_0
1130 - e_3_parent_2_0
1131 - e_4_parent_2_0
1132 e_3_parent_0
1133 - e_1_parent_3_0
1134 -- e_1_parent_1_3_0
1135 --- e_1_parent_1_1_3_0
1136 ---- e_1_parent_1_1_1_3_0
1137 """
1138
1139 subtree="subtree"
1140 dn_subtree = 'ou=%s,ou=People,%s' % (subtree, DEFAULT_SUFFIX)
1141 topo.standalone.add_s(Entry((dn_subtree, {'objectclass': 'top organizationalunit'.split(),
1142 'ou': subtree})))
1143 # First subtree
1144 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
1145
1146 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1147
1148 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1149
1150 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1151 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1152 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1153 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1154 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1155
1156 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1157
1158 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)], subtree=subtree)
1159
1160 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1161 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1162 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)], subtree=subtree)
1163 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1164 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1165
1166 # 2nd subtree
1167 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
1168
1169 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1170 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1171 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1172 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1173
1174 # third subtree
1175 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
1176
1177 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
1178
1179 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
1180
1181 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
1182
1183 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
1184
1185 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
1186 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
1187 'cn': 'test_slapi_memberof',
1188 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
1189 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
1190 'nsslapd-pluginType': 'extendedop',
1191 'nsslapd-pluginEnabled': 'on',
1192 'nsslapd-plugin-depends-on-type': 'database',
1193 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1194 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1195 'slapimemberOfGroupAttr': 'manager',
1196 'slapimemberOfAttr': 'memberof',
1197 'slapimemberOfAllBackends': 'on',
1198 'slapimemberOfSkipNested': 'off',
1199 'slapimemberOfEntryScope': dn_subtree,
1200 'slapimemberOfMaxGroup': '0',
1201 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1202 'nsslapd-pluginVendor': '389 Project',
1203 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1204 topo.standalone.restart()
1205
1206 # Check the first subtree
1207 expected = [ EMPTY_RESULT ]
1208 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1209 _check_res_vs_expected("first subtree", res, expected)
1210
1211 # Check the second subtree
1212 expected = [ EMPTY_RESULT ]
1213 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1214 _check_res_vs_expected("second subtree", res, expected)
1215
1216 # Check the third subtree
1217 expected = [ EMPTY_RESULT ]
1218 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1219 _check_res_vs_expected("third subtree", res, expected)
1220
1221 # check e_1_parent_1_0
1222 expected = [ EMPTY_RESULT ]
1223 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1224 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1225
1226 # check e_1_parent_1_1_0
1227 expected = [ EMPTY_RESULT ]
1228 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1229 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1230
1231 # check e_2_parent_1_1_0
1232 expected = [ EMPTY_RESULT ]
1233 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1234 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
1235
1236 # check e_2_parent_1_0
1237 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
1238 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
1239 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
1240
1241 # Check e_1_parent_2_1_0
1242 expected = [ EMPTY_RESULT ]
1243 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_2_1_0, relation="manager")
1244 _check_res_vs_expected("organisation reporting to e_1_parent_2_1_0", res, expected)
1245
1246 # check e_2_parent_2_1_0
1247 expected = [ e_1_parent_2_2_1_0 ]
1248 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
1249 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
1250
1251 # Check e_1_parent_3_0
1252 expected = [ EMPTY_RESULT ]
1253 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
1254 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
1255
1256 # Check e_1_parent_1_3_0
1257 expected = [ EMPTY_RESULT ]
1258 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
1259 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
1260
1261 # Check e_1_parent_1_1_3_0
1262 expected = [ EMPTY_RESULT ]
1263 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
1264 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
1265
1266 # Check e_1_parent_1_1_1_3_0
1267 expected = [EMPTY_RESULT]
1268 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
1269 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
1270
1271 def fin():
1272 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1273 for entry in entries:
1274 topo.standalone.delete_s(entry)
1275 topo.standalone.delete_s(dn_config)
1276 topo.standalone.delete_s(dn_subtree)
1277
1278 request.addfinalizer(fin)
1279
1280 def test_slapi_memberof_excludescope(topo, request, install_test_plugin):
1281 """
1282 Test that membership hierarchy (member) is computed with slapi_member
1283 Entries in the subtree excludeescope (e_2_parent_1_0) are ignored
1284 computation of the membership
1285 with following parameters
1286 - membership attribute: 'manager'
1287 - span over all backends: 'on'
1288 - skip nesting membership: 'off'
1289 - computation mode: recompute
1290 - Scope: DEFAULT_SUFFIX
1291 - ExcludeScope: ou=subtree,ou=People,dc=example,dc=com <----
1292 - Maximum return entries: None
1293
1294 :id: bdb17e7e-289c-4b56-83d5-0eb54d0c660e
1295 :setup: Standalone instance
1296 :steps:
1297 1. provision a set of entries in default backend
1298 2. configure test_slapi_memberof as described above
1299 so entries under e_2_parent_1_0 are ignored
1300 3. check computed membership vs expected result
1301 :expectedresults:
1302 1. Operation should succeed
1303 2. Operation should succeed
1304 3. Operation should succeed
1305
1306 DIT is :
1307 e_1_parent_0
1308 - e_1_parent_1_0
1309 -- e_1_parent_1_1_0
1310 --- e_1_parent_1_1_1_0
1311 --- e_2_parent_1_1_1_0
1312 --- e_3_parent_1_1_1_0
1313 --- e_4_parent_1_1_1_0
1314 --- e_5_parent_1_1_1_0
1315 -- e_2_parent_1_1_0
1316 - e_2_parent_1_0 (subtree) <----
1317 -- e_1_parent_2_1_0 (subtree) <----
1318 -- e_2_parent_2_1_0 (subtree) <----
1319 --- e_1_parent_2_2_1_0 (subtree) <----
1320 -- e_3_parent_2_1_0 (subtree) <----
1321 -- e_4_parent_2_1_0 (subtree) <----
1322 e_2_parent_0
1323 - e_1_parent_2_0
1324 - e_2_parent_2_0
1325 - e_3_parent_2_0
1326 - e_4_parent_2_0
1327 e_3_parent_0
1328 - e_1_parent_3_0
1329 -- e_1_parent_1_3_0
1330 --- e_1_parent_1_1_3_0
1331 ---- e_1_parent_1_1_1_3_0
1332 """
1333
1334 subtree="subtree"
1335 dn_subtree = 'ou=%s,ou=People,%s' % (subtree, DEFAULT_SUFFIX)
1336 topo.standalone.add_s(Entry((dn_subtree, {'objectclass': 'top organizationalunit'.split(),
1337 'ou': subtree})))
1338 # First subtree
1339 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
1340
1341 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1342
1343 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1344
1345 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1346 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1347 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1348 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1349 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1350
1351 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1352
1353 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)], subtree=subtree)
1354
1355 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1356 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1357 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)], subtree=subtree)
1358 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1359 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)], subtree=subtree)
1360
1361 # 2nd subtree
1362 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
1363
1364 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1365 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1366 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1367 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1368
1369 # third subtree
1370 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
1371
1372 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
1373
1374 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
1375
1376 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
1377
1378 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
1379
1380 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
1381 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
1382 'cn': 'test_slapi_memberof',
1383 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
1384 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
1385 'nsslapd-pluginType': 'extendedop',
1386 'nsslapd-pluginEnabled': 'on',
1387 'nsslapd-plugin-depends-on-type': 'database',
1388 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1389 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1390 'slapimemberOfGroupAttr': 'manager',
1391 'slapimemberOfAttr': 'memberof',
1392 'slapimemberOfAllBackends': 'on',
1393 'slapimemberOfSkipNested': 'off',
1394 'slapimemberOfEntryScopeExcludeSubtree': dn_subtree,
1395 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
1396 'slapimemberOfMaxGroup': '0',
1397 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1398 'nsslapd-pluginVendor': '389 Project',
1399 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1400 topo.standalone.restart()
1401
1402 # Check the first subtree
1403 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
1404 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1405 _check_res_vs_expected("first subtree", res, expected)
1406
1407 # Check the second subtree
1408 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
1409 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1410 _check_res_vs_expected("second subtree", res, expected)
1411
1412 # Check the third subtree
1413 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1414 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1415 _check_res_vs_expected("third subtree", res, expected)
1416
1417 # check e_1_parent_1_0
1418 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
1419 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1420 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1421
1422 # check e_1_parent_1_1_0
1423 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
1424 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1425 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1426
1427 # check e_2_parent_1_1_0
1428 expected = [ EMPTY_RESULT ]
1429 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1430 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
1431
1432 # check e_2_parent_1_0
1433 expected = [ EMPTY_RESULT ]
1434 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
1435 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
1436
1437 # Check e_1_parent_2_1_0
1438 expected = [ EMPTY_RESULT ]
1439 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_2_1_0, relation="manager")
1440 _check_res_vs_expected("organisation reporting to e_1_parent_2_1_0", res, expected)
1441
1442 # check e_2_parent_2_1_0
1443 expected = [ EMPTY_RESULT ]
1444 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
1445 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
1446
1447 # Check e_1_parent_3_0
1448 expected = [ e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0 ]
1449 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
1450 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
1451
1452 # Check e_1_parent_1_3_0
1453 expected = [ e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0 ]
1454 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
1455 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
1456
1457 # Check e_1_parent_1_1_3_0
1458 expected = [ e_1_parent_1_1_1_3_0 ]
1459 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
1460 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
1461
1462 # Check e_1_parent_1_1_1_3_0
1463 expected = [EMPTY_RESULT]
1464 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
1465 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
1466
1467 def fin():
1468 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1469 for entry in entries:
1470 topo.standalone.delete_s(entry)
1471 topo.standalone.delete_s(dn_config)
1472 topo.standalone.delete_s(dn_subtree)
1473
1474 request.addfinalizer(fin)
1475
1476 def test_slapi_memberof_skip_nested(topo, request, install_test_plugin):
1477 """
1478 When searching the management (manager) hierarchy it stops at the first level
1479 no recursion
1480 Test that management hierarchy is computed with slapi_member
1481 It is done stopping at the first level, so the direct subordinate
1482 with following parameters
1483 - membership attribute: 'manager'
1484 - span over all backends: 'on'
1485 - skip nesting membership: 'on' <----
1486 - computation mode: recompute
1487 - Scope: DEFAULT_SUFFIX
1488 - ExcludeScope: ou=subtree,ou=People,dc=example,dc=com
1489 - Maximum return entries: None
1490
1491 :id: c9b5617f-9058-40f5-bdd6-a560bc67b30d
1492 :setup: Standalone instance
1493 :steps:
1494 1. provision a set of entries in default backend
1495 2. configure test_slapi_memberof as described above
1496 3. check computed membership vs expected result
1497 only direct subordinate are returned
1498 :expectedresults:
1499 1. Operation should succeed
1500 2. Operation should succeed
1501 3. Operation should succeed
1502
1503 DIT is :
1504 e_1_parent_0
1505 - e_1_parent_1_0
1506 -- e_1_parent_1_1_0
1507 --- e_1_parent_1_1_1_0
1508 --- e_2_parent_1_1_1_0
1509 --- e_3_parent_1_1_1_0
1510 --- e_4_parent_1_1_1_0
1511 --- e_5_parent_1_1_1_0
1512 -- e_2_parent_1_1_0
1513 - e_2_parent_1_0
1514 -- e_1_parent_2_1_0
1515 -- e_2_parent_2_1_0
1516 --- e_1_parent_2_2_1_0
1517 -- e_3_parent_2_1_0
1518 -- e_4_parent_2_1_0
1519 e_2_parent_0
1520 - e_1_parent_2_0
1521 - e_2_parent_2_0
1522 - e_3_parent_2_0
1523 - e_4_parent_2_0
1524 e_3_parent_0
1525 - e_1_parent_3_0
1526 -- e_1_parent_1_3_0
1527 --- e_1_parent_1_1_3_0
1528 ---- e_1_parent_1_1_1_3_0
1529 """
1530
1531 subtree="subtree"
1532 dn_subtree = 'ou=%s,ou=People,%s' % (subtree, DEFAULT_SUFFIX)
1533 topo.standalone.add_s(Entry((dn_subtree, {'objectclass': 'top organizationalunit'.split(),
1534 'ou': subtree})))
1535 # First subtree
1536 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
1537
1538 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1539
1540 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1541
1542 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1543 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1544 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1545 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1546 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1547
1548 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1549
1550 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1551
1552 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1553 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1554 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
1555 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1556 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1557
1558 # 2nd subtree
1559 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
1560
1561 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1562 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1563 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1564 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1565
1566 # third subtree
1567 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
1568
1569 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
1570
1571 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
1572
1573 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
1574
1575 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
1576
1577 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
1578 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
1579 'cn': 'test_slapi_memberof',
1580 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
1581 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
1582 'nsslapd-pluginType': 'extendedop',
1583 'nsslapd-pluginEnabled': 'on',
1584 'nsslapd-plugin-depends-on-type': 'database',
1585 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1586 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1587 'slapimemberOfGroupAttr': 'manager',
1588 'slapimemberOfAttr': 'memberof',
1589 'slapimemberOfAllBackends': 'on',
1590 'slapimemberOfSkipNested': 'on',
1591 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
1592 'slapimemberOfMaxGroup': '0',
1593 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1594 'nsslapd-pluginVendor': '389 Project',
1595 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1596 topo.standalone.restart()
1597 # Check the first subtree
1598 expected = [ e_1_parent_1_0, e_2_parent_1_0]
1599 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1600 _check_res_vs_expected("first subtree", res, expected)
1601
1602 # Check the second subtree
1603 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
1604 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1605 _check_res_vs_expected("second subtree", res, expected)
1606
1607 # Check the third subtree
1608 expected = [e_1_parent_3_0]
1609 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1610 _check_res_vs_expected("third subtree", res, expected)
1611
1612 # check e_1_parent_1_0
1613 expected = [e_1_parent_1_1_0, e_2_parent_1_1_0]
1614 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1615 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1616
1617 # check e_1_parent_1_1_0
1618 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
1619 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1620 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1621
1622 # check e_2_parent_1_1_0
1623 expected = [EMPTY_RESULT]
1624 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1625 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
1626
1627 # check e_2_parent_1_0
1628 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
1629 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
1630 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
1631
1632 # check e_2_parent_2_1_0
1633 expected = [e_1_parent_2_2_1_0]
1634 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
1635 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
1636
1637 # Check e_1_parent_3_0
1638 expected = [e_1_parent_1_3_0]
1639 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
1640 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
1641
1642 # Check e_1_parent_1_3_0
1643 expected = [e_1_parent_1_1_3_0]
1644 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
1645 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
1646
1647 # Check e_1_parent_1_1_3_0
1648 expected = [e_1_parent_1_1_1_3_0]
1649 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
1650 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
1651
1652 # Check e_1_parent_1_1_1_3_0
1653 expected = [EMPTY_RESULT]
1654 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
1655 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
1656
1657 def fin():
1658 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1659 for entry in entries:
1660 topo.standalone.delete_s(entry)
1661 topo.standalone.delete_s(dn_config)
1662 topo.standalone.delete_s(dn_subtree)
1663
1664 request.addfinalizer(fin)
1665
1666 def test_slapi_memberof_maxgroup(topo, request, install_test_plugin):
1667 """
1668 When searching the management (manager) hierarchy it stops when
1669 a maximum subordinates are retrieved
1670 Test that management hierarchy is computed with slapi_member
1671 with following parameters
1672 - membership attribute: 'manager'
1673 - span over all backends: 'on'
1674 - skip nesting membership: 'off' <----
1675 - computation mode: recompute
1676 - Scope: DEFAULT_SUFFIX
1677 - ExcludeScope: ou=subtree,ou=People,dc=example,dc=com
1678 - Maximum return entries: 3 <--
1679
1680 :id: 83a4c668-99d0-4f47-ac89-a7f7fc620340
1681 :setup: Standalone instance
1682 :steps:
1683 1. provision a set of entries in default backend
1684 2. configure test_slapi_memberof as described above
1685 3. check computed membership vs expected result
1686 only direct subordinate are returned
1687 :expectedresults:
1688 1. Operation should succeed
1689 2. Operation should succeed
1690 3. Operation should succeed
1691
1692 DIT is :
1693 e_1_parent_0
1694 - e_1_parent_1_0
1695 -- e_1_parent_1_1_0
1696 --- e_1_parent_1_1_1_0
1697 --- e_2_parent_1_1_1_0
1698 --- e_3_parent_1_1_1_0
1699 --- e_4_parent_1_1_1_0
1700 --- e_5_parent_1_1_1_0
1701 -- e_2_parent_1_1_0
1702 - e_2_parent_1_0
1703 -- e_1_parent_2_1_0
1704 -- e_2_parent_2_1_0
1705 --- e_1_parent_2_2_1_0
1706 -- e_3_parent_2_1_0
1707 -- e_4_parent_2_1_0
1708 e_2_parent_0
1709 - e_1_parent_2_0
1710 - e_2_parent_2_0
1711 - e_3_parent_2_0
1712 - e_4_parent_2_0
1713 e_3_parent_0
1714 - e_1_parent_3_0
1715 -- e_1_parent_1_3_0
1716 --- e_1_parent_1_1_3_0
1717 ---- e_1_parent_1_1_1_3_0
1718 """
1719 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
1720
1721 # First subtree
1722 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
1723
1724 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1725
1726 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1727
1728 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1729 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1730 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1731 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1732 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1733
1734 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1735
1736 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1737
1738 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1739 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1740 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
1741 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1742 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1743
1744 # 2nd subtree
1745 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
1746
1747 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1748 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1749 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1750 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1751
1752 # third subtree
1753 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
1754
1755 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
1756
1757 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
1758
1759 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
1760
1761 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
1762
1763 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
1764 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
1765 'cn': 'test_slapi_memberof',
1766 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
1767 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
1768 'nsslapd-pluginType': 'extendedop',
1769 'nsslapd-pluginEnabled': 'on',
1770 'nsslapd-plugin-depends-on-type': 'database',
1771 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1772 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1773 'slapimemberOfGroupAttr': 'manager',
1774 'slapimemberOfAttr': 'memberof',
1775 'slapimemberOfAllBackends': 'on',
1776 'slapimemberOfSkipNested': 'off',
1777 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
1778 'slapimemberOfMaxGroup': '3',
1779 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1780 'nsslapd-pluginVendor': '389 Project',
1781 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1782 topo.standalone.restart()
1783
1784 # Check the first subtree
1785 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0]
1786 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1787 _check_res_vs_expected("first subtree", res, expected)
1788
1789 # Check the second subtree
1790 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0]
1791 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1792 _check_res_vs_expected("second subtree", res, expected)
1793
1794 # Check the third subtree
1795 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0]
1796 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1797 _check_res_vs_expected("third subtree", res, expected)
1798
1799 # check e_1_parent_1_0
1800 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0]
1801 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1802 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1803
1804 # check e_1_parent_1_1_0
1805 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0]
1806 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1807 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1808
1809 # check e_2_parent_1_1_0
1810 expected = [EMPTY_RESULT]
1811 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1812 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
1813
1814 # check e_2_parent_1_0
1815 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0]
1816 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
1817 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
1818
1819 # check e_2_parent_2_1_0
1820 expected = [e_1_parent_2_2_1_0]
1821 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
1822 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
1823
1824 # Check e_1_parent_3_0
1825 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1826 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
1827 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
1828
1829 # Check e_1_parent_1_3_0
1830 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1831 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
1832 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
1833
1834 # Check e_1_parent_1_1_3_0
1835 expected = [e_1_parent_1_1_1_3_0]
1836 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
1837 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
1838
1839 # Check e_1_parent_1_1_1_3_0
1840 expected = [EMPTY_RESULT]
1841 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
1842 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
1843
1844 def fin():
1845 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1846 for entry in entries:
1847 topo.standalone.delete_s(entry)
1848 topo.standalone.delete_s(dn_config)
1849
1850 request.addfinalizer(fin)
1851
1852 def test_slapi_memberof_reuse_if_possible_1(topo, request, install_test_plugin):
1853 """
1854 Test that management hierarchy (manager) is computed with slapi_memberof
1855 It requires slapi_memberof to reuse IF POSSIBLE the computed values
1856 from memberof plugins. As memberof plugin is not enabled, it falls back
1857 to regular computation (recompute)
1858 with following parameters
1859 - membership attribute: 'manager'
1860 - span over all backends: 'on'
1861 - skip nesting membership: 'off'
1862 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
1863 - Scope: DEFAULT_SUFFIX
1864 - ExcludeScope: None
1865 - Maximum return entries: None
1866
1867 :id: 8f75e4c9-60d4-41b8-8b25-df9fe4b0231d
1868 :setup: Standalone instance
1869 :steps:
1870 1. provision a set of entry
1871 2. configure test_slapi_memberof as described above
1872 3. check computed membership vs expected result
1873 :expectedresults:
1874 1. Operation should succeed
1875 2. Operation should succeed
1876 3. Operation should succeed
1877
1878 DIT is :
1879 e_1_parent_0
1880 - e_1_parent_1_0
1881 -- e_1_parent_1_1_0
1882 --- e_1_parent_1_1_1_0
1883 --- e_2_parent_1_1_1_0
1884 --- e_3_parent_1_1_1_0
1885 --- e_4_parent_1_1_1_0
1886 --- e_5_parent_1_1_1_0
1887 -- e_2_parent_1_1_0
1888 - e_2_parent_1_0
1889 -- e_1_parent_2_1_0
1890 -- e_2_parent_2_1_0
1891 --- e_1_parent_2_2_1_0
1892 -- e_3_parent_2_1_0
1893 -- e_4_parent_2_1_0
1894 e_2_parent_0
1895 - e_1_parent_2_0
1896 - e_2_parent_2_0
1897 - e_3_parent_2_0
1898 - e_4_parent_2_0
1899 e_3_parent_0
1900 - e_1_parent_3_0
1901 -- e_1_parent_1_3_0
1902 --- e_1_parent_1_1_3_0
1903 ---- e_1_parent_1_1_1_3_0
1904 """
1905 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
1906
1907 # First subtree
1908 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
1909
1910 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1911
1912 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1913
1914 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1915 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1916 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1917 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1918 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
1919
1920 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
1921
1922 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
1923
1924 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1925 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1926 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
1927 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1928 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
1929
1930 # 2nd subtree
1931 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
1932
1933 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1934 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1935 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1936 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
1937
1938 # third subtree
1939 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
1940
1941 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
1942
1943 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
1944
1945 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
1946
1947 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
1948
1949 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
1950 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
1951 'cn': 'test_slapi_memberof',
1952 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
1953 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
1954 'nsslapd-pluginType': 'extendedop',
1955 'nsslapd-pluginEnabled': 'on',
1956 'nsslapd-plugin-depends-on-type': 'database',
1957 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
1958 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
1959 'slapimemberOfGroupAttr': 'manager',
1960 'slapimemberOfAttr': 'memberof',
1961 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
1962 'slapimemberOfAllBackends': 'on',
1963 'slapimemberOfSkipNested': 'off',
1964 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
1965 'slapimemberOfMaxGroup': '0',
1966 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
1967 'nsslapd-pluginVendor': '389 Project',
1968 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
1969 topo.standalone.restart()
1970
1971 # Check the first subtree
1972 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
1973 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
1974 _check_res_vs_expected("first subtree", res, expected)
1975
1976 # Check the second subtree
1977 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
1978 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
1979 _check_res_vs_expected("second subtree", res, expected)
1980
1981 # Check the third subtree
1982 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
1983 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
1984 _check_res_vs_expected("third subtree", res, expected)
1985
1986 # check e_1_parent_1_0
1987 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
1988 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
1989 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
1990
1991 # check e_1_parent_1_1_0
1992 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
1993 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
1994 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
1995
1996 # check e_2_parent_1_1_0
1997 expected = [EMPTY_RESULT]
1998 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
1999 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2000
2001 # check e_2_parent_1_0
2002 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2003 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2004 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2005
2006 # check e_2_parent_2_1_0
2007 expected = [e_1_parent_2_2_1_0]
2008 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2009 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2010
2011 # Check e_1_parent_3_0
2012 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2013 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
2014 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
2015
2016 # Check e_1_parent_1_3_0
2017 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2018 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
2019 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
2020
2021 # Check e_1_parent_1_1_3_0
2022 expected = [e_1_parent_1_1_1_3_0]
2023 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
2024 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
2025
2026 # Check e_1_parent_1_1_1_3_0
2027 expected = [EMPTY_RESULT]
2028 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
2029 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
2030
2031 def fin():
2032 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2033 for entry in entries:
2034 topo.standalone.delete_s(entry)
2035 topo.standalone.delete_s(dn_config)
2036
2037 request.addfinalizer(fin)
2038
2039 def test_slapi_memberof_reuse_if_possible_2(topo, request, install_test_plugin):
2040 """
2041 Test that management hierarchy (manager) is computed with slapi_memberof
2042 It requires slapi_memberof to reuse IF POSSIBLE the computed values
2043 from memberof plugins.
2044 Memberof plugin is enabled, but with a different 'membership attribute'
2045 it falls back to regular computation (recompute)
2046 with following parameters
2047 - membership attribute: 'manager' <--
2048 - span over all backends: 'off'
2049 - skip nesting membership: 'off'
2050 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
2051 - Scope: DEFAULT_SUFFIX
2052 - ExcludeScope: None
2053 - Maximum return entries: None
2054
2055 :id: 2175578b-7f12-4f36-a4fe-eb401422643d
2056 :setup: Standalone instance
2057 :steps:
2058 1. Configure memberof with 'uniquemember' memberOfGroupAttr <--
2059 2. provision a set of entry
2060 3. configure test_slapi_memberof as described above
2061 4. check computed membership vs expected result
2062 :expectedresults:
2063 1. Operation should succeed
2064 2. Operation should succeed
2065 3. Operation should succeed
2066 4. Operation should succeed
2067
2068 DIT is :
2069 e_1_parent_0
2070 - e_1_parent_1_0
2071 -- e_1_parent_1_1_0
2072 --- e_1_parent_1_1_1_0
2073 --- e_2_parent_1_1_1_0
2074 --- e_3_parent_1_1_1_0
2075 --- e_4_parent_1_1_1_0
2076 --- e_5_parent_1_1_1_0
2077 -- e_2_parent_1_1_0
2078 - e_2_parent_1_0
2079 -- e_1_parent_2_1_0
2080 -- e_2_parent_2_1_0
2081 --- e_1_parent_2_2_1_0
2082 -- e_3_parent_2_1_0
2083 -- e_4_parent_2_1_0
2084 e_2_parent_0
2085 - e_1_parent_2_0
2086 - e_2_parent_2_0
2087 - e_3_parent_2_0
2088 - e_4_parent_2_0
2089 e_3_parent_0
2090 - e_1_parent_3_0
2091 -- e_1_parent_1_3_0
2092 --- e_1_parent_1_1_3_0
2093 ---- e_1_parent_1_1_1_3_0
2094 """
2095 memberof = MemberOfPlugin(topo.standalone)
2096 memberof.enable()
2097 memberof.replace('memberOfGroupAttr', 'uniquemember')
2098 topo.standalone.restart()
2099
2100 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
2101
2102 # First subtree
2103 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
2104
2105 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2106
2107 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2108
2109 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2110 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2111 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2112 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2113 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2114
2115 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2116
2117 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2118
2119 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2120 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2121 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
2122 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2123 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2124
2125 # 2nd subtree
2126 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
2127
2128 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2129 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2130 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2131 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2132
2133 # third subtree
2134 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
2135
2136 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
2137
2138 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
2139
2140 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
2141
2142 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
2143
2144 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
2145 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
2146 'cn': 'test_slapi_memberof',
2147 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
2148 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
2149 'nsslapd-pluginType': 'extendedop',
2150 'nsslapd-pluginEnabled': 'on',
2151 'nsslapd-plugin-depends-on-type': 'database',
2152 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
2153 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
2154 'slapimemberOfGroupAttr': 'manager',
2155 'slapimemberOfAttr': 'memberof',
2156 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
2157 'slapimemberOfAllBackends': 'off',
2158 'slapimemberOfSkipNested': 'off',
2159 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
2160 'slapimemberOfMaxGroup': '0',
2161 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
2162 'nsslapd-pluginVendor': '389 Project',
2163 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
2164 topo.standalone.restart()
2165
2166 # Check the first subtree
2167 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2168 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
2169 _check_res_vs_expected("first subtree", res, expected)
2170
2171 # Check the second subtree
2172 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
2173 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
2174 _check_res_vs_expected("second subtree", res, expected)
2175
2176 # Check the third subtree
2177 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2178 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
2179 _check_res_vs_expected("third subtree", res, expected)
2180
2181 # check e_1_parent_1_0
2182 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
2183 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
2184 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
2185
2186 # check e_1_parent_1_1_0
2187 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
2188 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
2189 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
2190
2191 # check e_2_parent_1_1_0
2192 expected = [EMPTY_RESULT]
2193 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
2194 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2195
2196 # check e_2_parent_1_0
2197 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2198 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2199 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2200
2201 # check e_2_parent_2_1_0
2202 expected = [e_1_parent_2_2_1_0]
2203 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2204 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2205
2206 # Check e_1_parent_3_0
2207 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2208 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
2209 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
2210
2211 # Check e_1_parent_1_3_0
2212 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2213 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
2214 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
2215
2216 # Check e_1_parent_1_1_3_0
2217 expected = [e_1_parent_1_1_1_3_0]
2218 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
2219 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
2220
2221 # Check e_1_parent_1_1_1_3_0
2222 expected = [EMPTY_RESULT]
2223 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
2224 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
2225
2226 def fin():
2227 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2228 for entry in entries:
2229 topo.standalone.delete_s(entry)
2230 topo.standalone.delete_s(dn_config)
2231
2232 request.addfinalizer(fin)
2233
2234 def test_slapi_memberof_reuse_if_possible_3(topo, request, install_test_plugin):
2235 """
2236 Test that management hierarchy (manager) is computed with slapi_memberof
2237 It requires slapi_memberof to reuse IF POSSIBLE the computed values
2238 from memberof plugins.
2239 Memberof plugin is enabled, but with a different 'memberOfAllBackends attribute'
2240 it falls back to regular computation (recompute)
2241 with following parameters
2242 - membership attribute: 'manager'
2243 - span over all backends: 'off' <--
2244 - skip nesting membership: 'off'
2245 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
2246 - Scope: DEFAULT_SUFFIX
2247 - ExcludeScope: None
2248 - Maximum return entries: None
2249
2250 :id: 11615fc6-67e8-4c4a-be76-d57baf0e1706
2251 :setup: Standalone instance
2252 :steps:
2253 1. Configure memberof with 'memberOfAllBackends: on' <--
2254 2. provision a set of entry
2255 3. configure test_slapi_memberof as described above
2256 4. check computed membership vs expected result
2257 :expectedresults:
2258 1. Operation should succeed
2259 2. Operation should succeed
2260 3. Operation should succeed
2261 4. Operation should succeed
2262
2263 DIT is :
2264 e_1_parent_0
2265 - e_1_parent_1_0
2266 -- e_1_parent_1_1_0
2267 --- e_1_parent_1_1_1_0
2268 --- e_2_parent_1_1_1_0
2269 --- e_3_parent_1_1_1_0
2270 --- e_4_parent_1_1_1_0
2271 --- e_5_parent_1_1_1_0
2272 -- e_2_parent_1_1_0
2273 - e_2_parent_1_0
2274 -- e_1_parent_2_1_0
2275 -- e_2_parent_2_1_0
2276 --- e_1_parent_2_2_1_0
2277 -- e_3_parent_2_1_0
2278 -- e_4_parent_2_1_0
2279 e_2_parent_0
2280 - e_1_parent_2_0
2281 - e_2_parent_2_0
2282 - e_3_parent_2_0
2283 - e_4_parent_2_0
2284 e_3_parent_0
2285 - e_1_parent_3_0
2286 -- e_1_parent_1_3_0
2287 --- e_1_parent_1_1_3_0
2288 ---- e_1_parent_1_1_1_3_0
2289 """
2290 memberof = MemberOfPlugin(topo.standalone)
2291 memberof.enable()
2292 memberof.replace('memberOfGroupAttr', 'manager')
2293 memberof.replace('memberOfAllBackends', 'on')
2294 topo.standalone.restart()
2295
2296 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
2297
2298 # First subtree
2299 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
2300
2301 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2302
2303 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2304
2305 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2306 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2307 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2308 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2309 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2310
2311 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2312
2313 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2314
2315 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2316 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2317 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
2318 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2319 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2320
2321 # 2nd subtree
2322 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
2323
2324 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2325 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2326 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2327 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2328
2329 # third subtree
2330 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
2331
2332 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
2333
2334 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
2335
2336 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
2337
2338 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
2339
2340 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
2341 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
2342 'cn': 'test_slapi_memberof',
2343 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
2344 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
2345 'nsslapd-pluginType': 'extendedop',
2346 'nsslapd-pluginEnabled': 'on',
2347 'nsslapd-plugin-depends-on-type': 'database',
2348 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
2349 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
2350 'slapimemberOfGroupAttr': 'manager',
2351 'slapimemberOfAttr': 'memberof',
2352 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
2353 'slapimemberOfAllBackends': 'off',
2354 'slapimemberOfSkipNested': 'off',
2355 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
2356 'slapimemberOfMaxGroup': '0',
2357 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
2358 'nsslapd-pluginVendor': '389 Project',
2359 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
2360 topo.standalone.restart()
2361
2362 # Check the first subtree
2363 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2364 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
2365 _check_res_vs_expected("first subtree", res, expected)
2366
2367 # Check the second subtree
2368 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
2369 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
2370 _check_res_vs_expected("second subtree", res, expected)
2371
2372 # Check the third subtree
2373 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2374 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
2375 _check_res_vs_expected("third subtree", res, expected)
2376
2377 # check e_1_parent_1_0
2378 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
2379 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
2380 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
2381
2382 # check e_1_parent_1_1_0
2383 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
2384 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
2385 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
2386
2387 # check e_2_parent_1_1_0
2388 expected = [EMPTY_RESULT]
2389 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
2390 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2391
2392 # check e_2_parent_1_0
2393 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2394 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2395 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2396
2397 # check e_2_parent_2_1_0
2398 expected = [e_1_parent_2_2_1_0]
2399 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2400 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2401
2402 # Check e_1_parent_3_0
2403 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2404 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
2405 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
2406
2407 # Check e_1_parent_1_3_0
2408 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2409 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
2410 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
2411
2412 # Check e_1_parent_1_1_3_0
2413 expected = [e_1_parent_1_1_1_3_0]
2414 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
2415 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
2416
2417 # Check e_1_parent_1_1_1_3_0
2418 expected = [EMPTY_RESULT]
2419 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
2420 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
2421
2422 def fin():
2423 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2424 for entry in entries:
2425 topo.standalone.delete_s(entry)
2426 topo.standalone.delete_s(dn_config)
2427
2428 request.addfinalizer(fin)
2429
2430
2431 def test_slapi_memberof_reuse_if_possible_4(topo, request, install_test_plugin):
2432 """
2433 Test that management hierarchy (manager) is computed with slapi_memberof
2434 It requires slapi_memberof to reuse IF POSSIBLE the computed values
2435 from memberof plugins.
2436 Memberof plugin is enabled, but with a different 'memberOfSkipNested' attr
2437 it falls back to regular computation (recompute)
2438 with following parameters
2439 - membership attribute: 'manager'
2440 - span over all backends: 'off'
2441 - skip nesting membership: 'off' <--
2442 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
2443 - Scope: DEFAULT_SUFFIX
2444 - ExcludeScope: None
2445 - Maximum return entries: None
2446
2447 :id: 305c99ba-5835-4b8c-bfb7-11deeea5eedc
2448 :setup: Standalone instance
2449 :steps:
2450 1. Configure memberof with 'memberOfSkipNested: on' <--
2451 2. provision a set of entry
2452 3. configure test_slapi_memberof as described above
2453 4. check computed membership vs expected result
2454 :expectedresults:
2455 1. Operation should succeed
2456 2. Operation should succeed
2457 3. Operation should succeed
2458 4. Operation should succeed
2459
2460 DIT is :
2461 e_1_parent_0
2462 - e_1_parent_1_0
2463 -- e_1_parent_1_1_0
2464 --- e_1_parent_1_1_1_0
2465 --- e_2_parent_1_1_1_0
2466 --- e_3_parent_1_1_1_0
2467 --- e_4_parent_1_1_1_0
2468 --- e_5_parent_1_1_1_0
2469 -- e_2_parent_1_1_0
2470 - e_2_parent_1_0
2471 -- e_1_parent_2_1_0
2472 -- e_2_parent_2_1_0
2473 --- e_1_parent_2_2_1_0
2474 -- e_3_parent_2_1_0
2475 -- e_4_parent_2_1_0
2476 e_2_parent_0
2477 - e_1_parent_2_0
2478 - e_2_parent_2_0
2479 - e_3_parent_2_0
2480 - e_4_parent_2_0
2481 e_3_parent_0
2482 - e_1_parent_3_0
2483 -- e_1_parent_1_3_0
2484 --- e_1_parent_1_1_3_0
2485 ---- e_1_parent_1_1_1_3_0
2486 """
2487 memberof = MemberOfPlugin(topo.standalone)
2488 memberof.enable()
2489 memberof.replace('memberOfGroupAttr', 'manager')
2490 memberof.replace('memberOfSkipNested', 'on')
2491 topo.standalone.restart()
2492
2493 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
2494
2495 # First subtree
2496 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
2497
2498 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2499
2500 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2501
2502 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2503 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2504 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2505 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2506 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2507
2508 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2509
2510 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2511
2512 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2513 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2514 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
2515 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2516 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2517
2518 # 2nd subtree
2519 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
2520
2521 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2522 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2523 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2524 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2525
2526 # third subtree
2527 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
2528
2529 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
2530
2531 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
2532
2533 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
2534
2535 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
2536
2537 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
2538 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
2539 'cn': 'test_slapi_memberof',
2540 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
2541 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
2542 'nsslapd-pluginType': 'extendedop',
2543 'nsslapd-pluginEnabled': 'on',
2544 'nsslapd-plugin-depends-on-type': 'database',
2545 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
2546 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
2547 'slapimemberOfGroupAttr': 'manager',
2548 'slapimemberOfAttr': 'memberof',
2549 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
2550 'slapimemberOfAllBackends': 'off',
2551 'slapimemberOfSkipNested': 'off',
2552 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
2553 'slapimemberOfMaxGroup': '0',
2554 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
2555 'nsslapd-pluginVendor': '389 Project',
2556 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
2557 topo.standalone.restart()
2558
2559 # Check the first subtree
2560 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2561 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
2562 _check_res_vs_expected("first subtree", res, expected)
2563
2564 # Check the second subtree
2565 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
2566 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
2567 _check_res_vs_expected("second subtree", res, expected)
2568
2569 # Check the third subtree
2570 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2571 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
2572 _check_res_vs_expected("third subtree", res, expected)
2573
2574 # check e_1_parent_1_0
2575 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
2576 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
2577 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
2578
2579 # check e_1_parent_1_1_0
2580 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
2581 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
2582 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
2583
2584 # check e_2_parent_1_1_0
2585 expected = [EMPTY_RESULT]
2586 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
2587 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2588
2589 # check e_2_parent_1_0
2590 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2591 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2592 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2593
2594 # check e_2_parent_2_1_0
2595 expected = [e_1_parent_2_2_1_0]
2596 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2597 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2598
2599 # Check e_1_parent_3_0
2600 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2601 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
2602 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
2603
2604 # Check e_1_parent_1_3_0
2605 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2606 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
2607 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
2608
2609 # Check e_1_parent_1_1_3_0
2610 expected = [e_1_parent_1_1_1_3_0]
2611 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
2612 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
2613
2614 # Check e_1_parent_1_1_1_3_0
2615 expected = [EMPTY_RESULT]
2616 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
2617 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
2618
2619 def fin():
2620 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2621 for entry in entries:
2622 topo.standalone.delete_s(entry)
2623 topo.standalone.delete_s(dn_config)
2624
2625 request.addfinalizer(fin)
2626
2627
2628 def test_slapi_memberof_reuse_if_possible_5(topo, request, install_test_plugin):
2629 """
2630 Test that management hierarchy (manager) is computed with slapi_memberof
2631 It requires slapi_memberof to reuse IF POSSIBLE the computed values
2632 from memberof plugins.
2633 Memberof plugin is enabled, but with a different 'memberOfAttr' attr
2634 it falls back to regular computation (recompute)
2635 with following parameters
2636 - member attribute: memberof <--
2637 - membership attribute: 'manager'
2638 - span over all backends: 'off'
2639 - skip nesting membership: 'off'
2640 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
2641 - Scope: DEFAULT_SUFFIX
2642 - ExcludeScope: None
2643 - Maximum return entries: None
2644
2645 :id: 66d2ed29-5d14-487a-b28a-5660962c7c6c
2646 :setup: Standalone instance
2647 :steps:
2648 1. Configure memberof with 'memberOfAttr: member' <--
2649 2. provision a set of entry
2650 3. configure test_slapi_memberof as described above
2651 4. check computed membership vs expected result
2652 :expectedresults:
2653 1. Operation should succeed
2654 2. Operation should succeed
2655 3. Operation should succeed
2656 4. Operation should succeed
2657
2658 DIT is :
2659 e_1_parent_0
2660 - e_1_parent_1_0
2661 -- e_1_parent_1_1_0
2662 --- e_1_parent_1_1_1_0
2663 --- e_2_parent_1_1_1_0
2664 --- e_3_parent_1_1_1_0
2665 --- e_4_parent_1_1_1_0
2666 --- e_5_parent_1_1_1_0
2667 -- e_2_parent_1_1_0
2668 - e_2_parent_1_0
2669 -- e_1_parent_2_1_0
2670 -- e_2_parent_2_1_0
2671 --- e_1_parent_2_2_1_0
2672 -- e_3_parent_2_1_0
2673 -- e_4_parent_2_1_0
2674 e_2_parent_0
2675 - e_1_parent_2_0
2676 - e_2_parent_2_0
2677 - e_3_parent_2_0
2678 - e_4_parent_2_0
2679 e_3_parent_0
2680 - e_1_parent_3_0
2681 -- e_1_parent_1_3_0
2682 --- e_1_parent_1_1_3_0
2683 ---- e_1_parent_1_1_1_3_0
2684 """
2685 memberof = MemberOfPlugin(topo.standalone)
2686 memberof.enable()
2687 memberof.replace('memberOfGroupAttr', 'manager')
2688
2689 # For the test memberOfAttr should differ from 'memberof' that is
2690 # used in slapi_memberof call. We can not use a dummy attribute
2691 # because it requires to be a DN syntax. Let's use 'member'
2692 memberof.replace('memberOfAttr', 'member')
2693 topo.standalone.restart()
2694
2695 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
2696
2697 # First subtree
2698 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
2699
2700 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2701
2702 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2703
2704 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2705 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2706 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2707 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2708 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2709
2710 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2711
2712 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2713
2714 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2715 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2716 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
2717 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2718 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2719
2720 # 2nd subtree
2721 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
2722
2723 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2724 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2725 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2726 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2727
2728 # third subtree
2729 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
2730
2731 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
2732
2733 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
2734
2735 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
2736
2737 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
2738
2739 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
2740 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
2741 'cn': 'test_slapi_memberof',
2742 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
2743 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
2744 'nsslapd-pluginType': 'extendedop',
2745 'nsslapd-pluginEnabled': 'on',
2746 'nsslapd-plugin-depends-on-type': 'database',
2747 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
2748 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
2749 'slapimemberOfGroupAttr': 'manager',
2750 'slapimemberOfAttr': 'memberof',
2751 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
2752 'slapimemberOfAllBackends': 'off',
2753 'slapimemberOfSkipNested': 'off',
2754 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
2755 'slapimemberOfMaxGroup': '0',
2756 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
2757 'nsslapd-pluginVendor': '389 Project',
2758 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
2759 topo.standalone.restart()
2760
2761 # Check the first subtree
2762 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2763 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
2764 _check_res_vs_expected("first subtree", res, expected)
2765
2766 # Check the second subtree
2767 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
2768 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
2769 _check_res_vs_expected("second subtree", res, expected)
2770
2771 # Check the third subtree
2772 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2773 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
2774 _check_res_vs_expected("third subtree", res, expected)
2775
2776 # check e_1_parent_1_0
2777 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
2778 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
2779 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
2780
2781 # check e_1_parent_1_1_0
2782 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
2783 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
2784 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
2785
2786 # check e_2_parent_1_1_0
2787 expected = [EMPTY_RESULT]
2788 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
2789 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2790
2791 # check e_2_parent_1_0
2792 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2793 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2794 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2795
2796 # check e_2_parent_2_1_0
2797 expected = [e_1_parent_2_2_1_0]
2798 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2799 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2800
2801 # Check e_1_parent_3_0
2802 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2803 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
2804 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
2805
2806 # Check e_1_parent_1_3_0
2807 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2808 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
2809 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
2810
2811 # Check e_1_parent_1_1_3_0
2812 expected = [e_1_parent_1_1_1_3_0]
2813 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
2814 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
2815
2816 # Check e_1_parent_1_1_1_3_0
2817 expected = [EMPTY_RESULT]
2818 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
2819 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
2820
2821 def fin():
2822 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2823 for entry in entries:
2824 topo.standalone.delete_s(entry)
2825 topo.standalone.delete_s(dn_config)
2826
2827 request.addfinalizer(fin)
2828
2829 def test_slapi_memberof_reuse_if_possible_6(topo, request, install_test_plugin):
2830 """
2831 Test that management hierarchy (manager) is computed with slapi_memberof
2832 It requires slapi_memberof to reuse IF POSSIBLE the computed values
2833 from memberof plugins.
2834 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScope' attr
2835 it falls back to regular computation (recompute)
2836 with following parameters
2837 - member attribute: memberof
2838 - membership attribute: 'manager'
2839 - span over all backends: 'off'
2840 - skip nesting membership: 'off'
2841 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
2842 - Scope: ou=people,dc=example,dc=com <--
2843 - ExcludeScope: None
2844 - Maximum return entries: None
2845
2846 :id: 4fbefa39-6c06-47c4-8818-a102944b7f29
2847 :setup: Standalone instance
2848 :steps:
2849 1. Configure memberof without 'memberOfEntryScope' <--
2850 2. provision a set of entry
2851 3. configure test_slapi_memberof as described above
2852 4. check computed membership vs expected result
2853 :expectedresults:
2854 1. Operation should succeed
2855 2. Operation should succeed
2856 3. Operation should succeed
2857 4. Operation should succeed
2858
2859 DIT is :
2860 e_1_parent_0
2861 - e_1_parent_1_0
2862 -- e_1_parent_1_1_0
2863 --- e_1_parent_1_1_1_0
2864 --- e_2_parent_1_1_1_0
2865 --- e_3_parent_1_1_1_0
2866 --- e_4_parent_1_1_1_0
2867 --- e_5_parent_1_1_1_0
2868 -- e_2_parent_1_1_0
2869 - e_2_parent_1_0
2870 -- e_1_parent_2_1_0
2871 -- e_2_parent_2_1_0
2872 --- e_1_parent_2_2_1_0
2873 -- e_3_parent_2_1_0
2874 -- e_4_parent_2_1_0
2875 e_2_parent_0
2876 - e_1_parent_2_0
2877 - e_2_parent_2_0
2878 - e_3_parent_2_0
2879 - e_4_parent_2_0
2880 e_3_parent_0
2881 - e_1_parent_3_0
2882 -- e_1_parent_1_3_0
2883 --- e_1_parent_1_1_3_0
2884 ---- e_1_parent_1_1_1_3_0
2885 """
2886 memberof = MemberOfPlugin(topo.standalone)
2887 memberof.enable()
2888 memberof.replace('memberOfGroupAttr', 'manager')
2889 topo.standalone.restart()
2890
2891 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
2892
2893 # First subtree
2894 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
2895
2896 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2897
2898 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2899
2900 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2901 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2902 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2903 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2904 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
2905
2906 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
2907
2908 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
2909
2910 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2911 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2912 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
2913 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2914 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
2915
2916 # 2nd subtree
2917 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
2918
2919 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2920 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2921 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2922 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
2923
2924 # third subtree
2925 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
2926
2927 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
2928
2929 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
2930
2931 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
2932
2933 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
2934
2935 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
2936 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
2937 'cn': 'test_slapi_memberof',
2938 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
2939 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
2940 'nsslapd-pluginType': 'extendedop',
2941 'nsslapd-pluginEnabled': 'on',
2942 'nsslapd-plugin-depends-on-type': 'database',
2943 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
2944 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
2945 'slapimemberOfGroupAttr': 'manager',
2946 'slapimemberOfAttr': 'memberof',
2947 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
2948 'slapimemberOfAllBackends': 'off',
2949 'slapimemberOfSkipNested': 'off',
2950 'slapimemberOfEntryScope': "ou=People,%s" % DEFAULT_SUFFIX,
2951 'slapimemberOfMaxGroup': '0',
2952 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
2953 'nsslapd-pluginVendor': '389 Project',
2954 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
2955 topo.standalone.restart()
2956
2957 # Check the first subtree
2958 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2959 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
2960 _check_res_vs_expected("first subtree", res, expected)
2961
2962 # Check the second subtree
2963 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
2964 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
2965 _check_res_vs_expected("second subtree", res, expected)
2966
2967 # Check the third subtree
2968 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2969 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
2970 _check_res_vs_expected("third subtree", res, expected)
2971
2972 # check e_1_parent_1_0
2973 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
2974 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
2975 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
2976
2977 # check e_1_parent_1_1_0
2978 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
2979 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
2980 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
2981
2982 # check e_2_parent_1_1_0
2983 expected = [EMPTY_RESULT]
2984 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
2985 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
2986
2987 # check e_2_parent_1_0
2988 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
2989 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
2990 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
2991
2992 # check e_2_parent_2_1_0
2993 expected = [e_1_parent_2_2_1_0]
2994 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
2995 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
2996
2997 # Check e_1_parent_3_0
2998 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
2999 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
3000 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
3001
3002 # Check e_1_parent_1_3_0
3003 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3004 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
3005 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
3006
3007 # Check e_1_parent_1_1_3_0
3008 expected = [e_1_parent_1_1_1_3_0]
3009 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
3010 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
3011
3012 # Check e_1_parent_1_1_1_3_0
3013 expected = [EMPTY_RESULT]
3014 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
3015 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
3016
3017 def fin():
3018 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3019 for entry in entries:
3020 topo.standalone.delete_s(entry)
3021 topo.standalone.delete_s(dn_config)
3022
3023 request.addfinalizer(fin)
3024
3025
3026 def test_slapi_memberof_reuse_if_possible_7(topo, request, install_test_plugin):
3027 """
3028 Test that management hierarchy (manager) is computed with slapi_memberof
3029 It requires slapi_memberof to reuse IF POSSIBLE the computed values
3030 from memberof plugins.
3031 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScope' attr
3032 it falls back to regular computation (recompute)
3033 with following parameters
3034 - member attribute: memberof
3035 - membership attribute: 'manager'
3036 - span over all backends: 'off'
3037 - skip nesting membership: 'off'
3038 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
3039 - Scope: ou=people,dc=example,dc=com <--
3040 - ExcludeScope: None
3041 - Maximum return entries: None
3042
3043 :id: b8cfca23-742f-44f0-8bb7-f93371954d40
3044 :setup: Standalone instance
3045 :steps:
3046 1. Configure memberof with 'memberOfEntryScope: ou=groups,dc=example,dc=com' <--
3047 2. provision a set of entry
3048 3. configure test_slapi_memberof as described above
3049 4. check computed membership vs expected result
3050 :expectedresults:
3051 1. Operation should succeed
3052 2. Operation should succeed
3053 3. Operation should succeed
3054 4. Operation should succeed
3055
3056 DIT is :
3057 e_1_parent_0
3058 - e_1_parent_1_0
3059 -- e_1_parent_1_1_0
3060 --- e_1_parent_1_1_1_0
3061 --- e_2_parent_1_1_1_0
3062 --- e_3_parent_1_1_1_0
3063 --- e_4_parent_1_1_1_0
3064 --- e_5_parent_1_1_1_0
3065 -- e_2_parent_1_1_0
3066 - e_2_parent_1_0
3067 -- e_1_parent_2_1_0
3068 -- e_2_parent_2_1_0
3069 --- e_1_parent_2_2_1_0
3070 -- e_3_parent_2_1_0
3071 -- e_4_parent_2_1_0
3072 e_2_parent_0
3073 - e_1_parent_2_0
3074 - e_2_parent_2_0
3075 - e_3_parent_2_0
3076 - e_4_parent_2_0
3077 e_3_parent_0
3078 - e_1_parent_3_0
3079 -- e_1_parent_1_3_0
3080 --- e_1_parent_1_1_3_0
3081 ---- e_1_parent_1_1_1_3_0
3082 """
3083 memberof = MemberOfPlugin(topo.standalone)
3084 memberof.enable()
3085 memberof.replace('memberOfGroupAttr', 'manager')
3086 memberof.replace('memberOfAllBackends', 'off')
3087 memberof.replace('memberOfSkipNested', 'off')
3088 memberof.replace('memberOfEntryScope', 'ou=groups,dc=example,dc=com')
3089 topo.standalone.restart()
3090
3091 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
3092
3093 # First subtree
3094 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
3095
3096 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3097
3098 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3099
3100 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3101 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3102 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3103 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3104 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3105
3106 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3107
3108 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3109
3110 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3111 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3112 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
3113 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3114 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3115
3116 # 2nd subtree
3117 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
3118
3119 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3120 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3121 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3122 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3123
3124 # third subtree
3125 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
3126
3127 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
3128
3129 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
3130
3131 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
3132
3133 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
3134
3135 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
3136 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
3137 'cn': 'test_slapi_memberof',
3138 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
3139 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
3140 'nsslapd-pluginType': 'extendedop',
3141 'nsslapd-pluginEnabled': 'on',
3142 'nsslapd-plugin-depends-on-type': 'database',
3143 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
3144 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
3145 'slapimemberOfGroupAttr': 'manager',
3146 'slapimemberOfAttr': 'memberof',
3147 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
3148 'slapimemberOfAllBackends': 'off',
3149 'slapimemberOfSkipNested': 'off',
3150 'slapimemberOfEntryScope': "ou=People,%s" % DEFAULT_SUFFIX,
3151 'slapimemberOfMaxGroup': '0',
3152 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
3153 'nsslapd-pluginVendor': '389 Project',
3154 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
3155 topo.standalone.restart()
3156
3157 # Check the first subtree
3158 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3159 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
3160 _check_res_vs_expected("first subtree", res, expected)
3161
3162 # Check the second subtree
3163 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
3164 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
3165 _check_res_vs_expected("second subtree", res, expected)
3166
3167 # Check the third subtree
3168 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3169 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
3170 _check_res_vs_expected("third subtree", res, expected)
3171
3172 # check e_1_parent_1_0
3173 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
3174 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
3175 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
3176
3177 # check e_1_parent_1_1_0
3178 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
3179 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
3180 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
3181
3182 # check e_2_parent_1_1_0
3183 expected = [EMPTY_RESULT]
3184 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
3185 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
3186
3187 # check e_2_parent_1_0
3188 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3189 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
3190 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
3191
3192 # check e_2_parent_2_1_0
3193 expected = [e_1_parent_2_2_1_0]
3194 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
3195 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
3196
3197 # Check e_1_parent_3_0
3198 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3199 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
3200 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
3201
3202 # Check e_1_parent_1_3_0
3203 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3204 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
3205 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
3206
3207 # Check e_1_parent_1_1_3_0
3208 expected = [e_1_parent_1_1_1_3_0]
3209 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
3210 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
3211
3212 # Check e_1_parent_1_1_1_3_0
3213 expected = [EMPTY_RESULT]
3214 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
3215 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
3216
3217 def fin():
3218 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3219 for entry in entries:
3220 topo.standalone.delete_s(entry)
3221 topo.standalone.delete_s(dn_config)
3222
3223 request.addfinalizer(fin)
3224
3225 def test_slapi_memberof_reuse_if_possible_8(topo, request, install_test_plugin):
3226 """
3227 Test that management hierarchy (manager) is computed with slapi_memberof
3228 It requires slapi_memberof to reuse IF POSSIBLE the computed values
3229 from memberof plugins.
3230 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScope' attr
3231 it falls back to regular computation (recompute)
3232 with following parameters
3233 - member attribute: memberof
3234 - membership attribute: 'manager'
3235 - span over all backends: 'off'
3236 - skip nesting membership: 'off'
3237 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
3238 - Scope: ou=people,dc=example,dc=com <--
3239 - ExcludeScope: None
3240 - Maximum return entries: None
3241
3242 :id: 5c990df5-8aa6-44c6-a9e1-f161c3e01d1e
3243 :setup: Standalone instance
3244 :steps:
3245 1. Configure memberof with
3246 - 'memberOfEntryScope: ou=groups,dc=example,dc=com' <--
3247 - 'memberOfEntryScope: ou=people,dc=example,dc=com' <--
3248 2. provision a set of entry
3249 3. configure test_slapi_memberof as described above
3250 4. check computed membership vs expected result
3251 :expectedresults:
3252 1. Operation should succeed
3253 2. Operation should succeed
3254 3. Operation should succeed
3255 4. Operation should succeed
3256
3257 DIT is :
3258 e_1_parent_0
3259 - e_1_parent_1_0
3260 -- e_1_parent_1_1_0
3261 --- e_1_parent_1_1_1_0
3262 --- e_2_parent_1_1_1_0
3263 --- e_3_parent_1_1_1_0
3264 --- e_4_parent_1_1_1_0
3265 --- e_5_parent_1_1_1_0
3266 -- e_2_parent_1_1_0
3267 - e_2_parent_1_0
3268 -- e_1_parent_2_1_0
3269 -- e_2_parent_2_1_0
3270 --- e_1_parent_2_2_1_0
3271 -- e_3_parent_2_1_0
3272 -- e_4_parent_2_1_0
3273 e_2_parent_0
3274 - e_1_parent_2_0
3275 - e_2_parent_2_0
3276 - e_3_parent_2_0
3277 - e_4_parent_2_0
3278 e_3_parent_0
3279 - e_1_parent_3_0
3280 -- e_1_parent_1_3_0
3281 --- e_1_parent_1_1_3_0
3282 ---- e_1_parent_1_1_1_3_0
3283 """
3284 memberof = MemberOfPlugin(topo.standalone)
3285 memberof.enable()
3286 memberof.replace('memberOfGroupAttr', 'manager')
3287 memberof.replace('memberOfAllBackends', 'off')
3288 memberof.replace('memberOfSkipNested', 'off')
3289 memberof.replace('memberOfEntryScope', DEFAULT_SUFFIX)
3290 memberof.replace('memberOfEntryScope', 'ou=groups,dc=example,dc=com')
3291 memberof.add('memberOfEntryScope', 'ou=people,dc=example,dc=com')
3292 topo.standalone.restart()
3293
3294 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
3295
3296 # First subtree
3297 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
3298
3299 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3300
3301 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3302
3303 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3304 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3305 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3306 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3307 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3308
3309 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3310
3311 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3312
3313 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3314 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3315 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
3316 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3317 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3318
3319 # 2nd subtree
3320 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
3321
3322 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3323 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3324 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3325 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3326
3327 # third subtree
3328 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
3329
3330 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
3331
3332 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
3333
3334 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
3335
3336 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
3337
3338 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
3339 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
3340 'cn': 'test_slapi_memberof',
3341 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
3342 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
3343 'nsslapd-pluginType': 'extendedop',
3344 'nsslapd-pluginEnabled': 'on',
3345 'nsslapd-plugin-depends-on-type': 'database',
3346 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
3347 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
3348 'slapimemberOfGroupAttr': 'manager',
3349 'slapimemberOfAttr': 'memberof',
3350 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
3351 'slapimemberOfAllBackends': 'off',
3352 'slapimemberOfSkipNested': 'off',
3353 'slapimemberOfEntryScope': "ou=People,%s" % DEFAULT_SUFFIX,
3354 'slapimemberOfMaxGroup': '0',
3355 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
3356 'nsslapd-pluginVendor': '389 Project',
3357 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
3358 topo.standalone.restart()
3359
3360 # Check the first subtree
3361 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3362 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
3363 _check_res_vs_expected("first subtree", res, expected)
3364
3365 # Check the second subtree
3366 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
3367 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
3368 _check_res_vs_expected("second subtree", res, expected)
3369
3370 # Check the third subtree
3371 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3372 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
3373 _check_res_vs_expected("third subtree", res, expected)
3374
3375 # check e_1_parent_1_0
3376 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
3377 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
3378 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
3379
3380 # check e_1_parent_1_1_0
3381 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
3382 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
3383 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
3384
3385 # check e_2_parent_1_1_0
3386 expected = [EMPTY_RESULT]
3387 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
3388 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
3389
3390 # check e_2_parent_1_0
3391 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3392 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
3393 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
3394
3395 # check e_2_parent_2_1_0
3396 expected = [e_1_parent_2_2_1_0]
3397 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
3398 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
3399
3400 # Check e_1_parent_3_0
3401 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3402 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
3403 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
3404
3405 # Check e_1_parent_1_3_0
3406 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3407 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
3408 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
3409
3410 # Check e_1_parent_1_1_3_0
3411 expected = [e_1_parent_1_1_1_3_0]
3412 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
3413 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
3414
3415 # Check e_1_parent_1_1_1_3_0
3416 expected = [EMPTY_RESULT]
3417 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
3418 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
3419
3420 def fin():
3421 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3422 for entry in entries:
3423 topo.standalone.delete_s(entry)
3424 topo.standalone.delete_s(dn_config)
3425
3426 request.addfinalizer(fin)
3427
3428 def test_slapi_memberof_reuse_if_possible_9(topo, request, install_test_plugin):
3429 """
3430 Test that management hierarchy (manager) is computed with slapi_memberof
3431 It requires slapi_memberof to reuse IF POSSIBLE the computed values
3432 from memberof plugins.
3433 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScopeExcludeSubtree' attr
3434 it falls back to regular computation (recompute)
3435 with following parameters
3436 - member attribute: memberof
3437 - membership attribute: 'manager'
3438 - span over all backends: 'off'
3439 - skip nesting membership: 'off'
3440 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
3441 - Scope: None
3442 - ExcludeScope: ou=groups,dc=example,dc=com <--
3443 - Maximum return entries: None
3444
3445 :id: 55ffe094-482b-4e2f-9d34-8b0a1ebd5248
3446 :setup: Standalone instance
3447 :steps:
3448 1. Configure memberof without 'memberOfEntryScopeExcludeSubtree' <--
3449 2. provision a set of entry
3450 3. configure test_slapi_memberof as described above
3451 4. check computed membership vs expected result
3452 :expectedresults:
3453 1. Operation should succeed
3454 2. Operation should succeed
3455 3. Operation should succeed
3456 4. Operation should succeed
3457
3458 DIT is :
3459 e_1_parent_0
3460 - e_1_parent_1_0
3461 -- e_1_parent_1_1_0
3462 --- e_1_parent_1_1_1_0
3463 --- e_2_parent_1_1_1_0
3464 --- e_3_parent_1_1_1_0
3465 --- e_4_parent_1_1_1_0
3466 --- e_5_parent_1_1_1_0
3467 -- e_2_parent_1_1_0
3468 - e_2_parent_1_0
3469 -- e_1_parent_2_1_0
3470 -- e_2_parent_2_1_0
3471 --- e_1_parent_2_2_1_0
3472 -- e_3_parent_2_1_0
3473 -- e_4_parent_2_1_0
3474 e_2_parent_0
3475 - e_1_parent_2_0
3476 - e_2_parent_2_0
3477 - e_3_parent_2_0
3478 - e_4_parent_2_0
3479 e_3_parent_0
3480 - e_1_parent_3_0
3481 -- e_1_parent_1_3_0
3482 --- e_1_parent_1_1_3_0
3483 ---- e_1_parent_1_1_1_3_0
3484 """
3485 memberof = MemberOfPlugin(topo.standalone)
3486 memberof.enable()
3487 memberof.replace('memberOfGroupAttr', 'manager')
3488 memberof.replace('memberOfAllBackends', 'off')
3489 memberof.replace('memberOfSkipNested', 'off')
3490 memberof.replace('memberOfEntryScope', DEFAULT_SUFFIX)
3491 topo.standalone.restart()
3492
3493 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
3494
3495 # First subtree
3496 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
3497
3498 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3499
3500 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3501
3502 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3503 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3504 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3505 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3506 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3507
3508 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3509
3510 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3511
3512 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3513 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3514 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
3515 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3516 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3517
3518 # 2nd subtree
3519 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
3520
3521 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3522 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3523 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3524 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3525
3526 # third subtree
3527 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
3528
3529 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
3530
3531 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
3532
3533 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
3534
3535 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
3536
3537 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
3538 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
3539 'cn': 'test_slapi_memberof',
3540 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
3541 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
3542 'nsslapd-pluginType': 'extendedop',
3543 'nsslapd-pluginEnabled': 'on',
3544 'nsslapd-plugin-depends-on-type': 'database',
3545 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
3546 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
3547 'slapimemberOfGroupAttr': 'manager',
3548 'slapimemberOfAttr': 'memberof',
3549 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
3550 'slapimemberOfAllBackends': 'off',
3551 'slapimemberOfSkipNested': 'off',
3552 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
3553 'slapimemberOfEntryScopeExcludeSubtree': "ou=Groups,%s" % DEFAULT_SUFFIX,
3554 'slapimemberOfMaxGroup': '0',
3555 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
3556 'nsslapd-pluginVendor': '389 Project',
3557 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
3558 topo.standalone.restart()
3559
3560 # Check the first subtree
3561 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3562 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
3563 _check_res_vs_expected("first subtree", res, expected)
3564
3565 # Check the second subtree
3566 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
3567 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
3568 _check_res_vs_expected("second subtree", res, expected)
3569
3570 # Check the third subtree
3571 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3572 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
3573 _check_res_vs_expected("third subtree", res, expected)
3574
3575 # check e_1_parent_1_0
3576 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
3577 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
3578 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
3579
3580 # check e_1_parent_1_1_0
3581 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
3582 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
3583 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
3584
3585 # check e_2_parent_1_1_0
3586 expected = [EMPTY_RESULT]
3587 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
3588 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
3589
3590 # check e_2_parent_1_0
3591 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3592 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
3593 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
3594
3595 # check e_2_parent_2_1_0
3596 expected = [e_1_parent_2_2_1_0]
3597 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
3598 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
3599
3600 # Check e_1_parent_3_0
3601 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3602 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
3603 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
3604
3605 # Check e_1_parent_1_3_0
3606 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3607 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
3608 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
3609
3610 # Check e_1_parent_1_1_3_0
3611 expected = [e_1_parent_1_1_1_3_0]
3612 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
3613 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
3614
3615 # Check e_1_parent_1_1_1_3_0
3616 expected = [EMPTY_RESULT]
3617 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
3618 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
3619
3620 def fin():
3621 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3622 for entry in entries:
3623 topo.standalone.delete_s(entry)
3624 topo.standalone.delete_s(dn_config)
3625
3626 request.addfinalizer(fin)
3627
3628
3629 def test_slapi_memberof_reuse_if_possible_10(topo, request, install_test_plugin):
3630 """
3631 Test that management hierarchy (manager) is computed with slapi_memberof
3632 It requires slapi_memberof to reuse IF POSSIBLE the computed values
3633 from memberof plugins.
3634 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScopeExcludeSubtree' attr
3635 it falls back to regular computation (recompute)
3636 with following parameters
3637 - member attribute: memberof
3638 - membership attribute: 'manager'
3639 - span over all backends: 'off'
3640 - skip nesting membership: 'off'
3641 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
3642 - Scope: DEFAULT_SUFFIX
3643 - ExcludeScope: ou=foo,dc=example,dc=com <--
3644 - Maximum return entries: None
3645
3646 :id: 6c26619d-e0e2-4b3e-938b-4cab817e928f
3647 :setup: Standalone instance
3648 :steps:
3649 1. Configure memberof with 'memberOfEntryScopeExcludeSubtree: ou=groups,dc=example,dc=com' <--
3650 2. provision a set of entry
3651 3. configure test_slapi_memberof as described above
3652 4. check computed membership vs expected result
3653 :expectedresults:
3654 1. Operation should succeed
3655 2. Operation should succeed
3656 3. Operation should succeed
3657 4. Operation should succeed
3658
3659 DIT is :
3660 e_1_parent_0
3661 - e_1_parent_1_0
3662 -- e_1_parent_1_1_0
3663 --- e_1_parent_1_1_1_0
3664 --- e_2_parent_1_1_1_0
3665 --- e_3_parent_1_1_1_0
3666 --- e_4_parent_1_1_1_0
3667 --- e_5_parent_1_1_1_0
3668 -- e_2_parent_1_1_0
3669 - e_2_parent_1_0
3670 -- e_1_parent_2_1_0
3671 -- e_2_parent_2_1_0
3672 --- e_1_parent_2_2_1_0
3673 -- e_3_parent_2_1_0
3674 -- e_4_parent_2_1_0
3675 e_2_parent_0
3676 - e_1_parent_2_0
3677 - e_2_parent_2_0
3678 - e_3_parent_2_0
3679 - e_4_parent_2_0
3680 e_3_parent_0
3681 - e_1_parent_3_0
3682 -- e_1_parent_1_3_0
3683 --- e_1_parent_1_1_3_0
3684 ---- e_1_parent_1_1_1_3_0
3685 """
3686 memberof = MemberOfPlugin(topo.standalone)
3687 memberof.enable()
3688 memberof.replace('memberOfGroupAttr', 'manager')
3689 memberof.replace('memberOfAllBackends', 'off')
3690 memberof.replace('memberOfSkipNested', 'off')
3691 memberof.replace('memberOfEntryScope', DEFAULT_SUFFIX)
3692 memberof.replace('memberOfEntryScopeExcludeSubtree', 'ou=groups,dc=example,dc=com')
3693 topo.standalone.restart()
3694
3695 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
3696
3697 # First subtree
3698 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
3699
3700 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3701
3702 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3703
3704 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3705 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3706 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3707 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3708 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3709
3710 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3711
3712 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3713
3714 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3715 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3716 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
3717 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3718 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3719
3720 # 2nd subtree
3721 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
3722
3723 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3724 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3725 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3726 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3727
3728 # third subtree
3729 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
3730
3731 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
3732
3733 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
3734
3735 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
3736
3737 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
3738
3739 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
3740 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
3741 'cn': 'test_slapi_memberof',
3742 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
3743 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
3744 'nsslapd-pluginType': 'extendedop',
3745 'nsslapd-pluginEnabled': 'on',
3746 'nsslapd-plugin-depends-on-type': 'database',
3747 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
3748 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
3749 'slapimemberOfGroupAttr': 'manager',
3750 'slapimemberOfAttr': 'memberof',
3751 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
3752 'slapimemberOfAllBackends': 'off',
3753 'slapimemberOfSkipNested': 'off',
3754 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
3755 'slapimemberOfEntryScopeExcludeSubtree': "ou=Foo,%s" % DEFAULT_SUFFIX,
3756 'slapimemberOfMaxGroup': '0',
3757 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
3758 'nsslapd-pluginVendor': '389 Project',
3759 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
3760 topo.standalone.restart()
3761
3762 # Check the first subtree
3763 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3764 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
3765 _check_res_vs_expected("first subtree", res, expected)
3766
3767 # Check the second subtree
3768 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
3769 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
3770 _check_res_vs_expected("second subtree", res, expected)
3771
3772 # Check the third subtree
3773 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3774 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
3775 _check_res_vs_expected("third subtree", res, expected)
3776
3777 # check e_1_parent_1_0
3778 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
3779 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
3780 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
3781
3782 # check e_1_parent_1_1_0
3783 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
3784 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
3785 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
3786
3787 # check e_2_parent_1_1_0
3788 expected = [EMPTY_RESULT]
3789 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
3790 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
3791
3792 # check e_2_parent_1_0
3793 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3794 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
3795 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
3796
3797 # check e_2_parent_2_1_0
3798 expected = [e_1_parent_2_2_1_0]
3799 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
3800 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
3801
3802 # Check e_1_parent_3_0
3803 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3804 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
3805 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
3806
3807 # Check e_1_parent_1_3_0
3808 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3809 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
3810 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
3811
3812 # Check e_1_parent_1_1_3_0
3813 expected = [e_1_parent_1_1_1_3_0]
3814 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
3815 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
3816
3817 # Check e_1_parent_1_1_1_3_0
3818 expected = [EMPTY_RESULT]
3819 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
3820 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
3821
3822 def fin():
3823 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3824 for entry in entries:
3825 topo.standalone.delete_s(entry)
3826 topo.standalone.delete_s(dn_config)
3827
3828 request.addfinalizer(fin)
3829
3830 def test_slapi_memberof_reuse_if_possible_11(topo, request, install_test_plugin):
3831 """
3832 Test that management hierarchy (manager) is computed with slapi_memberof
3833 It requires slapi_memberof to reuse IF POSSIBLE the computed values
3834 from memberof plugins.
3835 Memberof plugin is enabled, but with a different 'slapimemberOfEntryScope' attr
3836 it falls back to regular computation (recompute)
3837 with following parameters
3838 - member attribute: memberof
3839 - membership attribute: 'manager'
3840 - span over all backends: 'off'
3841 - skip nesting membership: 'off'
3842 - computation mode: MEMBEROF_REUSE_IF_POSSIBLE <--
3843 - Scope: None
3844 - ExcludeScope: ou=foo1,dc=example,dc=com <--
3845 - Maximum return entries: None
3846
3847 :id: 4c15995e-21a9-4443-8027-a0908345be50
3848 :setup: Standalone instance
3849 :steps:
3850 1. Configure memberof with
3851 - 'memberOfEntryScopeExcludeSubtree: ou=foo1,dc=example,dc=com' <--
3852 - 'memberOfEntryScopeExcludeSubtree: ou=foo2,dc=example,dc=com' <--
3853 2. provision a set of entry
3854 3. configure test_slapi_memberof as described above
3855 4. check computed membership vs expected result
3856 :expectedresults:
3857 1. Operation should succeed
3858 2. Operation should succeed
3859 3. Operation should succeed
3860 4. Operation should succeed
3861
3862 DIT is :
3863 e_1_parent_0
3864 - e_1_parent_1_0
3865 -- e_1_parent_1_1_0
3866 --- e_1_parent_1_1_1_0
3867 --- e_2_parent_1_1_1_0
3868 --- e_3_parent_1_1_1_0
3869 --- e_4_parent_1_1_1_0
3870 --- e_5_parent_1_1_1_0
3871 -- e_2_parent_1_1_0
3872 - e_2_parent_1_0
3873 -- e_1_parent_2_1_0
3874 -- e_2_parent_2_1_0
3875 --- e_1_parent_2_2_1_0
3876 -- e_3_parent_2_1_0
3877 -- e_4_parent_2_1_0
3878 e_2_parent_0
3879 - e_1_parent_2_0
3880 - e_2_parent_2_0
3881 - e_3_parent_2_0
3882 - e_4_parent_2_0
3883 e_3_parent_0
3884 - e_1_parent_3_0
3885 -- e_1_parent_1_3_0
3886 --- e_1_parent_1_1_3_0
3887 ---- e_1_parent_1_1_1_3_0
3888 """
3889 memberof = MemberOfPlugin(topo.standalone)
3890 memberof.enable()
3891 memberof.replace('memberOfGroupAttr', 'manager')
3892 memberof.replace('memberOfAllBackends', 'off')
3893 memberof.replace('memberOfSkipNested', 'off')
3894 memberof.replace('memberOfEntryScope', DEFAULT_SUFFIX)
3895 memberof.replace('memberOfEntryScopeExcludeSubtree', 'ou=foo1,dc=example,dc=com')
3896 memberof.add('memberOfEntryScopeExcludeSubtree', 'ou=foo2,dc=example,dc=com')
3897 topo.standalone.restart()
3898
3899 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
3900
3901 # First subtree
3902 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
3903
3904 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3905
3906 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3907
3908 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3909 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3910 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3911 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3912 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
3913
3914 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
3915
3916 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
3917
3918 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3919 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3920 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
3921 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3922 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
3923
3924 # 2nd subtree
3925 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
3926
3927 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3928 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3929 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3930 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
3931
3932 # third subtree
3933 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
3934
3935 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
3936
3937 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
3938
3939 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
3940
3941 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
3942
3943 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
3944 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
3945 'cn': 'test_slapi_memberof',
3946 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
3947 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
3948 'nsslapd-pluginType': 'extendedop',
3949 'nsslapd-pluginEnabled': 'on',
3950 'nsslapd-plugin-depends-on-type': 'database',
3951 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
3952 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
3953 'slapimemberOfGroupAttr': 'manager',
3954 'slapimemberOfAttr': 'memberof',
3955 'slapimemberOfFlag': 'MEMBEROF_REUSE_IF_POSSIBLE',
3956 'slapimemberOfAllBackends': 'off',
3957 'slapimemberOfSkipNested': 'off',
3958 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
3959 'slapimemberOfEntryScopeExcludeSubtree': "ou=foo1,%s" % DEFAULT_SUFFIX,
3960 'slapimemberOfMaxGroup': '0',
3961 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
3962 'nsslapd-pluginVendor': '389 Project',
3963 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
3964 topo.standalone.restart()
3965
3966 # Check the first subtree
3967 expected = [ e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3968 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
3969 _check_res_vs_expected("first subtree", res, expected)
3970
3971 # Check the second subtree
3972 expected = [e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0]
3973 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
3974 _check_res_vs_expected("second subtree", res, expected)
3975
3976 # Check the third subtree
3977 expected = [e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
3978 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
3979 _check_res_vs_expected("third subtree", res, expected)
3980
3981 # check e_1_parent_1_0
3982 expected = [e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0]
3983 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
3984 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
3985
3986 # check e_1_parent_1_1_0
3987 expected = [e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0]
3988 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
3989 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
3990
3991 # check e_2_parent_1_1_0
3992 expected = [EMPTY_RESULT]
3993 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
3994 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
3995
3996 # check e_2_parent_1_0
3997 expected = [e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0]
3998 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
3999 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
4000
4001 # check e_2_parent_2_1_0
4002 expected = [e_1_parent_2_2_1_0]
4003 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
4004 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
4005
4006 # Check e_1_parent_3_0
4007 expected = [e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
4008 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
4009 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
4010
4011 # Check e_1_parent_1_3_0
4012 expected = [e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
4013 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
4014 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
4015
4016 # Check e_1_parent_1_1_3_0
4017 expected = [e_1_parent_1_1_1_3_0]
4018 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
4019 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
4020
4021 # Check e_1_parent_1_1_1_3_0
4022 expected = [EMPTY_RESULT]
4023 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
4024 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
4025
4026 def fin():
4027 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
4028 for entry in entries:
4029 topo.standalone.delete_s(entry)
4030 topo.standalone.delete_s(dn_config)
4031
4032 request.addfinalizer(fin)
4033
4034 def test_slapi_memberof_reuse_only_1(topo, request, install_test_plugin):
4035 """
4036 Test that management hierarchy (manager) is computed with slapi_memberof
4037 It requires slapi_memberof to ONLY reuse the computed values
4038 from memberof plugins. As memberof plugin is not enabled, it returns
4039 no memberof.
4040 with following parameters
4041 - membership attribute: 'manager'
4042 - span over all backends: 'on'
4043 - skip nesting membership: 'off'
4044 - computation mode: MEMBEROF_REUSE_ONLY <--
4045 - Scope: DEFAULT_SUFFIX
4046 - ExcludeScope: None
4047 - Maximum return entries: None
4048
4049 :id: 7be9b188-2e84-4454-b6db-9e176014582a
4050 :setup: Standalone instance
4051 :steps:
4052 1. provision a set of entry
4053 2. configure test_slapi_memberof as described above
4054 3. check computed membership vs expected result
4055 :expectedresults:
4056 1. Operation should succeed
4057 2. Operation should succeed
4058 3. Operation should succeed
4059
4060 DIT is :
4061 e_1_parent_0
4062 - e_1_parent_1_0
4063 -- e_1_parent_1_1_0
4064 --- e_1_parent_1_1_1_0
4065 --- e_2_parent_1_1_1_0
4066 --- e_3_parent_1_1_1_0
4067 --- e_4_parent_1_1_1_0
4068 --- e_5_parent_1_1_1_0
4069 -- e_2_parent_1_1_0
4070 - e_2_parent_1_0
4071 -- e_1_parent_2_1_0
4072 -- e_2_parent_2_1_0
4073 --- e_1_parent_2_2_1_0
4074 -- e_3_parent_2_1_0
4075 -- e_4_parent_2_1_0
4076 e_2_parent_0
4077 - e_1_parent_2_0
4078 - e_2_parent_2_0
4079 - e_3_parent_2_0
4080 - e_4_parent_2_0
4081 e_3_parent_0
4082 - e_1_parent_3_0
4083 -- e_1_parent_1_3_0
4084 --- e_1_parent_1_1_3_0
4085 ---- e_1_parent_1_1_1_3_0
4086 """
4087 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX)
4088
4089 # First subtree
4090 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
4091
4092 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
4093
4094 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
4095
4096 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
4097 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
4098 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
4099 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
4100 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0", manager=[ensure_bytes(e_1_parent_1_1_0)])
4101
4102 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0", manager=[ensure_bytes(e_1_parent_1_0)])
4103
4104 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0", manager=[ensure_bytes(e_1_parent_0)])
4105
4106 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
4107 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
4108 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0", manager=[ensure_bytes(e_2_parent_2_1_0)])
4109 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
4110 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0", manager=[ensure_bytes(e_2_parent_1_0)])
4111
4112 # 2nd subtree
4113 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
4114
4115 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
4116 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
4117 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
4118 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0", manager=[ensure_bytes(e_2_parent_0)])
4119
4120 # third subtree
4121 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
4122
4123 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0", manager=[ensure_bytes(e_3_parent_0)])
4124
4125 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0", manager=[ensure_bytes(e_1_parent_3_0)])
4126
4127 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_3_0)])
4128
4129 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0", manager=[ensure_bytes(e_1_parent_1_1_3_0)])
4130
4131 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
4132 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
4133 'cn': 'test_slapi_memberof',
4134 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
4135 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
4136 'nsslapd-pluginType': 'extendedop',
4137 'nsslapd-pluginEnabled': 'on',
4138 'nsslapd-plugin-depends-on-type': 'database',
4139 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
4140 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
4141 'slapimemberOfGroupAttr': 'manager',
4142 'slapimemberOfAttr': 'memberof',
4143 'slapimemberOfFlag': 'MEMBEROF_REUSE_ONLY',
4144 'slapimemberOfAllBackends': 'off',
4145 'slapimemberOfSkipNested': 'off',
4146 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
4147 'slapimemberOfMaxGroup': '0',
4148 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
4149 'nsslapd-pluginVendor': '389 Project',
4150 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
4151 topo.standalone.restart()
4152
4153 # Check the first subtree
4154 expected = [EMPTY_RESULT]
4155 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="manager")
4156 _check_res_vs_expected("first subtree", res, expected)
4157
4158 # Check the second subtree
4159 expected = [EMPTY_RESULT]
4160 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="manager")
4161 _check_res_vs_expected("second subtree", res, expected)
4162
4163 # Check the third subtree
4164 expected = [EMPTY_RESULT]
4165 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="manager")
4166 _check_res_vs_expected("third subtree", res, expected)
4167
4168 # check e_1_parent_1_0
4169 expected = [EMPTY_RESULT]
4170 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="manager")
4171 _check_res_vs_expected("organisation reporting to e_1_parent_1_0", res, expected)
4172
4173 # check e_1_parent_1_1_0
4174 expected = [EMPTY_RESULT]
4175 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="manager")
4176 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
4177
4178 # check e_2_parent_1_1_0
4179 expected = [EMPTY_RESULT]
4180 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="manager")
4181 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
4182
4183 # check e_2_parent_1_0
4184 expected = [EMPTY_RESULT]
4185 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="manager")
4186 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
4187
4188 # check e_2_parent_2_1_0
4189 expected = [EMPTY_RESULT]
4190 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="manager")
4191 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
4192
4193 # Check e_1_parent_3_0
4194 expected = [EMPTY_RESULT]
4195 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="manager")
4196 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
4197
4198 # Check e_1_parent_1_3_0
4199 expected = [EMPTY_RESULT]
4200 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="manager")
4201 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
4202
4203 # Check e_1_parent_1_1_3_0
4204 expected = [EMPTY_RESULT]
4205 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="manager")
4206 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
4207
4208 # Check e_1_parent_1_1_1_3_0
4209 expected = [EMPTY_RESULT]
4210 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="manager")
4211 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
4212
4213 def fin():
4214 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
4215 for entry in entries:
4216 topo.standalone.delete_s(entry)
4217 topo.standalone.delete_s(dn_config)
4218
4219 request.addfinalizer(fin)
4220
4221 def test_slapi_memberof_reuse_only_2(topo, request, install_test_plugin):
4222 """
4223 Test that membership is computed with slapi_memberof
4224 It requires slapi_memberof to ONLY reuse the computed values
4225 from memberof plugins. As memberof plugin is enabled, it returns
4226 memberof.
4227 with following parameters
4228 - member attribute: memberof
4229 - membership attribute: 'member'
4230 - span over all backends: 'off'
4231 - skip nesting membership: 'off'
4232 - computation mode: MEMBEROF_REUSE_ONLY <--
4233 - Scope: None
4234 - ExcludeScope: dc=example,dc=com <--
4235 - Maximum return entries: None
4236
4237 :id: fb4f8c86-aa39-4252-90e0-36cfd7b3dd80
4238 :setup: Standalone instance
4239 :steps:
4240 1. Configure memberof with
4241 2. provision a set of entry
4242 3. configure test_slapi_memberof as described above
4243 4. check computed membership vs expected result
4244 :expectedresults:
4245 1. Operation should succeed
4246 2. Operation should succeed
4247 3. Operation should succeed
4248 4. Operation should succeed
4249
4250 DIT is :
4251 e_1_parent_0
4252 - e_1_parent_1_0
4253 -- e_1_parent_1_1_0
4254 --- e_1_parent_1_1_1_0
4255 --- e_2_parent_1_1_1_0
4256 --- e_3_parent_1_1_1_0
4257 --- e_4_parent_1_1_1_0
4258 --- e_5_parent_1_1_1_0
4259 -- e_2_parent_1_1_0
4260 - e_2_parent_1_0
4261 -- e_1_parent_2_1_0
4262 -- e_2_parent_2_1_0
4263 --- e_1_parent_2_2_1_0
4264 -- e_3_parent_2_1_0
4265 -- e_4_parent_2_1_0
4266 e_2_parent_0
4267 - e_1_parent_2_0
4268 - e_2_parent_2_0
4269 - e_3_parent_2_0
4270 - e_4_parent_2_0
4271 e_3_parent_0
4272 - e_1_parent_3_0
4273 -- e_1_parent_1_3_0
4274 --- e_1_parent_1_1_3_0
4275 ---- e_1_parent_1_1_1_3_0
4276 """
4277 # Configure memberof plugin to add 'memberof' attribute
4278 # to the members ('member') of groups that are in the suffix
4279 memberof = MemberOfPlugin(topo.standalone)
4280 memberof.enable()
4281 memberof.replace('memberOfAttr', 'memberof')
4282 memberof.replace('memberOfGroupAttr', 'member')
4283 memberof.replace('memberOfAllBackends', 'off')
4284 memberof.replace('memberOfSkipNested', 'off')
4285 memberof.replace('memberOfEntryScope', DEFAULT_SUFFIX)
4286 topo.standalone.restart()
4287
4288 #topo.standalone.config.replace('nsslapd-errorlog-level', '65536')
4289 #topo.standalone.config.set('nsslapd-accesslog-level','260')
4290 #topo.standalone.config.set('nsslapd-auditlog-logging-enabled','on')
4291 #topo.standalone.config.set('nsslapd-auditfaillog-logging-enabled','on')
4292 #topo.standalone.config.set('nsslapd-plugin-logging', 'on')
4293
4294 # First subtree
4295 e_1_parent_0 = add_entry(topo.standalone, uid="e_1_parent_0")
4296 e_1_parent_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_0")
4297 e_1_parent_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_0")
4298 e_1_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_0")
4299 e_2_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_1_0")
4300 e_3_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_3_parent_1_1_1_0")
4301 e_4_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_4_parent_1_1_1_0")
4302 e_5_parent_1_1_1_0 = add_entry(topo.standalone, uid="e_5_parent_1_1_1_0")
4303 e_2_parent_1_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_1_0")
4304 e_2_parent_1_0 = add_entry(topo.standalone, uid="e_2_parent_1_0")
4305 e_1_parent_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_1_0")
4306 e_2_parent_2_1_0 = add_entry(topo.standalone, uid="e_2_parent_2_1_0")
4307 e_1_parent_2_2_1_0 = add_entry(topo.standalone, uid="e_1_parent_2_2_1_0")
4308 e_3_parent_2_1_0 = add_entry(topo.standalone, uid="e_3_parent_2_1_0")
4309 e_4_parent_2_1_0 = add_entry(topo.standalone, uid="e_4_parent_2_1_0")
4310
4311 e_2_parent_0 = add_entry(topo.standalone, uid="e_2_parent_0")
4312 e_1_parent_2_0 = add_entry(topo.standalone, uid="e_1_parent_2_0")
4313 e_2_parent_2_0 = add_entry(topo.standalone, uid="e_2_parent_2_0")
4314 e_3_parent_2_0 = add_entry(topo.standalone, uid="e_3_parent_2_0")
4315 e_4_parent_2_0 = add_entry(topo.standalone, uid="e_4_parent_2_0")
4316
4317 e_3_parent_0 = add_entry(topo.standalone, uid="e_3_parent_0")
4318 e_1_parent_3_0 = add_entry(topo.standalone, uid="e_1_parent_3_0")
4319 e_1_parent_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_3_0")
4320 e_1_parent_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_3_0")
4321 e_1_parent_1_1_1_3_0 = add_entry(topo.standalone, uid="e_1_parent_1_1_1_3_0")
4322
4323 # e_1_parent_0
4324 # - e_1_parent_1_0
4325 # - e_2_parent_1_0
4326 members = [ensure_bytes(e_1_parent_1_0),
4327 ensure_bytes(e_2_parent_1_0)]
4328 mod = [(ldap.MOD_REPLACE, 'member', members)]
4329 topo.standalone.modify_s(e_1_parent_0, mod)
4330
4331 # - e_1_parent_1_0
4332 # -- e_1_parent_1_1_0
4333 # -- e_2_parent_1_1_0
4334 members = [ensure_bytes(e_1_parent_1_1_0),
4335 ensure_bytes(e_2_parent_1_1_0)]
4336 mod = [(ldap.MOD_REPLACE, 'member', members)]
4337 topo.standalone.modify_s(e_1_parent_1_0, mod)
4338
4339 # -- e_1_parent_1_1_0
4340 # --- e_1_parent_1_1_1_0
4341 # --- e_2_parent_1_1_1_0
4342 # --- e_3_parent_1_1_1_0
4343 # --- e_4_parent_1_1_1_0
4344 # --- e_5_parent_1_1_1_0
4345 members = [ensure_bytes(e_1_parent_1_1_1_0),
4346 ensure_bytes(e_2_parent_1_1_1_0),
4347 ensure_bytes(e_3_parent_1_1_1_0),
4348 ensure_bytes(e_4_parent_1_1_1_0),
4349 ensure_bytes(e_5_parent_1_1_1_0)]
4350 mod = [(ldap.MOD_REPLACE, 'member', members)]
4351 topo.standalone.modify_s(e_1_parent_1_1_0, mod)
4352
4353 # - e_2_parent_1_0
4354 # -- e_1_parent_2_1_0
4355 # -- e_2_parent_2_1_0
4356 # -- e_3_parent_2_1_0
4357 # -- e_4_parent_2_1_0
4358 members = [ensure_bytes(e_1_parent_2_1_0),
4359 ensure_bytes(e_2_parent_2_1_0),
4360 ensure_bytes(e_3_parent_2_1_0),
4361 ensure_bytes(e_4_parent_2_1_0)]
4362 mod = [(ldap.MOD_REPLACE, 'member', members)]
4363 topo.standalone.modify_s(e_2_parent_1_0, mod)
4364
4365 # -- e_2_parent_2_1_0
4366 # --- e_1_parent_2_2_1_0
4367 members = [ensure_bytes(e_1_parent_2_2_1_0)]
4368 mod = [(ldap.MOD_REPLACE, 'member', members)]
4369 topo.standalone.modify_s(e_2_parent_2_1_0, mod)
4370
4371 # e_2_parent_0
4372 # - e_1_parent_2_0
4373 # - e_2_parent_2_0
4374 # - e_3_parent_2_0
4375 # - e_4_parent_2_0
4376 members = [ensure_bytes(e_1_parent_2_0),
4377 ensure_bytes(e_2_parent_2_0),
4378 ensure_bytes(e_3_parent_2_0),
4379 ensure_bytes(e_4_parent_2_0)]
4380 mod = [(ldap.MOD_REPLACE, 'member', members)]
4381 topo.standalone.modify_s(e_2_parent_0, mod)
4382
4383 # e_3_parent_0
4384 # - e_1_parent_3_0
4385 members = [ensure_bytes(e_1_parent_3_0)]
4386 mod = [(ldap.MOD_REPLACE, 'member', members)]
4387 topo.standalone.modify_s(e_3_parent_0, mod)
4388
4389 # - e_1_parent_3_0
4390 # -- e_1_parent_1_3_0
4391 members = [ensure_bytes(e_1_parent_1_3_0)]
4392 mod = [(ldap.MOD_REPLACE, 'member', members)]
4393 topo.standalone.modify_s(e_1_parent_3_0, mod)
4394
4395 # -- e_1_parent_1_3_0
4396 # --- e_1_parent_1_1_3_0
4397 members = [ensure_bytes(e_1_parent_1_1_3_0)]
4398 mod = [(ldap.MOD_REPLACE, 'member', members)]
4399 topo.standalone.modify_s(e_1_parent_1_3_0, mod)
4400
4401 # --- e_1_parent_1_1_3_0
4402 # ---- e_1_parent_1_1_1_3_0
4403 members = [ensure_bytes(e_1_parent_1_1_1_3_0)]
4404 mod = [(ldap.MOD_REPLACE, 'member', members)]
4405 topo.standalone.modify_s(e_1_parent_1_1_3_0, mod)
4406
4407 #
4408 # configure the test plugin to request 'memberof' with the
4409 # same scope and groupAttr ('member') so that we can
4410 # reuse the values computed by memberof plugin
4411 #
4412 dn_config = 'cn=test_slapi_memberof,cn=plugins,cn=config'
4413 topo.standalone.add_s(Entry((dn_config, {'objectclass': 'top nsSlapdPlugin extensibleObject'.split(),
4414 'cn': 'test_slapi_memberof',
4415 'nsslapd-pluginPath': 'libtest_slapi_memberof-plugin',
4416 'nsslapd-pluginInitfunc': 'test_slapi_memberof_init',
4417 'nsslapd-pluginType': 'extendedop',
4418 'nsslapd-pluginEnabled': 'on',
4419 'nsslapd-plugin-depends-on-type': 'database',
4420 'nsslapd-pluginId': 'test_slapi_memberof-plugin',
4421 'slapimemberOfMemberDN': 'uid=test_user_11,ou=People,dc=example,dc=com',
4422 'slapimemberOfGroupAttr': 'member',
4423 'slapimemberOfAttr': 'memberof',
4424 'slapimemberOfFlag': 'MEMBEROF_REUSE_ONLY',
4425 'slapimemberOfAllBackends': 'off',
4426 'slapimemberOfSkipNested': 'off',
4427 'slapimemberOfEntryScope': DEFAULT_SUFFIX,
4428 'slapimemberOfMaxGroup': '0',
4429 'nsslapd-pluginVersion': '2.3.2.202302131418git0e190fc3d',
4430 'nsslapd-pluginVendor': '389 Project',
4431 'nsslapd-pluginDescription': 'test_slapi_memberof extended operation plugin'})))
4432 topo.standalone.restart()
4433
4434 # Check the first subtree
4435 expected = [EMPTY_RESULT]
4436 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_0, relation="member")
4437 _check_res_vs_expected("first subtree", res, expected)
4438
4439 # Check the second subtree
4440 expected = [EMPTY_RESULT]
4441 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_0, relation="member")
4442 _check_res_vs_expected("second subtree", res, expected)
4443
4444 # Check the third subtree
4445 expected = [EMPTY_RESULT]
4446 res = _extop_test_slapi_member(server=topo.standalone, dn=e_3_parent_0, relation="member")
4447 _check_res_vs_expected("third subtree", res, expected)
4448
4449 # check e_1_parent_1_0
4450 expected = [e_1_parent_0]
4451 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_0, relation="member")
4452 _check_res_vs_expected("Groups which e_1_parent_1_0 is member of", res, expected)
4453
4454 # check e_1_parent_1_1_0
4455 expected = [e_1_parent_0, e_1_parent_1_0]
4456 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_0, relation="member")
4457 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_0", res, expected)
4458
4459 # check e_2_parent_1_1_0
4460 expected = [e_1_parent_0, e_1_parent_1_0]
4461 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_1_0, relation="member")
4462 _check_res_vs_expected("organisation reporting to e_2_parent_1_1_0", res, expected)
4463
4464 # check e_2_parent_1_0
4465 expected = [e_1_parent_0]
4466 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_1_0, relation="member")
4467 _check_res_vs_expected("organisation reporting to e_2_parent_1_0", res, expected)
4468
4469 # check e_2_parent_2_1_0
4470 expected = [e_1_parent_0, e_2_parent_1_0]
4471 res = _extop_test_slapi_member(server=topo.standalone, dn=e_2_parent_2_1_0, relation="member")
4472 _check_res_vs_expected("organisation reporting to e_2_parent_2_1_0", res, expected)
4473
4474 # Check e_1_parent_3_0
4475 expected = [e_3_parent_0]
4476 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_3_0, relation="member")
4477 _check_res_vs_expected("organisation reporting to e_1_parent_3_0", res, expected)
4478
4479 # Check e_1_parent_1_3_0
4480 expected = [e_3_parent_0, e_1_parent_3_0]
4481 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_3_0, relation="member")
4482 _check_res_vs_expected("organisation reporting to e_1_parent_1_3_0", res, expected)
4483
4484 # Check e_1_parent_1_1_3_0
4485 expected = [e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0]
4486 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_3_0, relation="member")
4487 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_3_0", res, expected)
4488
4489 # Check e_1_parent_1_1_1_3_0
4490 expected = [e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0]
4491 res = _extop_test_slapi_member(server=topo.standalone, dn=e_1_parent_1_1_1_3_0, relation="member")
4492 _check_res_vs_expected("organisation reporting to e_1_parent_1_1_1_3_0", res, expected)
4493
4494 def fin():
4495 entries = [e_1_parent_0, e_1_parent_1_0, e_1_parent_1_1_0, e_1_parent_1_1_1_0, e_2_parent_1_1_1_0, e_3_parent_1_1_1_0, e_4_parent_1_1_1_0, e_5_parent_1_1_1_0, e_2_parent_1_1_0, e_2_parent_1_0, e_1_parent_2_1_0, e_2_parent_2_1_0, e_1_parent_2_2_1_0, e_3_parent_2_1_0, e_4_parent_2_1_0, e_2_parent_0, e_1_parent_2_0, e_2_parent_2_0, e_3_parent_2_0, e_4_parent_2_0, e_3_parent_0, e_1_parent_3_0, e_1_parent_1_3_0, e_1_parent_1_1_3_0, e_1_parent_1_1_1_3_0]
4496 for entry in entries:
4497 topo.standalone.delete_s(entry)
4498 topo.standalone.delete_s(dn_config)
4499
4500 request.addfinalizer(fin)
4501
4502 if __name__ == "__main__":
4503 CURRENT_FILE = os.path.realpath(__file__)
4504 pytest.main("-s -v %s" % CURRENT_FILE)
4505