Validate that resource type is a string
Raises a proper validation error when a non-string resource type is passed. Change-Id: I1c84ee2bb1c7ff78802119e3321998b9d6487b2f Closes-Bug: #1298548
This commit is contained in:
parent
29827230aa
commit
426fb774b8
|
@ -288,6 +288,9 @@ class ResourceRegistry(object):
|
|||
msg = _('Non-empty resource type is required '
|
||||
'for resource "%s"') % resource_name
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
elif not isinstance(resource_type, basestring):
|
||||
msg = _('Resource "%s" type is not a string') % resource_name
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
info = self.get_resource_info(resource_type,
|
||||
resource_name=resource_name)
|
||||
|
|
|
@ -84,6 +84,15 @@ class ResourceTest(HeatTestCase):
|
|||
snippet, self.stack)
|
||||
self.assertIn(_('Resource "%s" has no type') % resource_name, str(ex))
|
||||
|
||||
def test_resource_wrong_type(self):
|
||||
snippet = {'Type': {}}
|
||||
resource_name = 'aresource'
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
resource.Resource, resource_name,
|
||||
snippet, self.stack)
|
||||
self.assertIn(_('Resource "%s" type is not a string') % resource_name,
|
||||
str(ex))
|
||||
|
||||
def test_resource_missed_type(self):
|
||||
snippet = {'not-a-Type': 'GenericResourceType'}
|
||||
resource_name = 'aresource'
|
||||
|
|
Loading…
Reference in New Issue