Merge "Validate extra_specs type"

This commit is contained in:
Jenkins 2016-07-06 23:47:29 +00:00 committed by Gerrit Code Review
commit b472011f72
2 changed files with 7 additions and 1 deletions

View File

@ -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,

View File

@ -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,