selftest: enable py3 for samba.tests.krb5_credentials
authorJoe Guo <joeg@catalyst.net.nz>
Wed, 11 Apr 2018 05:44:26 +0000 (17:44 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 13 Apr 2018 05:27:13 +0000 (07:27 +0200)
Fix encoding issue.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/krb5_credentials.py
source4/selftest/tests.py

index cad19da249dbc81650d8ce878ea13a4b24ccb245..01694fe700953ae3213cab8f5ff72e30c5b6b1f2 100644 (file)
@@ -93,10 +93,9 @@ class PyKrb5CredentialsTests(TestCase):
         # remove the account if it exists, this will happen if a previous test
         # run failed
         delete_force(self.ldb, self.machine_dn)
-
-        utf16pw = unicode(
-            '"' + self.machine_pass.encode('utf-8') + '"', 'utf-8'
-        ).encode('utf-16-le')
+        # get unicode str for both py2 and py3
+        pass_unicode = self.machine_pass.encode('utf-8').decode('utf-8')
+        utf16pw = u'"{}"'.format(pass_unicode).encode('utf-16-le')
         self.ldb.add({
             "dn": self.machine_dn,
             "objectclass": "computer",
index f7942ea632a096938a197ce64d2b39456107ea48..d1e5bc6a50955aa1f0e1e5af10da7dde95537e34 100755 (executable)
@@ -721,7 +721,9 @@ planpythontestsuite("ad_dc_ntvfs:local",
 
 planoldpythontestsuite("ad_dc_ntvfs",
                        "samba.tests.krb5_credentials",
+                       py3_compatible=True,
                        extra_args=['-U"$USERNAME%$PASSWORD"'])
+
 for env in ["ad_dc_ntvfs", "vampire_dc", "promoted_dc"]:
     planoldpythontestsuite(env,
                            "samba.tests.py_credentials",