Commit d51a33e8 authored by Vincent Pelletier's avatar Vincent Pelletier

caucase.test: Fix testWSGI on python3.

wsgi.input is specified to be a bytes object, not a string object.
parent f3e938ac
......@@ -1860,7 +1860,7 @@ class CaucaseTest(unittest.TestCase):
self.assertEqual(request({
'PATH_INFO': '/cau/csr',
'REQUEST_METHOD': 'PUT',
'wsgi.input': StringIO(),
'wsgi.input': BytesIO(),
})[0], 500)
self.assertEqual(request({
'PATH_INFO': '/cau/csr',
......@@ -1897,50 +1897,50 @@ class CaucaseTest(unittest.TestCase):
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json',
'CONTENT_LENGTH': 'a',
'wsgi.input': StringIO(),
'wsgi.input': BytesIO(),
})[0], 400)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/renew',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json',
'CONTENT_LENGTH': str(wsgi.MAX_BODY_LENGTH + 1),
'wsgi.input': StringIO(),
'wsgi.input': BytesIO(),
})[0], 413)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/renew',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{'),
'wsgi.input': BytesIO(b'{'),
})[0], 400)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/revoke',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{"digest": null}'),
'wsgi.input': BytesIO(b'{"digest": null}'),
})[0], UNAUTHORISED_STATUS)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/revoke',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{"digest":"sha256","payload":""}'),
'wsgi.input': BytesIO(b'{"digest":"sha256","payload":""}'),
})[0], 400)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/a',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u''),
'wsgi.input': BytesIO(b''),
})[0], 400)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/123',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u''),
'wsgi.input': BytesIO(b''),
})[0], UNAUTHORISED_STATUS)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/123',
'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u'foo'),
'wsgi.input': BytesIO(b'foo'),
})[0], 400)
self.assertEqual(request({
'PATH_INFO': '/cau/crt/123',
......@@ -2125,7 +2125,7 @@ class CaucaseTest(unittest.TestCase):
'PATH_INFO': '/cors',
'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
'wsgi.input': StringIO(utils.toUnicode(urlencode(input_dict))),
'wsgi.input': BytesIO(urlencode(input_dict).encode('ascii')),
}
base_request_reader_dict.update(kw)
return base_request_reader_dict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment