Projet

Général

Profil

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

Paul Marillonnet, 18 avril 2019 14:45

Télécharger (1,26 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
8 8
from django.test import TestCase
9 9
from django.core.urlresolvers import reverse
10 10
from django.conf import settings
11
from django.utils.encoding import iri_to_uri
11
from django.utils.encoding import iri_to_uri, force_text
12 12
from django.shortcuts import resolve_url
13 13
from django.utils import six
14 14
from django.utils.six.moves.urllib import parse as urlparse
......
55 55

  
56 56

  
57 57
def basic_authorization_header(user, password=None):
58
    cred = base64.b64encode('%s:%s' % (user.username, password or user.username))
59
    return {'Authorization': 'Basic %s' % cred}
58
    cred = '%s:%s' % (user.username, password or user.username)
59
    b64_cred = base64.b64encode(cred.encode('ascii'))
60
    return {'Authorization': 'Basic %s' % str(force_text(b64_cred))}
60 61

  
61 62

  
62 63
def get_response_form(response, form='form'):
63
-