Cause forbidden when deactivating image(non-admin)
If a user tries to deactivate an image that is hosted by the admin that has public visiblity, it will currently return a 500 error. This changes that behaviour to return a Forbidden. Closes-Bug: 1485940 Change-Id: Id7f645fc599e57f6c0842bba2b7a2f3db52784ae
This commit is contained in:
parent
5b9127ad40
commit
15c08d822a
@ -328,6 +328,14 @@ class ImmutableImageProxy(object):
|
||||
message = _("You are not permitted to upload data for this image.")
|
||||
raise exception.Forbidden(message)
|
||||
|
||||
def deactivate(self, *args, **kwargs):
|
||||
message = _("You are not permitted to deactivate this image.")
|
||||
raise exception.Forbidden(message)
|
||||
|
||||
def activate(self, *args, **kwargs):
|
||||
message = _("You are not permitted to activate this image.")
|
||||
raise exception.Forbidden(message)
|
||||
|
||||
|
||||
class ImmutableMemberProxy(object):
|
||||
def __init__(self, base):
|
||||
|
@ -768,6 +768,12 @@ class TestImmutableImage(utils.BaseTestCase):
|
||||
self.assertRaises(exception.Forbidden,
|
||||
self.image.set_data, 'blah', 4)
|
||||
|
||||
def test_deactivate_image(self):
|
||||
self.assertRaises(exception.Forbidden, self.image.deactivate)
|
||||
|
||||
def test_activate_image(self):
|
||||
self.assertRaises(exception.Forbidden, self.image.activate)
|
||||
|
||||
def test_get_data(self):
|
||||
class FakeImage(object):
|
||||
def get_data(self):
|
||||
|
Loading…
Reference in New Issue
Block a user