s4-ldb: added a double-rename test
authorAndrew Tridgell <tridge@samba.org>
Fri, 20 Nov 2009 00:47:54 +0000 (11:47 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 20 Nov 2009 01:23:46 +0000 (12:23 +1100)
This tests the fix for double rename/add and indexing

source4/lib/ldb/tests/python/ldap.py

index ed8e663ac8c96ab2cf9c6a2e97f7a5da1fb38853..f9801e2f5a6f171629cf23bbfa0f59a0287a7dc7 100755 (executable)
@@ -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)