]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/dsdb/tests: port samba4.tombstone_reanimation for PY3
authorNoel Power <noel.power@suse.com>
Mon, 3 Sep 2018 17:47:20 +0000 (18:47 +0100)
committerNoel Power <npower@samba.org>
Thu, 6 Sep 2018 13:51:36 +0000 (15:51 +0200)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett abartlet@samba.org
source4/dsdb/tests/python/tombstone_reanimation.py

index c82cb4cce98b5dee20b304a47eadbd6819a94b9f..2e0f370dddc358dd6619d68e4ca0324f6dcf7dee 100755 (executable)
@@ -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):