summaryrefslogtreecommitdiff
path: root/source4/dsdb/tests/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2017-02-02 13:57:16 +1300
committerDouglas Bagnall <dbagnall@samba.org>2017-02-09 03:17:14 +0100
commitd3dec7a2329ea77101e97cd542e137b6becf7ba1 (patch)
tree77ac8e73316cb92fc546ccf23c4617d6f6c7a3b0 /source4/dsdb/tests/python
parentb69f48e19be0d3724768716663c4bfb55ab706a3 (diff)
downloadsamba-d3dec7a2329ea77101e97cd542e137b6becf7ba1.tar.gz
samba-d3dec7a2329ea77101e97cd542e137b6becf7ba1.tar.bz2
samba-d3dec7a2329ea77101e97cd542e137b6becf7ba1.zip
s4/linked_attribute tests: try adding linked attributes directly
Previously we have only added linked attributes using a modify. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Pair-programmed-with: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/tests/python')
-rw-r--r--source4/dsdb/tests/python/linked_attributes.py64
1 files changed, 51 insertions, 13 deletions
diff --git a/source4/dsdb/tests/python/linked_attributes.py b/source4/dsdb/tests/python/linked_attributes.py
index a6046194b8c..305ff63dc93 100644
--- a/source4/dsdb/tests/python/linked_attributes.py
+++ b/source4/dsdb/tests/python/linked_attributes.py
@@ -74,25 +74,24 @@ class LATests(samba.tests.TestCase):
if not opts.no_cleanup:
self.samdb.delete(self.ou, ['tree_delete:1'])
- def delete_user(self, user):
- self.samdb.delete(user['dn'])
- del self.users[self.users.index(user)]
-
- def add_object(self, cn, objectclass):
+ def add_object(self, cn, objectclass, more_attrs={}):
dn = "CN=%s,%s" % (cn, self.ou)
- self.samdb.add({'cn': cn,
- 'objectclass': objectclass,
- 'dn': dn})
+ attrs = {'cn': cn,
+ 'objectclass': objectclass,
+ 'dn': dn}
+ attrs.update(more_attrs)
+ self.samdb.add(attrs)
return dn
- def add_objects(self, n, objectclass, prefix=None):
+ def add_objects(self, n, objectclass, prefix=None, more_attrs={}):
if prefix is None:
prefix = objectclass
dns = []
for i in range(n):
dns.append(self.add_object("%s%d" % (prefix, i + 1),
- objectclass))
+ objectclass,
+ more_attrs=more_attrs))
return dns
def add_linked_attribute(self, src, dest, attr='member',
@@ -511,16 +510,17 @@ class LATests(samba.tests.TestCase):
relax_control = ['relax:0']
users = self.add_objects(10, 'user', 'u_relax')
- groups = self.add_objects(3, 'group', 'g_relax')
+ groups = self.add_objects(3, 'group', 'g_relax',
+ more_attrs={'member': users[:2]})
g_relax1, g_relax2, g_uptight = groups
# g_relax1 has all users added at once
# g_relax2 gets them one at a time in reverse order
# g_uptight never relaxes
- self.add_linked_attribute(g_relax1, users[:5], controls=relax_control)
+ self.add_linked_attribute(g_relax1, users[2:5], controls=relax_control)
- for u in reversed(users[:5]):
+ for u in reversed(users[2:5]):
self.add_linked_attribute(g_relax2, u, controls=relax_control)
self.add_linked_attribute(g_uptight, u)
@@ -571,6 +571,44 @@ class LATests(samba.tests.TestCase):
for u in users:
self.assert_back_links(u, groups)
+ def test_add_all_at_once(self):
+ """All these other tests are creating linked attributes after the
+ objects are there. We want to test creating them all at once
+ using LDIF.
+ """
+ users = self.add_objects(7, 'user', 'u_all_at_once')
+ g1, g3 = self.add_objects(2, 'group', 'g_all_at_once',
+ more_attrs={'member': users})
+ (g2,) = self.add_objects(1, 'group', 'g_all_at_once2',
+ more_attrs={'member': users[:5]})
+
+ self.assert_forward_links(g1, users)
+ self.assert_forward_links(g2, users[:5])
+ self.assert_forward_links(g3, users)
+ for u in users[:5]:
+ self.assert_back_links(u, [g1, g2, g3])
+ for u in users[5:]:
+ self.assert_back_links(u, [g1, g3])
+
+ self.remove_linked_attribute(g2, users[0])
+ self.remove_linked_attribute(g2, users[1])
+ self.add_linked_attribute(g2, users[1])
+ self.add_linked_attribute(g2, users[5])
+ self.add_linked_attribute(g2, users[6])
+
+ self.assert_forward_links(g1, users)
+ self.assert_forward_links(g2, users[1:])
+
+ for u in users[1:]:
+ self.remove_linked_attribute(g2, u)
+ self.remove_linked_attribute(g1, users)
+
+ for u in users:
+ self.samdb.delete(u)
+
+ self.assert_forward_links(g1, [])
+ self.assert_forward_links(g2, [])
+ self.assert_forward_links(g3, [])
def test_one_way_attributes(self):
e1, e2 = self.add_objects(2, 'msExchConfigurationContainer',