From 47923ea5071ba6dca842edb8eb124030576fd4ca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Nov 2009 11:47:54 +1100 Subject: s4-ldb: added a double-rename test This tests the fix for double rename/add and indexing --- source4/lib/ldb/tests/python/ldap.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index ed8e663ac8..f9801e2f5a 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -109,6 +109,7 @@ class BasicTests(unittest.TestCase): self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer2," + self.base_dn) + self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestgroup2,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn) @@ -531,6 +532,28 @@ objectClass: container self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn) + def test_rename_twice(self): + """Tests the rename operation twice - this corresponds to a past bug""" + print "Tests the rename twice operation""" + + self.ldb.add({ + "dn": "cn=ldaptestuser5,cn=users," + self.base_dn, + "objectclass": ["user", "person"] }) + + ldb.rename("cn=ldaptestuser5,cn=users," + self.base_dn, "cn=ldaptestUSER5,cn=users," + self.base_dn) + self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn) + self.ldb.add({ + "dn": "cn=ldaptestuser5,cn=users," + self.base_dn, + "objectclass": ["user", "person"] }) + ldb.rename("cn=ldaptestuser5,cn=Users," + self.base_dn, "cn=ldaptestUSER5,cn=users," + self.base_dn) + res = ldb.search(expression="cn=ldaptestuser5") + print "Found %u records" % len(res) + self.assertEquals(len(res), 1, "Wrong number of hits for cn=ldaptestuser5") + res = ldb.search(expression="(&(cn=ldaptestuser5)(objectclass=user))") + print "Found %u records" % len(res) + self.assertEquals(len(res), 1, "Wrong number of hits for (&(cn=ldaptestuser5)(objectclass=user))") + self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn) + def test_parentGUID(self): """Test parentGUID behaviour""" print "Testing parentGUID behaviour\n" @@ -1632,6 +1655,7 @@ member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """ self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer2," + self.base_dn) + self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestgroup2,cn=users," + self.base_dn) self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn) -- cgit