API: restrict length of bay's name to 242
Restrict the length of bay's name to avoid passing a invalid long name to heat stack. Reason of 242 is: stack_name = '%s-%s' % (bay.name, short_id.generate_id()) 255 - len(short_id.generate_id()) - 1 = 242 Closes-bug: #1606785 Change-Id: If22a9018ece718f014c40e8059b945ae1a411f5b
This commit is contained in:
parent
d92c76f6d1
commit
e4a8242b96
|
@ -83,9 +83,10 @@ class Bay(base.APIBase):
|
|||
uuid = types.uuid
|
||||
"""Unique UUID for this bay"""
|
||||
|
||||
name = wtypes.StringType(min_length=1, max_length=255,
|
||||
name = wtypes.StringType(min_length=1, max_length=242,
|
||||
pattern='^[a-zA-Z][a-zA-Z0-9_.-]*$')
|
||||
"""Name of this bay"""
|
||||
"""Name of this bay, max length is limited to 242 because of heat stack
|
||||
requires max length limit to 255, and Magnum amend a uuid length"""
|
||||
|
||||
baymodel_id = wsme.wsproperty(wtypes.text, _get_baymodel_id,
|
||||
_set_baymodel_id, mandatory=True)
|
||||
|
|
|
@ -532,7 +532,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(1, response.json['master_count'])
|
||||
|
||||
def test_create_bay_with_invalid_long_name(self):
|
||||
bdict = apiutils.bay_post_data(name='x' * 256)
|
||||
bdict = apiutils.bay_post_data(name='x' * 243)
|
||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
|
|
Loading…
Reference in New Issue