From: Noel Power Date: Wed, 9 May 2018 10:24:48 +0000 (+0100) Subject: python/samba/tests: make password_hash.py py2/py3 compatible X-Git-Tag: tdb-1.3.17~1759 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccbecac3b22d6039e2196ba766ad4113220cbde5;p=thirdparty%2Fsamba.git python/samba/tests: make password_hash.py py2/py3 compatible Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/password_hash.py b/python/samba/tests/password_hash.py index cd1577f0ec3..9892c3238a3 100644 --- a/python/samba/tests/password_hash.py +++ b/python/samba/tests/password_hash.py @@ -111,7 +111,7 @@ class PassWordHashTests(TestCase): res = self.ldb.search(base=self.ldb.get_config_basedn(), expression="ncName=%s" % self.ldb.get_default_basedn(), attrs=["nETBIOSName"]) - self.netbios_domain = res[0]["nETBIOSName"][0] + self.netbios_domain = str(res[0]["nETBIOSName"][0]) self.dns_domain = self.ldb.domain_dns_name() # Gets back the basedn @@ -161,7 +161,7 @@ class PassWordHashTests(TestCase): # Calculate and validate a Wdigest value def check_digest(self, user, realm, password, digest): expected = calc_digest(user, realm, password) - actual = binascii.hexlify(bytearray(digest)) + actual = binascii.hexlify(bytearray(digest)).decode('utf8') error = "Digest expected[%s], actual[%s], " \ "user[%s], realm[%s], pass[%s]" % \ (expected, actual, user, realm, password) @@ -312,7 +312,7 @@ class PassWordHashTests(TestCase): for (tag, alg, rounds) in expected: self.assertEquals(tag, up.hashes[i].scheme) - data = up.hashes[i].value.split("$") + data = up.hashes[i].value.decode('utf8').split("$") # Check we got the expected crypt algorithm self.assertEquals(alg, data[1]) @@ -323,7 +323,7 @@ class PassWordHashTests(TestCase): # Calculate the expected hash value expected = crypt.crypt(USER_PASS, cmd) - self.assertEquals(expected, up.hashes[i].value) + self.assertEquals(expected, up.hashes[i].value.decode('utf8')) i += 1 # Check that the correct nt_hash was stored for userPassword