Projet

Général

Profil

0001-python3-basic-authz-header-encoding-in-tests-31175.patch

Paul Marillonnet, 16 octobre 2019 14:52

Télécharger (1,27 ko)

Voir les différences:

Subject: [PATCH] python3: basic authz header encoding in tests (#31175)

 tests/utils.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tests/utils.py
25 25
from django.test import TestCase
26 26
from django.core.urlresolvers import reverse
27 27
from django.conf import settings
28
from django.utils.encoding import iri_to_uri
28
from django.utils.encoding import iri_to_uri, force_text
29 29
from django.shortcuts import resolve_url
30 30
from django.utils import six
31 31
from django.utils.six.moves.urllib import parse as urlparse
......
72 72

  
73 73

  
74 74
def basic_authorization_header(user, password=None):
75
    cred = base64.b64encode('%s:%s' % (user.username, password or user.username))
76
    return {'Authorization': 'Basic %s' % cred}
75
    cred = '%s:%s' % (user.username, password or user.username)
76
    b64_cred = base64.b64encode(cred.encode('utf-8'))
77
    return {'Authorization': 'Basic %s' % str(force_text(b64_cred))}
77 78

  
78 79

  
79 80
def get_response_form(response, form='form'):
80
-