mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s4/dsdb/tests: port samba4.tombstone_reanimation for PY3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett abartlet@samba.org
This commit is contained in:
parent
59ff17cc75
commit
2200b22b34
@ -31,6 +31,7 @@ from samba.dcerpc import security
|
||||
from samba.dcerpc import drsblobs
|
||||
from samba.dcerpc.drsuapi import *
|
||||
from samba.tests.password_test import PasswordCommon
|
||||
from samba.compat import get_string
|
||||
|
||||
import samba.tests
|
||||
from ldb import (SCOPE_BASE, FLAG_MOD_ADD, FLAG_MOD_DELETE, FLAG_MOD_REPLACE, Dn, Message,
|
||||
@ -58,7 +59,7 @@ class RestoredObjectAttributesBaseTestCase(samba.tests.TestCase):
|
||||
super(RestoredObjectAttributesBaseTestCase, self).tearDown()
|
||||
|
||||
def GUID_string(self, guid):
|
||||
return self.samdb.schema_format_value("objectGUID", guid)
|
||||
return get_string(self.samdb.schema_format_value("objectGUID", guid))
|
||||
|
||||
def search_guid(self, guid, attrs=["*"]):
|
||||
res = self.samdb.search(base="<GUID=%s>" % self.GUID_string(guid),
|
||||
@ -129,12 +130,19 @@ class RestoredObjectAttributesBaseTestCase(samba.tests.TestCase):
|
||||
if expected_val == "**":
|
||||
# "**" values means "any"
|
||||
continue
|
||||
self.assertEqual(expected_val, str(actual_val),
|
||||
# if expected_val is e.g. ldb.bytes we can't depend on
|
||||
# str(actual_value) working, we may just get a decoding
|
||||
# error. Better to just compare raw values
|
||||
if not isinstance(expected_val, str):
|
||||
actual_val = actual_val[0]
|
||||
else:
|
||||
actual_val = str(actual_val)
|
||||
self.assertEqual(expected_val, actual_val,
|
||||
"Unexpected value (%s) for '%s', expected (%s)" % (
|
||||
str(actual_val), name, expected_val))
|
||||
repr(actual_val), name, repr(expected_val)))
|
||||
|
||||
def _check_metadata(self, metadata, expected):
|
||||
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob, str(metadata[0]))
|
||||
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob, metadata[0])
|
||||
|
||||
repl_array = []
|
||||
for o in repl.ctr.array:
|
||||
@ -261,7 +269,7 @@ class BaseRestoreObjectTestCase(RestoredObjectAttributesBaseTestCase):
|
||||
objDeleted1 = self.search_guid(guid1)
|
||||
self.restore_deleted_object(self.samdb, objDeleted1.dn, usr1, {"url": "www.samba.org"})
|
||||
objLive2 = self.search_dn(usr1)
|
||||
self.assertEqual(objLive2["url"][0], "www.samba.org")
|
||||
self.assertEqual(str(objLive2["url"][0]), "www.samba.org")
|
||||
samba.tests.delete_force(self.samdb, usr1)
|
||||
|
||||
def test_undelete_newuser(self):
|
||||
|
Loading…
Reference in New Issue
Block a user