Skip schema validation on GET /v2/images/%s
These are server-generated, not user-generated, and schema validation should not be necessary. Rework a unit test that enforces this; bad data should be blocked at ingest, not blocked on reads. Co-authored-by: Stuart McLaren <stuart.mclaren@hp.com> Change-Id: Ib1926fec0e858b6eed43c7931a6d6c3a1708e70e Closes-Bug: 1501046
This commit is contained in:

committed by
Stuart McLaren

parent
dd588b475b
commit
214dbffc92
@@ -42,7 +42,7 @@ class ClientTestRequests(testutils.TestCase):
|
||||
|
||||
def test_show_bad_image_schema(self):
|
||||
# if kernel_id or ramdisk_id are not uuids, verify we
|
||||
# fail schema validation on 'show'
|
||||
# don't fail due to schema validation
|
||||
self.requests = self.useFixture(rm_fixture.Fixture())
|
||||
self.requests.get('http://example.com/v2/schemas/image',
|
||||
json=schema_fixture)
|
||||
@@ -50,9 +50,5 @@ class ClientTestRequests(testutils.TestCase):
|
||||
% image_show_fixture['id'],
|
||||
json=image_show_fixture)
|
||||
gc = client.Client(2.2, "http://example.com/v2.1")
|
||||
try:
|
||||
gc.images.get(image_show_fixture['id'])
|
||||
self.fail('Expected exception was not raised.')
|
||||
except ValueError as e:
|
||||
if 'ramdisk_id' not in str(e) and 'kernel_id' not in str(e):
|
||||
self.fail('Expected exception message was not returned.')
|
||||
img = gc.images.get(image_show_fixture['id'])
|
||||
self.assertEqual(image_show_fixture['checksum'], img['checksum'])
|
||||
|
@@ -182,7 +182,7 @@ class Controller(object):
|
||||
# NOTE(bcwaldon): remove 'self' for now until we have an elegant
|
||||
# way to pass it into the model constructor without conflict
|
||||
body.pop('self', None)
|
||||
return self.model(**body)
|
||||
return self.unvalidated_model(**body)
|
||||
|
||||
def data(self, image_id, do_checksum=True):
|
||||
"""Retrieve data of an image.
|
||||
@@ -255,7 +255,8 @@ class Controller(object):
|
||||
:param remove_props: List of property names to remove
|
||||
:param \*\*kwargs: Image attribute names and their new values.
|
||||
"""
|
||||
image = self.get(image_id)
|
||||
unvalidated_image = self.get(image_id)
|
||||
image = self.model(**unvalidated_image)
|
||||
for (key, value) in kwargs.items():
|
||||
try:
|
||||
setattr(image, key, value)
|
||||
|
Reference in New Issue
Block a user