summaryrefslogtreecommitdiff
path: root/src/mailman/rest/tests/test_root.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rest/tests/test_root.py')
-rw-r--r--src/mailman/rest/tests/test_root.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py
index c5787bcb1..49877c3ae 100644
--- a/src/mailman/rest/tests/test_root.py
+++ b/src/mailman/rest/tests/test_root.py
@@ -102,22 +102,23 @@ class TestRoot(unittest.TestCase):
}
response, raw_content = Http().request(url, 'GET', None, headers)
self.assertEqual(response.status, 401)
- content = json.loads(raw_content)
+ content = json.loads(raw_content.decode('utf-8'))
self.assertEqual(content['title'], '401 Unauthorized')
self.assertEqual(content['description'],
'The REST API requires authentication')
def test_unauthorized(self):
# Bad Basic Auth credentials results in a 401 error.
- auth = b64encode('baduser:badpass')
+ userpass = b64encode(b'baduser:badpass')
+ auth = 'Basic {}'.format(userpass.decode('ascii'))
url = 'http://localhost:9001/3.0/system'
headers = {
'Content-Type': 'application/x-www-form-urlencode',
- 'Authorization': 'Basic ' + auth,
+ 'Authorization': auth,
}
response, raw_content = Http().request(url, 'GET', None, headers)
self.assertEqual(response.status, 401)
- content = json.loads(raw_content)
+ content = json.loads(raw_content.decode('utf-8'))
self.assertEqual(content['title'], '401 Unauthorized')
self.assertEqual(content['description'],
'User is not authorized for the REST API')