From 489c6b60d115af1416d48f058b86d78ff15ca787 Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Thu, 14 Jun 2012 13:47:06 -0500 Subject: 400 on unrecognized content type (bug 1012282) Unrecognized content type: http://paste.openstack.org/raw/18537/ Malformed JSON: http://paste.openstack.org/raw/18536/ Change-Id: I76afbf9300bcb1c11bed74eddbe4972c451c5877 --- tests/test_middleware.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/test_middleware.py') diff --git a/tests/test_middleware.py b/tests/test_middleware.py index a5740acd..fca39775 100644 --- a/tests/test_middleware.py +++ b/tests/test_middleware.py @@ -90,9 +90,8 @@ class JsonBodyMiddlewareTest(test.TestCase): req = make_request(body='{"arg1": "on', content_type='application/json', method='POST') - _middleware = middleware.JsonBodyMiddleware(None) - self.assertRaises(webob.exc.HTTPBadRequest, - _middleware.process_request, req) + resp = middleware.JsonBodyMiddleware(None).process_request(req) + self.assertEqual(resp.status_int, 400) def test_no_content_type(self): req = make_request(body='{"arg1": "one", "arg2": ["a"]}', @@ -105,6 +104,12 @@ class JsonBodyMiddlewareTest(test.TestCase): req = make_request(body='{"arg1": "one", "arg2": ["a"]}', content_type='text/plain', method='POST') + resp = middleware.JsonBodyMiddleware(None).process_request(req) + self.assertEqual(resp.status_int, 400) + + def test_unrecognized_content_type_without_body(self): + req = make_request(content_type='text/plain', + method='GET') middleware.JsonBodyMiddleware(None).process_request(req) params = req.environ.get(middleware.PARAMS_ENV, {}) self.assertEqual(params, {}) -- cgit