python3: basic authz header encoding in tests (#31175)
This commit is contained in:
parent
1f73b6ebcd
commit
20a9676ef2
|
@ -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'):
|
||||
|
|
Loading…
Reference in New Issue