From 20a9676ef2311c05ec1bcc29940477d2bd77ba3f Mon Sep 17 00:00:00 2001 From: Paul Marillonnet Date: Wed, 10 Apr 2019 15:47:34 +0200 Subject: [PATCH] python3: basic authz header encoding in tests (#31175) --- tests/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index c9f922d79..728735404 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -25,7 +25,7 @@ import pytest from django.test import TestCase from django.core.urlresolvers import reverse from django.conf import settings -from django.utils.encoding import iri_to_uri +from django.utils.encoding import iri_to_uri, force_text from django.shortcuts import resolve_url from django.utils import six from django.utils.six.moves.urllib import parse as urlparse @@ -72,8 +72,9 @@ def logout(app): def basic_authorization_header(user, password=None): - cred = base64.b64encode('%s:%s' % (user.username, password or user.username)) - return {'Authorization': 'Basic %s' % cred} + cred = '%s:%s' % (user.username, password or user.username) + b64_cred = base64.b64encode(cred.encode('utf-8')) + return {'Authorization': 'Basic %s' % str(force_text(b64_cred))} def get_response_form(response, form='form'):