Throw ValidationError on null outputs section (#4221)
This commit is contained in:
		
							parent
							
								
									9613795bc2
								
							
						
					
					
						commit
						cbbeaff23e
					
				| @ -745,6 +745,13 @@ class OutputMap(collections_abc.Mapping): | ||||
|     def __init__(self, resources, template, stack_id): | ||||
|         self._template = template | ||||
|         self._stack_id = stack_id | ||||
| 
 | ||||
|         if "Outputs" in template and template["Outputs"] is None: | ||||
|             raise ValidationError( | ||||
|                 stack_id,  # not sure why we need to supply this when also supplying message | ||||
|                 message="[/Outputs] 'null' values are not allowed in templates", | ||||
|             ) | ||||
| 
 | ||||
|         self._output_json_map = template.get("Outputs") | ||||
| 
 | ||||
|         # Create the default resources | ||||
|  | ||||
| @ -56,6 +56,8 @@ output_dict = { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| null_output = {"Outputs": None} | ||||
| 
 | ||||
| bad_output = { | ||||
|     "Outputs": {"Output1": {"Value": {"Fn::GetAtt": ["Queue", "InvalidAttribute"]}}} | ||||
| } | ||||
| @ -146,6 +148,7 @@ import_value_template = { | ||||
| } | ||||
| 
 | ||||
| outputs_template = dict(list(dummy_template.items()) + list(output_dict.items())) | ||||
| null_outputs_template = dict(list(dummy_template.items()) + list(null_output.items())) | ||||
| bad_outputs_template = dict(list(dummy_template.items()) + list(bad_output.items())) | ||||
| get_attribute_outputs_template = dict( | ||||
|     list(dummy_template.items()) + list(get_attribute_output.items()) | ||||
| @ -162,6 +165,7 @@ ssm_parameter_template = dict( | ||||
| dummy_template_json = json.dumps(dummy_template) | ||||
| name_type_template_json = json.dumps(name_type_template) | ||||
| output_type_template_json = json.dumps(outputs_template) | ||||
| null_output_template_json = json.dumps(null_outputs_template) | ||||
| bad_output_template_json = json.dumps(bad_outputs_template) | ||||
| get_attribute_outputs_template_json = json.dumps(get_attribute_outputs_template) | ||||
| get_availability_zones_template_json = json.dumps(get_availability_zones_template) | ||||
| @ -316,6 +320,14 @@ def test_parse_stack_with_bad_get_attribute_outputs(): | ||||
|     ).should.throw(ValidationError) | ||||
| 
 | ||||
| 
 | ||||
| def test_parse_stack_with_null_outputs_section(): | ||||
|     FakeStack.when.called_with( | ||||
|         "test_id", "test_stack", null_output_template_json, {}, "us-west-1" | ||||
|     ).should.throw( | ||||
|         ValidationError, "[/Outputs] 'null' values are not allowed in templates" | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| def test_parse_stack_with_parameters(): | ||||
|     stack = FakeStack( | ||||
|         stack_id="test_id", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user