1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

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
This commit is contained in:
Matthias Dieter Wallnöfer 2010-11-07 20:10:48 +01:00
parent 225f102106
commit 9ba7ce6acf

View File

@ -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",