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): ...@@ -1860,7 +1860,7 @@ class CaucaseTest(unittest.TestCase):
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/csr', 'PATH_INFO': '/cau/csr',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'wsgi.input': StringIO(), 'wsgi.input': BytesIO(),
})[0], 500) })[0], 500)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/csr', 'PATH_INFO': '/cau/csr',
...@@ -1897,50 +1897,50 @@ class CaucaseTest(unittest.TestCase): ...@@ -1897,50 +1897,50 @@ class CaucaseTest(unittest.TestCase):
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json', 'CONTENT_TYPE': 'application/json',
'CONTENT_LENGTH': 'a', 'CONTENT_LENGTH': 'a',
'wsgi.input': StringIO(), 'wsgi.input': BytesIO(),
})[0], 400) })[0], 400)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/renew', 'PATH_INFO': '/cau/crt/renew',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json', 'CONTENT_TYPE': 'application/json',
'CONTENT_LENGTH': str(wsgi.MAX_BODY_LENGTH + 1), 'CONTENT_LENGTH': str(wsgi.MAX_BODY_LENGTH + 1),
'wsgi.input': StringIO(), 'wsgi.input': BytesIO(),
})[0], 413) })[0], 413)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/renew', 'PATH_INFO': '/cau/crt/renew',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json', 'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{'), 'wsgi.input': BytesIO(b'{'),
})[0], 400) })[0], 400)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/revoke', 'PATH_INFO': '/cau/crt/revoke',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json', 'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{"digest": null}'), 'wsgi.input': BytesIO(b'{"digest": null}'),
})[0], UNAUTHORISED_STATUS) })[0], UNAUTHORISED_STATUS)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/revoke', 'PATH_INFO': '/cau/crt/revoke',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'application/json', 'CONTENT_TYPE': 'application/json',
'wsgi.input': StringIO(u'{"digest":"sha256","payload":""}'), 'wsgi.input': BytesIO(b'{"digest":"sha256","payload":""}'),
})[0], 400) })[0], 400)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/a', 'PATH_INFO': '/cau/crt/a',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain', 'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u''), 'wsgi.input': BytesIO(b''),
})[0], 400) })[0], 400)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/123', 'PATH_INFO': '/cau/crt/123',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain', 'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u''), 'wsgi.input': BytesIO(b''),
})[0], UNAUTHORISED_STATUS) })[0], UNAUTHORISED_STATUS)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/123', 'PATH_INFO': '/cau/crt/123',
'REQUEST_METHOD': 'PUT', 'REQUEST_METHOD': 'PUT',
'CONTENT_TYPE': 'text/plain', 'CONTENT_TYPE': 'text/plain',
'wsgi.input': StringIO(u'foo'), 'wsgi.input': BytesIO(b'foo'),
})[0], 400) })[0], 400)
self.assertEqual(request({ self.assertEqual(request({
'PATH_INFO': '/cau/crt/123', 'PATH_INFO': '/cau/crt/123',
...@@ -2125,7 +2125,7 @@ class CaucaseTest(unittest.TestCase): ...@@ -2125,7 +2125,7 @@ class CaucaseTest(unittest.TestCase):
'PATH_INFO': '/cors', 'PATH_INFO': '/cors',
'REQUEST_METHOD': 'POST', 'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': 'application/x-www-form-urlencoded', '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) base_request_reader_dict.update(kw)
return base_request_reader_dict 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