]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fail validation when an unknown property is supplied in a template.
authorAngus Salkeld <asalkeld@redhat.com>
Tue, 5 Mar 2013 11:17:12 +0000 (22:17 +1100)
committerAngus Salkeld <asalkeld@redhat.com>
Tue, 5 Mar 2013 11:17:12 +0000 (22:17 +1100)
bug #1101098
Change-Id: I9430ad859e9a93d6c0d2a417877e02c151e98a05

heat/engine/properties.py
heat/tests/test_properties.py

index 00a657cc2357dd613950877956d545c8f6cf5e83..465f02de4201fb1f60a0ced200d16ca089d9570d 100644 (file)
@@ -167,6 +167,11 @@ class Properties(collections.Mapping):
                 return (self.error_prefix +
                         '%s Property not implemented yet' % key)
 
+        for key in self.data:
+            if key not in self.props:
+                return (self.error_prefix +
+                        'Unknown Property "%s"' % key)
+
     def __getitem__(self, key):
         if key not in self:
             raise KeyError(self.error_prefix + 'Invalid Property %s' % key)
index ac7dd6d9c1119177d89a4cb60400345bceffc5cb..dc60a8a796f5372cb8d8bb5d2a70a02a6c5f25fa 100644 (file)
@@ -337,3 +337,8 @@ class PropertiesValidationTest(unittest.TestCase):
         schema = {'foo': {'Type': 'String'}}
         props = properties.Properties(schema, {'foo': 42})
         self.assertEqual(props.validate(), 'foo Value must be a string')
+
+    def test_unknown_typo(self):
+        schema = {'foo': {'Type': 'String'}}
+        props = properties.Properties(schema, {'food': 42})
+        self.assertNotEqual(props.validate(), None)