From: Avishay Traeger Date: Mon, 21 Jan 2013 08:19:02 +0000 (+0200) Subject: Fix error for extra specs update with empty body. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=fee9b2ad61bb69d356e1280f0556afd808c5f128;p=openstack-build%2Fcinder-build.git Fix error for extra specs update with empty body. Fixes: bug #1090320 Change-Id: Ia2792d477f7670ecb2eb0c9c10dcbf1cf5b2389e --- diff --git a/cinder/api/contrib/types_extra_specs.py b/cinder/api/contrib/types_extra_specs.py index 40e43d737..5c298d95d 100644 --- a/cinder/api/contrib/types_extra_specs.py +++ b/cinder/api/contrib/types_extra_specs.py @@ -95,7 +95,8 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): context = req.environ['cinder.context'] authorize(context) if not body: - raise webob.exc.HTTPUnprocessableEntity() + expl = _('Request body empty') + raise webob.exc.HTTPBadRequest(explanation=expl) self._check_type(context, type_id) if not id in body: expl = _('Request body and URI mismatch') diff --git a/cinder/tests/api/contrib/test_types_extra_specs.py b/cinder/tests/api/contrib/test_types_extra_specs.py index 15baea7d5..49a6da6e4 100644 --- a/cinder/tests/api/contrib/test_types_extra_specs.py +++ b/cinder/tests/api/contrib/test_types_extra_specs.py @@ -149,6 +149,19 @@ class VolumeTypesExtraSpecsTest(test.TestCase): self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update, req, 1, 'bad', body) + def _extra_specs_empty_update(self, body): + req = fakes.HTTPRequest.blank('/v2/fake/types/1/extra_specs') + req.method = 'POST' + + self.assertRaises(webob.exc.HTTPBadRequest, + self.controller.update, req, '1', body) + + def test_update_no_body(self): + self._extra_specs_empty_update(body=None) + + def test_update_empty_body(self): + self._extra_specs_empty_update(body={}) + class VolumeTypeExtraSpecsSerializerTest(test.TestCase): def test_index_create_serializer(self): @@ -211,16 +224,3 @@ class VolumeTypeExtraSpecsUnprocessableEntityTestCase(test.TestCase): def test_create_malformed_entity(self): body = {'extra_specs': 'string'} self._unprocessable_extra_specs_create(body=body) - - def _unprocessable_extra_specs_update(self, body): - req = fakes.HTTPRequest.blank('/v2/fake/types/1/extra_specs') - req.method = 'POST' - - self.assertRaises(webob.exc.HTTPUnprocessableEntity, - self.controller.update, req, '1', body) - - def test_update_no_body(self): - self._unprocessable_extra_specs_update(body=None) - - def test_update_empty_body(self): - self._unprocessable_extra_specs_update(body={})