s4-drs: Test situations for runtime constructed parentGUID
authorFernando J V da Silva <fernandojvsilva@yahoo.com.br>
Fri, 27 Nov 2009 14:25:18 +0000 (12:25 -0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 30 Nov 2009 10:17:28 +0000 (21:17 +1100)
Includes the following verifications for the constructed parentGUID:
- Checks if it returns nothing when there is no parent object
- Ensures that attributes mentioned after the parentGUID
are returned correctly (this avoid a bug pointed out by Tridge
during sync constructed parentGUID development)

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/lib/ldb/tests/python/ldap.py

index 408246b45c4e39b959faefb928b68d7b05979fc0..029242274134c5e12d81ebff795d18da67f5e0ab 100755 (executable)
@@ -566,11 +566,34 @@ objectClass: container
             "objectclass":"user",
             "samaccountname":"parentguidtest"});
         res1 = ldb.search(base="cn=parentguidtest,cn=users," + self.base_dn, scope=SCOPE_BASE,
-                          attrs=["parentGUID"]);
+                          attrs=["parentGUID", "samaccountname"]);
         res2 = ldb.search(base="cn=users," + self.base_dn,scope=SCOPE_BASE,
                           attrs=["objectGUID"]);
+        res3 = ldb.search(base=self.base_dn, scope=SCOPE_BASE,
+                          attrs=["parentGUID"]);
+
+        """Check if the parentGUID is valid """
         self.assertEquals(res1[0]["parentGUID"], res2[0]["objectGUID"]);
 
+        """Check if it returns nothing when there is no parent object"""
+        has_parentGUID = False
+        for key in res3[0].keys():
+            if key == "parentGUID":
+                has_parentGUID = True
+                break
+        self.assertFalse(has_parentGUID);
+
+        """Ensures that if you look for another object attribute after the constructed
+            parentGUID, it will return correctly"""
+        has_another_attribute = False
+        for key in res1[0].keys():
+            if key == "sAMAccountName":
+                has_another_attribute = True
+                break
+        self.assertTrue(has_another_attribute)
+        self.assertTrue(len(res1[0]["samaccountname"]) == 1)
+        self.assertEquals(res1[0]["samaccountname"][0], "parentguidtest");
+
         print "Testing parentGUID behaviour on rename\n"
 
         self.ldb.add({