summaryrefslogtreecommitdiffstats
path: root/tests/test_middleware.py
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-06-14 13:47:06 -0500
committerDolph Mathews <dolph.mathews@gmail.com>2012-06-19 14:17:24 -0500
commit489c6b60d115af1416d48f058b86d78ff15ca787 (patch)
tree51541b9a572044ae5e79856b2b75b1d7d2d19a91 /tests/test_middleware.py
parent66a0b63dabffe4cb1d239be3ab68885e2f49f513 (diff)
downloadkeystone-489c6b60d115af1416d48f058b86d78ff15ca787.tar.gz
keystone-489c6b60d115af1416d48f058b86d78ff15ca787.tar.xz
keystone-489c6b60d115af1416d48f058b86d78ff15ca787.zip
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
Diffstat (limited to 'tests/test_middleware.py')
-rw-r--r--tests/test_middleware.py11
1 files changed, 8 insertions, 3 deletions
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, {})