Merge "Fix early resource property value validation"
This commit is contained in:
commit
5e4b16d916
@ -278,7 +278,9 @@ class Property(object):
|
||||
elif t == Schema.BOOLEAN:
|
||||
_value = self._get_bool(value)
|
||||
|
||||
if validate:
|
||||
# property value resolves to None if resource it depends on is not
|
||||
# created. So, if value is None skip constraint validation.
|
||||
if value is not None and validate:
|
||||
self.schema.validate_constraints(_value, self.context)
|
||||
|
||||
return _value
|
||||
|
@ -1031,6 +1031,20 @@ class PropertiesTest(testtools.TestCase):
|
||||
err = self.assertRaises(ValueError, props.get, 'foo')
|
||||
self.assertEqual('foo resolution failed!', str(err))
|
||||
|
||||
def test_resolve_returns_none(self):
|
||||
schema = {'foo': {'Type': 'String', "MinLength": "5"}}
|
||||
|
||||
def test_resolver(prop):
|
||||
return None
|
||||
|
||||
props = properties.Properties(schema,
|
||||
{'foo': 'get_attr: [db, value]'},
|
||||
test_resolver)
|
||||
try:
|
||||
self.assertIsNone(props.validate())
|
||||
except exception.StackValidationFailed:
|
||||
self.fail("Constraints should not have been evaluated.")
|
||||
|
||||
def test_schema_from_params(self):
|
||||
params_snippet = {
|
||||
"DBUsername": {
|
||||
|
Loading…
Reference in New Issue
Block a user