Pool PUT should validate name/description length
Change-Id: I75aba494f08153bb1da94338edb9916713c5bc58 Backport-Candidate: Queens Pike
This commit is contained in:
parent
86da7a86a1
commit
555c057e88
|
@ -143,8 +143,8 @@ class PoolRootPOST(types.BaseType):
|
|||
|
||||
class PoolPUT(BasePoolType):
|
||||
"""Defines attributes that are acceptable of a PUT request."""
|
||||
name = wtypes.wsattr(wtypes.StringType())
|
||||
description = wtypes.wsattr(wtypes.StringType())
|
||||
name = wtypes.wsattr(wtypes.StringType(max_length=255))
|
||||
description = wtypes.wsattr(wtypes.StringType(max_length=255))
|
||||
admin_state_up = wtypes.wsattr(bool)
|
||||
lb_algorithm = wtypes.wsattr(
|
||||
wtypes.Enum(str, *constants.SUPPORTED_LB_ALGORITHMS))
|
||||
|
|
|
@ -86,6 +86,22 @@ class TestPoolPOST(base.BaseTypesTest):
|
|||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_too_long_name(self):
|
||||
body = {"name": "n" * 256,
|
||||
"loadbalancer_id": uuidutils.generate_uuid(),
|
||||
"protocol": constants.PROTOCOL_HTTP,
|
||||
"lb_algorithm": constants.LB_ALGORITHM_ROUND_ROBIN}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_too_long_description(self):
|
||||
body = {"description": "d" * 256,
|
||||
"loadbalancer_id": uuidutils.generate_uuid(),
|
||||
"protocol": constants.PROTOCOL_HTTP,
|
||||
"lb_algorithm": constants.LB_ALGORITHM_ROUND_ROBIN}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_invalid_load_balacer_id(self):
|
||||
body = {"loadbalancer_id": 10,
|
||||
"protocol": constants.PROTOCOL_HTTP,
|
||||
|
@ -130,6 +146,16 @@ class TestPoolPUT(base.BaseTypesTest):
|
|||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_too_long_name(self):
|
||||
body = {"name": "n" * 256}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_too_long_description(self):
|
||||
body = {"description": "d" * 256}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
def test_invalid_description(self):
|
||||
body = {"description": 10}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
|
|
Loading…
Reference in New Issue