From: Noel Power Date: Mon, 3 Sep 2018 17:47:20 +0000 (+0100) Subject: s4/dsdb/tests: port samba4.tombstone_reanimation for PY3 X-Git-Tag: tdb-1.3.17~1720 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2200b22b345213539d49d374731cf076a8ce4a70;p=thirdparty%2Fsamba.git s4/dsdb/tests: port samba4.tombstone_reanimation for PY3 Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett abartlet@samba.org --- diff --git a/source4/dsdb/tests/python/tombstone_reanimation.py b/source4/dsdb/tests/python/tombstone_reanimation.py index c82cb4cce98..2e0f370dddc 100755 --- a/source4/dsdb/tests/python/tombstone_reanimation.py +++ b/source4/dsdb/tests/python/tombstone_reanimation.py @@ -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="" % 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):