Merge "Validate extra_specs type"
This commit is contained in:
commit
b472011f72
@ -344,7 +344,9 @@ class VolumeTypesManageApiTest(test.TestCase):
|
||||
|
||||
@ddt.data({'a' * 256: 'a'},
|
||||
{'a': 'a' * 256},
|
||||
{'': 'a'})
|
||||
{'': 'a'},
|
||||
'foo',
|
||||
None)
|
||||
def test_create_type_with_invalid_extra_specs(self, value):
|
||||
body = {"volume_type": {"name": "vol_type_1",
|
||||
"os-volume-type-access:is_public": False,
|
||||
|
@ -1063,6 +1063,10 @@ def validate_integer(value, name, min_value=None, max_value=None):
|
||||
|
||||
def validate_extra_specs(specs):
|
||||
"""Validating key and value of extra specs."""
|
||||
if not isinstance(specs, dict):
|
||||
msg = _('extra_specs must be a dictionary.')
|
||||
raise exception.InvalidInput(reason=msg)
|
||||
|
||||
for key, value in specs.items():
|
||||
if key is not None:
|
||||
check_string_length(key, 'Key "%s"' % key,
|
||||
|
Loading…
Reference in New Issue
Block a user