Merge "Fix 500 if custom property name is greater than 255"
This commit is contained in:
commit
12cd61e7a8
@ -453,6 +453,15 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
||||
image[key] = properties.pop(key)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# NOTE(abhishekk): Check if custom property key name is less than 255
|
||||
# characters. Reference LP #1737952
|
||||
for key in properties:
|
||||
if len(key) > 255:
|
||||
msg = (_("Custom property should not be greater than 255 "
|
||||
"characters."))
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
return dict(image=image, extra_properties=properties, tags=tags)
|
||||
|
||||
def _get_change_operation_d10(self, raw_change):
|
||||
|
@ -2441,6 +2441,23 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
||||
'tags': ['one', 'two']}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_create_invalid_property_key(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
request.body = jsonutils.dump_as_bytes({
|
||||
'id': UUID3,
|
||||
'name': 'image-1',
|
||||
'visibility': 'public',
|
||||
'tags': ['one', 'two'],
|
||||
'container_format': 'ami',
|
||||
'disk_format': 'ami',
|
||||
'min_ram': 128,
|
||||
'min_disk': 10,
|
||||
'f' * 256: 'bar',
|
||||
'protected': True,
|
||||
})
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create,
|
||||
request)
|
||||
|
||||
def test_create_readonly_attributes_forbidden(self):
|
||||
bodies = [
|
||||
{'direct_url': 'http://example.com'},
|
||||
|
Loading…
x
Reference in New Issue
Block a user