Merge "Return 400 if registry returns 400."
This commit is contained in:
commit
8d83124522
@ -93,6 +93,10 @@ class Controller(object):
|
|||||||
can_share = bool(body['member']['can_share'])
|
can_share = bool(body['member']['can_share'])
|
||||||
try:
|
try:
|
||||||
registry.add_member(req.context, image_id, id, can_share)
|
registry.add_member(req.context, image_id, id, can_share)
|
||||||
|
except exception.Invalid, e:
|
||||||
|
msg = "%s" % e
|
||||||
|
logger.debug(msg)
|
||||||
|
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||||
except exception.NotFound, e:
|
except exception.NotFound, e:
|
||||||
msg = "%s" % e
|
msg = "%s" % e
|
||||||
logger.debug(msg)
|
logger.debug(msg)
|
||||||
@ -121,6 +125,10 @@ class Controller(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
registry.replace_members(req.context, image_id, body)
|
registry.replace_members(req.context, image_id, body)
|
||||||
|
except exception.Invalid, e:
|
||||||
|
msg = "%s" % e
|
||||||
|
logger.debug(msg)
|
||||||
|
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||||
except exception.NotFound, e:
|
except exception.NotFound, e:
|
||||||
msg = "%s" % e
|
msg = "%s" % e
|
||||||
logger.debug(msg)
|
logger.debug(msg)
|
||||||
|
@ -148,6 +148,24 @@ class TestSharedImagesApi(keystone_utils.KeystoneTests):
|
|||||||
self.assertEqual(response.status, 200)
|
self.assertEqual(response.status, 200)
|
||||||
self.assertEqual(content, '{"images": []}')
|
self.assertEqual(content, '{"images": []}')
|
||||||
|
|
||||||
|
# Build path for the next couple of checks
|
||||||
|
path = ("http://%s:%d/v1/images/%s/members" %
|
||||||
|
("0.0.0.0", self.api_port, image_id))
|
||||||
|
|
||||||
|
# Make sure update with invalid data gets rejected with 400
|
||||||
|
body = {
|
||||||
|
'test': [
|
||||||
|
{
|
||||||
|
'member_id': keystone_utils.bacon_id,
|
||||||
|
'can_share': False,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
response, _ = self._request(path, 'PUT',
|
||||||
|
keystone_utils.pattieblack_token,
|
||||||
|
body=json.dumps(body))
|
||||||
|
self.assertEqual(response.status, 400)
|
||||||
|
|
||||||
# Replace froggy with bacon
|
# Replace froggy with bacon
|
||||||
body = {
|
body = {
|
||||||
'memberships': [
|
'memberships': [
|
||||||
@ -157,8 +175,6 @@ class TestSharedImagesApi(keystone_utils.KeystoneTests):
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
path = "http://%s:%d/v1/images/%s/members" % \
|
|
||||||
("0.0.0.0", self.api_port, image_id)
|
|
||||||
|
|
||||||
response, content = self._request(path, 'PUT',
|
response, content = self._request(path, 'PUT',
|
||||||
keystone_utils.pattieblack_token,
|
keystone_utils.pattieblack_token,
|
||||||
|
Loading…
Reference in New Issue
Block a user