summaryrefslogtreecommitdiff
path: root/src/mailman/testing/helpers.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-12-11 21:18:12 -0500
committerBarry Warsaw2014-12-11 21:18:12 -0500
commitfe7d286db796630b3bef326bd5106591940c0b5f (patch)
tree4a732db60a62d222a8dd998f596789022bbc64bf /src/mailman/testing/helpers.py
parent930a1c05b441000fbe5c3c4d8ae36d08bfe3dcdd (diff)
downloadmailman-fe7d286db796630b3bef326bd5106591940c0b5f.tar.gz
mailman-fe7d286db796630b3bef326bd5106591940c0b5f.tar.zst
mailman-fe7d286db796630b3bef326bd5106591940c0b5f.zip
Diffstat (limited to 'src/mailman/testing/helpers.py')
-rw-r--r--src/mailman/testing/helpers.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py
index 1de0e98cf..882e69cd9 100644
--- a/src/mailman/testing/helpers.py
+++ b/src/mailman/testing/helpers.py
@@ -333,7 +333,10 @@ def call_api(url, data=None, method=None, username=None, password=None):
basic_auth = '{0}:{1}'.format(
(config.webservice.admin_user if username is None else username),
(config.webservice.admin_pass if password is None else password))
- headers['Authorization'] = 'Basic ' + b64encode(basic_auth)
+ # b64encode() requires a bytes, but the header value must be str. Do the
+ # necessary conversion dances.
+ token = b64encode(basic_auth.encode('utf-8')).decode('ascii')
+ headers['Authorization'] = 'Basic ' + token
response, content = Http().request(url, method, data, headers)
# If we did not get a 2xx status code, make this look like a urllib2
# exception, for backward compatibility with existing doctests.