URL: https://github.com/freeipa/freeipa/pull/430
Author: MartinBasti
 Title: #430: [py3] tests_xmlrpc: do not call str() on bytes
Action: opened

PR body:
"""
Calling str() on bytes causes undesired side effect: it adds prefix "b"
to the result of conversion. The method decode() should be used instead.

https://fedorahosted.org/freeipa/ticket/4985
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/430/head:pr430
git checkout pr430
From 959dc8c7932f59dbf66fa66429da80991d162a57 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Wed, 1 Feb 2017 22:41:23 +0100
Subject: [PATCH] py3: tests_xmlrpc: do not call str() on bytes

Calling str() on bytes causes undesired side effect: it adds prefix "b"
to the result of conversion. The method decode() should be used instead.

https://fedorahosted.org/freeipa/ticket/4985
---
 ipatests/test_xmlrpc/test_caacl_profile_enforcement.py  | 2 +-
 ipatests/test_xmlrpc/test_kerberos_principal_aliases.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py b/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
index e5cf091..fa474c6 100644
--- a/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
+++ b/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
@@ -434,7 +434,7 @@ def santest_csr(request, santest_host_1, santest_host_2):
         pkey, hashes.SHA256(), backend
     ).public_bytes(serialization.Encoding.PEM)
 
-    return unicode(csr)
+    return csr.decode('ascii')
 
 
 class SubjectAltNameOneServiceBase(XMLRPC_test):
diff --git a/ipatests/test_xmlrpc/test_kerberos_principal_aliases.py b/ipatests/test_xmlrpc/test_kerberos_principal_aliases.py
index a1973af..9f062cc 100644
--- a/ipatests/test_xmlrpc/test_kerberos_principal_aliases.py
+++ b/ipatests/test_xmlrpc/test_kerberos_principal_aliases.py
@@ -260,7 +260,7 @@ def test_enterprise_principal_UPN_overlap(
         # Add an alias overlapping the UPN of a trusted domain
         upn_suffix = (
             trusted_domain_with_suffix['ldif']['ipaNTAdditionalSuffixes']
-        )
+        ).decode('utf-8')
 
         with pytest.raises(errors.ValidationError):
             krbalias_user.add_principal(
@@ -278,7 +278,7 @@ def test_enterprise_principal_NETBIOS_overlap(
         # Add an alias overlapping the NETBIOS name of a trusted domain
         netbios_name = (
             trusted_domain_with_suffix['ldif']['ipaNTFlatName']
-        )
+        ).decode('utf-8')
 
         with pytest.raises(errors.ValidationError):
             krbalias_user.add_principal(
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to