Merge "Deny chassis with too long description"
This commit is contained in:
commit
0acdfca62e
@ -51,7 +51,7 @@ class Chassis(base.APIBase):
|
||||
uuid = types.uuid
|
||||
"""The UUID of the chassis"""
|
||||
|
||||
description = wtypes.text
|
||||
description = wtypes.StringType(max_length=255)
|
||||
"""The description of the chassis"""
|
||||
|
||||
extra = {wtypes.text: types.jsontype}
|
||||
|
@ -43,6 +43,11 @@ class TestChassisObject(base.TestCase):
|
||||
chassis = api_chassis.Chassis(**chassis_dict)
|
||||
self.assertEqual(wtypes.Unset, chassis.description)
|
||||
|
||||
def test_chassis_sample(self):
|
||||
expected_description = 'Sample chassis'
|
||||
sample = api_chassis.Chassis.sample(expand=False)
|
||||
self.assertEqual(expected_description, sample.as_dict()['description'])
|
||||
|
||||
|
||||
class TestListChassis(test_api_base.BaseApiTest):
|
||||
|
||||
@ -445,6 +450,25 @@ class TestPost(test_api_base.BaseApiTest):
|
||||
result = self.get_json('/chassis/%s' % cdict['uuid'])
|
||||
self.assertEqual(descr, result['description'])
|
||||
|
||||
def test_create_chassis_toolong_description(self):
|
||||
descr = 'a' * 256
|
||||
valid_error_message = ('Value should have a maximum character '
|
||||
'requirement of 255')
|
||||
cdict = apiutils.chassis_post_data(description=descr)
|
||||
response = self.post_json('/chassis', cdict, expect_errors=True)
|
||||
self.assertEqual(http_client.BAD_REQUEST, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertIn(valid_error_message, response.json['error_message'])
|
||||
|
||||
def test_create_chassis_invalid_description(self):
|
||||
descr = 1334
|
||||
valid_error_message = 'Value should be string'
|
||||
cdict = apiutils.chassis_post_data(description=descr)
|
||||
response = self.post_json('/chassis', cdict, expect_errors=True)
|
||||
self.assertEqual(http_client.BAD_REQUEST, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertIn(valid_error_message, response.json['error_message'])
|
||||
|
||||
|
||||
class TestDelete(test_api_base.BaseApiTest):
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
fixes:
|
||||
- Deny too long description of chassis
|
||||
(more than 255 chars) with appropriate
|
||||
correct message.
|
Loading…
Reference in New Issue
Block a user