diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-07 20:10:48 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-07 21:12:03 +0000 |
commit | 9ba7ce6acf0ea0679933fdac5e73925927673761 (patch) | |
tree | 00547a1070642e9bffe1e052d20d7e36a4e8044d /source4 | |
parent | 225f1021060cc2a4cede905e84aa41304f273bee (diff) | |
download | samba-9ba7ce6acf0ea0679933fdac5e73925927673761.tar.gz samba-9ba7ce6acf0ea0679933fdac5e73925927673761.tar.bz2 samba-9ba7ce6acf0ea0679933fdac5e73925927673761.zip |
s4:ldap.py - add more "objectGUID" related tests
Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Sun Nov 7 21:12:03 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/dsdb/tests/python/ldap.py | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index 18af214fd7..26969cca3c 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -25,6 +25,7 @@ from ldb import ERR_OBJECT_CLASS_VIOLATION, ERR_NOT_ALLOWED_ON_RDN from ldb import ERR_NAMING_VIOLATION, ERR_CONSTRAINT_VIOLATION from ldb import Message, MessageElement, Dn from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE +from ldb import timestring from samba import Ldb from samba.dsdb import (UF_NORMAL_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT, @@ -1250,12 +1251,85 @@ objectClass: container 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_objectGUID(self): + """Test objectGUID behaviour""" + print "Testing objectGUID behaviour\n" + + # The objectGUID cannot directly be set + try: + self.ldb.add_ldif(""" +dn: cn=ldaptestcontainer,""" + self.base_dn + """ +objectClass: container +objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d +""") + self.fail() + except LdbError, (num, _): + self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) + + 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"]) + 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]) + + self.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 + + self.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]) + + self.delete_force(self.ldb, "cn=ldaptestcontainer," + self.base_dn) + def test_parentGUID(self): """Test parentGUID behaviour""" print "Testing parentGUID behaviour\n" - # TODO: This seems to fail on Windows Server. Hidden attribute? - self.ldb.add({ "dn": "cn=parentguidtest,cn=users," + self.base_dn, "objectclass":"user", |