From bc3cbf5ab83db2b0748a1a2cc24169754077d908 Mon Sep 17 00:00:00 2001 From: MalikAtalla-AWS <60721392+MalikAtalla-AWS@users.noreply.github.com> Date: Tue, 2 Mar 2021 11:37:56 -0800 Subject: [PATCH] Issue-692 Don't fail validation when version string with no quotes (#694) --- src/rpdk/core/contract/interface.py | 1 + src/rpdk/core/fragment/generator.py | 2 +- .../sample_fragments/template_with_date_in_version.yaml | 4 ++++ tests/fragments/test_generator.py | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/data/sample_fragments/template_with_date_in_version.yaml diff --git a/src/rpdk/core/contract/interface.py b/src/rpdk/core/contract/interface.py index 8900a468..ae9d669a 100644 --- a/src/rpdk/core/contract/interface.py +++ b/src/rpdk/core/contract/interface.py @@ -22,6 +22,7 @@ class OperationStatus(AutoName): FAILED = auto() +# pylint: disable=invalid-name class HandlerErrorCode(AutoName): NotUpdatable = auto() InvalidRequest = auto() diff --git a/src/rpdk/core/fragment/generator.py b/src/rpdk/core/fragment/generator.py index 161e549a..d2259ae5 100644 --- a/src/rpdk/core/fragment/generator.py +++ b/src/rpdk/core/fragment/generator.py @@ -105,7 +105,7 @@ def __get_cfn_lint_matches(raw_fragment): filename = "temporary_fragment.json" with open(filename, "w") as outfile: - json.dump(raw_fragment, outfile, indent=4) + json.dump(raw_fragment, outfile, indent=4, default=str) template = cfnlint.decode.cfn_json.load(filename) diff --git a/tests/data/sample_fragments/template_with_date_in_version.yaml b/tests/data/sample_fragments/template_with_date_in_version.yaml new file mode 100644 index 00000000..78cfb720 --- /dev/null +++ b/tests/data/sample_fragments/template_with_date_in_version.yaml @@ -0,0 +1,4 @@ +AWSTemplateFormatVersion: 2010-09-09 +Resources: + WaitHandle: + Type: AWS::CloudFormation::WaitConditionHandle diff --git a/tests/fragments/test_generator.py b/tests/fragments/test_generator.py index 179e4cee..ce9195a7 100644 --- a/tests/fragments/test_generator.py +++ b/tests/fragments/test_generator.py @@ -86,6 +86,12 @@ def test_template_fragments_without_parameter_section_is_valid(template_fragment ) +def test_template_fragments_with_date_in_version(template_fragment): + __assert_validation_throws_no_error( + "template_with_date_in_version.yaml", template_fragment + ) + + def test_template_fragments_without_description(template_fragment): schema = __generate_schema("template_without_description.json", template_fragment)