diff options
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/dsdb/tests/python/ldap.py | 209 |
1 files changed, 155 insertions, 54 deletions
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index 96331d2ee8..0a95b2a103 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -1327,60 +1327,6 @@ objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d "dn": "cn=ldaptestcontainer," + self.base_dn, "objectClass": "container" }) - res = ldb.search("cn=ldaptestcontainer," + self.base_dn, - scope=SCOPE_BASE, - attrs=["objectGUID", "uSNCreated", "uSNChanged", "whenCreated", "whenChanged"]) - self.assertTrue(len(res) == 1) - self.assertTrue("objectGUID" in res[0]) - self.assertTrue("uSNCreated" in res[0]) - self.assertTrue("uSNChanged" in res[0]) - self.assertTrue("whenCreated" in res[0]) - self.assertTrue("whenChanged" in res[0]) - - delete_force(self.ldb, "cn=ldaptestcontainer," + self.base_dn) - - # All the following attributes are specificable on add operations - self.ldb.add({ - "dn": "cn=ldaptestcontainer," + self.base_dn, - "objectClass": "container", - "uSNCreated" : "1", - "uSNChanged" : "1", - "whenCreated": timestring(long(time.time())), - "whenChanged": timestring(long(time.time())) }) - - res = ldb.search("cn=ldaptestcontainer," + self.base_dn, - scope=SCOPE_BASE, - attrs=["objectGUID", "uSNCreated", "uSNChanged", "whenCreated", "whenChanged"]) - self.assertTrue(len(res) == 1) - self.assertTrue("objectGUID" in res[0]) - self.assertTrue("uSNCreated" in res[0]) - self.assertFalse(res[0]["uSNCreated"][0] == "1") # these are corrected - self.assertTrue("uSNChanged" in res[0]) - self.assertFalse(res[0]["uSNChanged"][0] == "1") # these are corrected - - delete_force(self.ldb, "cn=ldaptestcontainer," + self.base_dn) - - # All this attributes are specificable on add operations - self.ldb.add({ - "dn": "cn=ldaptestcontainer," + self.base_dn, - "objectclass": "container", - "uSNCreated" : "1", - "uSNChanged" : "1", - "whenCreated": timestring(long(time.time())), - "whenChanged": timestring(long(time.time())) }) - - res = ldb.search("cn=ldaptestcontainer," + self.base_dn, - scope=SCOPE_BASE, - attrs=["objectGUID", "uSNCreated", "uSNChanged", "whenCreated", "whenChanged"]) - self.assertTrue(len(res) == 1) - self.assertTrue("objectGUID" in res[0]) - self.assertTrue("uSNCreated" in res[0]) - self.assertFalse(res[0]["uSNCreated"][0] == "1") # these are corrected - self.assertTrue("uSNChanged" in res[0]) - self.assertFalse(res[0]["uSNChanged"][0] == "1") # these are corrected - self.assertTrue("whenCreated" in res[0]) - self.assertTrue("whenChanged" in res[0]) - # The objectGUID cannot directly be changed try: self.ldb.modify_ldif(""" @@ -1469,6 +1415,161 @@ objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d delete_force(self.ldb, "cn=parentguidtest,cn=testotherusers," + self.base_dn) delete_force(self.ldb, "cn=testotherusers," + self.base_dn) + def test_usnChanged(self): + """Test usnChanged behaviour""" + print "Testing usnChanged behaviour\n" + + self.ldb.add({ + "dn": "cn=ldaptestcontainer," + self.base_dn, + "objectClass": "container" }) + + res = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["objectGUID", "uSNCreated", "uSNChanged", "whenCreated", "whenChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res[0]) + self.assertTrue("objectGUID" in res[0]) + self.assertTrue("uSNCreated" in res[0]) + self.assertTrue("uSNChanged" in res[0]) + self.assertTrue("whenCreated" in res[0]) + self.assertTrue("whenChanged" in res[0]) + + delete_force(self.ldb, "cn=ldaptestcontainer," + self.base_dn) + + # All this attributes are specificable on add operations + self.ldb.add({ + "dn": "cn=ldaptestcontainer," + self.base_dn, + "objectclass": "container", + "uSNCreated" : "1", + "uSNChanged" : "1", + "whenCreated": timestring(long(time.time())), + "whenChanged": timestring(long(time.time())) }) + + res = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["objectGUID", "uSNCreated", "uSNChanged", "whenCreated", "whenChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res[0]) + self.assertTrue("objectGUID" in res[0]) + self.assertTrue("uSNCreated" in res[0]) + self.assertFalse(res[0]["uSNCreated"][0] == "1") # these are corrected + self.assertTrue("uSNChanged" in res[0]) + self.assertFalse(res[0]["uSNChanged"][0] == "1") # these are corrected + self.assertTrue("whenCreated" in res[0]) + self.assertTrue("whenChanged" in res[0]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +replace: description +""") + + res2 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res2[0]) + self.assertEqual(res[0]["usnCreated"], res2[0]["usnCreated"]) + self.assertEqual(res[0]["usnCreated"], res2[0]["usnChanged"]) + self.assertEqual(res[0]["usnChanged"], res2[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +replace: description +description: test +""") + + res3 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res3[0]) + self.assertEqual("test", str(res3[0]["description"][0])) + self.assertEqual(res[0]["usnCreated"], res3[0]["usnCreated"]) + self.assertNotEqual(res[0]["usnCreated"], res3[0]["usnChanged"]) + self.assertNotEqual(res[0]["usnChanged"], res3[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +replace: description +description: test +""") + + res4 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res4[0]) + self.assertEqual("test", str(res4[0]["description"][0])) + self.assertEqual(res[0]["usnCreated"], res4[0]["usnCreated"]) + self.assertNotEqual(res3[0]["usnCreated"], res4[0]["usnChanged"]) + self.assertEqual(res3[0]["usnChanged"], res4[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +replace: description +description: test2 +""") + + res5 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res5[0]) + self.assertEqual("test2", str(res5[0]["description"][0])) + self.assertEqual(res[0]["usnCreated"], res5[0]["usnCreated"]) + self.assertNotEqual(res3[0]["usnChanged"], res5[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +delete: description +description: test2 +""") + + res6 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res6[0]) + self.assertEqual(res[0]["usnCreated"], res6[0]["usnCreated"]) + self.assertNotEqual(res5[0]["usnChanged"], res6[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +add: description +description: test3 +""") + + res7 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res7[0]) + self.assertEqual("test3", str(res7[0]["description"][0])) + self.assertEqual(res[0]["usnCreated"], res7[0]["usnCreated"]) + self.assertNotEqual(res6[0]["usnChanged"], res7[0]["usnChanged"]) + + ldb.modify_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +changetype: modify +delete: description +""") + + res8 = ldb.search("cn=ldaptestcontainer," + self.base_dn, + scope=SCOPE_BASE, + attrs=["uSNCreated", "uSNChanged", "description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res8[0]) + self.assertEqual(res[0]["usnCreated"], res8[0]["usnCreated"]) + self.assertNotEqual(res7[0]["usnChanged"], res8[0]["usnChanged"]) + + delete_force(self.ldb, "cn=ldaptestcontainer," + self.base_dn) + def test_groupType_int32(self): """Test groupType (int32) behaviour (should appear to be casted to a 32 bit signed integer before comparsion)""" print "Testing groupType (int32) behaviour\n" |