V1: Stop id changes after the image creation
Currently in v1 if someone tries to update the ID after the image is created it will cause a 500 to be returned (or if updating to the same ID a 200). This now returns a 403. ApiImpact Change-Id: Ibb40632f027b2b84f88aaf0a971a0f18de350187 Closes-Bug: 1483353 Closes-Bug: 1483688
This commit is contained in:
@@ -23,4 +23,4 @@ SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir')
|
||||
ACTIVE_IMMUTABLE = ('size', 'checksum')
|
||||
|
||||
# Metadata which cannot be changed (irrespective of the current image state)
|
||||
IMMUTABLE = ('status',)
|
||||
IMMUTABLE = ('status', 'id')
|
||||
|
||||
@@ -179,6 +179,21 @@ class TestGlanceAPI(base.IsolatedUnitTest):
|
||||
self.assertEqual(400, res.status_int)
|
||||
self.assertIn('Invalid value', res.body)
|
||||
|
||||
def test_updating_imageid_after_creation(self):
|
||||
# Test incorrect/illegal id update
|
||||
req = webob.Request.blank("/images/%s" % UUID1)
|
||||
req.method = 'PUT'
|
||||
req.headers['x-image-meta-id'] = '000000-000-0000-0000-000'
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(403, res.status_int)
|
||||
|
||||
# Test using id of another image
|
||||
req = webob.Request.blank("/images/%s" % UUID1)
|
||||
req.method = 'PUT'
|
||||
req.headers['x-image-meta-id'] = UUID2
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(403, res.status_int)
|
||||
|
||||
def test_bad_min_disk_size_update(self):
|
||||
fixture_headers = {'x-image-meta-disk-format': 'vhd',
|
||||
'x-image-meta-container-format': 'ovf',
|
||||
|
||||
Reference in New Issue
Block a user