Merge "Fix InvalidInput wrong message"
This commit is contained in:
commit
9e0e64a620
@ -554,7 +554,7 @@ class ShareMixin(object):
|
||||
try:
|
||||
self.share_api.extend(context, share, size, force=force)
|
||||
except (exception.InvalidInput, exception.InvalidShare) as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.message)
|
||||
raise webob.exc.HTTPBadRequest(explanation=str(e))
|
||||
except exception.ShareSizeExceedsAvailableQuota as e:
|
||||
raise webob.exc.HTTPForbidden(explanation=e.message)
|
||||
|
||||
@ -574,7 +574,7 @@ class ShareMixin(object):
|
||||
try:
|
||||
self.share_api.shrink(context, share, size)
|
||||
except (exception.InvalidInput, exception.InvalidShare) as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.message)
|
||||
raise webob.exc.HTTPBadRequest(explanation=str(e))
|
||||
|
||||
return webob.Response(status_int=http_client.ACCEPTED)
|
||||
|
||||
|
@ -280,7 +280,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin):
|
||||
raise exc.HTTPConflict(explanation=e.message)
|
||||
except (exception.ShareGroupSnapshotNotFound,
|
||||
exception.InvalidInput) as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.message)
|
||||
raise exc.HTTPBadRequest(explanation=str(e))
|
||||
|
||||
return self._view_builder.detail(
|
||||
req, {k: v for k, v in new_share_group.items()})
|
||||
|
@ -571,6 +571,23 @@ class ShareGroupAPITest(test.TestCase):
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'create')
|
||||
|
||||
def test_share_group_create_invalid_input(self):
|
||||
fake_snap_id = uuidutils.generate_uuid()
|
||||
body = {
|
||||
"share_group": {"source_share_group_snapshot_id": fake_snap_id}
|
||||
}
|
||||
self.mock_object(
|
||||
self.controller.share_group_api, 'create',
|
||||
mock.Mock(side_effect=exception.InvalidInput(
|
||||
reason='invalid input')))
|
||||
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.request, body)
|
||||
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'create')
|
||||
|
||||
def test_share_group_create_source_group_snapshot_not_a_uuid(self):
|
||||
fake_snap_id = "Not a uuid"
|
||||
body = {
|
||||
|
Loading…
Reference in New Issue
Block a user