From 31d403612ebfc36fea0e9e017e42595f9dac60e6 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Wed, 4 Sep 2024 09:04:39 -0700 Subject: [PATCH] Add integration tests for AZ schema changes (#3655) --- scripts/update_snapshot_results.sh | 1 + .../integration/availability-zones.json | 60 +++++++++++++++++++ .../integration/availability-zones.yaml | 12 ++++ .../integration/test_integration_templates.py | 7 +++ 4 files changed, 80 insertions(+) create mode 100644 test/fixtures/results/integration/availability-zones.json create mode 100644 test/fixtures/templates/integration/availability-zones.yaml diff --git a/scripts/update_snapshot_results.sh b/scripts/update_snapshot_results.sh index fd9b2615e1..efaf8c38f0 100755 --- a/scripts/update_snapshot_results.sh +++ b/scripts/update_snapshot_results.sh @@ -4,6 +4,7 @@ cfn-lint test/fixtures/templates/integration/dynamic-references.yaml -e -c I --format json > test/fixtures/results/integration/dynamic-references.json cfn-lint test/fixtures/templates/integration/resources-cloudformation-init.yaml -e -c I --format json > test/fixtures/results/integration/resources-cloudformation-init.json cfn-lint test/fixtures/templates/integration/ref-no-value.yaml -e -c I --format json > test/fixtures/results/integration/ref-no-value.json +cfn-lint test/fixtures/templates/integration/availability-zones.yaml -e -c I --format json > test/fixtures/results/integration/availability-zones.json # public/ cfn-lint test/fixtures/templates/public/lambda-poller.yaml -e -c I --format json > test/fixtures/results/public/lambda-poller.json diff --git a/test/fixtures/results/integration/availability-zones.json b/test/fixtures/results/integration/availability-zones.json new file mode 100644 index 0000000000..3a5ccea30c --- /dev/null +++ b/test/fixtures/results/integration/availability-zones.json @@ -0,0 +1,60 @@ +[ + { + "Filename": "test/fixtures/templates/integration/availability-zones.yaml", + "Id": "5ed67959-64ec-2c99-379b-b9c9cc0afea2", + "Level": "Error", + "Location": { + "End": { + "ColumnNumber": 25, + "LineNumber": 5 + }, + "Path": [ + "Resources", + "Subnet", + "Properties", + "AvailabilityZoneId" + ], + "Start": { + "ColumnNumber": 7, + "LineNumber": 5 + } + }, + "Message": "'AvailabilityZoneId' should not be included with 'AvailabilityZone'", + "ParentId": null, + "Rule": { + "Description": "When certain properties are specified other properties should not be included", + "Id": "E3020", + "ShortDescription": "Validate that when a property is specified another property should be excluded", + "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded" + } + }, + { + "Filename": "test/fixtures/templates/integration/availability-zones.yaml", + "Id": "de15b593-58fc-a138-446a-c62c4803d10e", + "Level": "Error", + "Location": { + "End": { + "ColumnNumber": 23, + "LineNumber": 6 + }, + "Path": [ + "Resources", + "Subnet", + "Properties", + "AvailabilityZone" + ], + "Start": { + "ColumnNumber": 7, + "LineNumber": 6 + } + }, + "Message": "'AvailabilityZone' should not be included with 'AvailabilityZoneId'", + "ParentId": null, + "Rule": { + "Description": "When certain properties are specified other properties should not be included", + "Id": "E3020", + "ShortDescription": "Validate that when a property is specified another property should be excluded", + "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded" + } + } +] diff --git a/test/fixtures/templates/integration/availability-zones.yaml b/test/fixtures/templates/integration/availability-zones.yaml new file mode 100644 index 0000000000..31d6379f68 --- /dev/null +++ b/test/fixtures/templates/integration/availability-zones.yaml @@ -0,0 +1,12 @@ +AWSTemplateFormatVersion: '2010-09-09' +Resources: + Subnet: + Properties: + AvailabilityZoneId: use1-az1 + AvailabilityZone: + Fn::Select: + - 0 + - Fn::GetAZs: "" + CidrBlock: 10.0.0.0/20 + VpcId: vpc-abc12345 + Type: "AWS::EC2::Subnet" diff --git a/test/integration/test_integration_templates.py b/test/integration/test_integration_templates.py index 18ef3ad0eb..8daf33905e 100644 --- a/test/integration/test_integration_templates.py +++ b/test/integration/test_integration_templates.py @@ -40,6 +40,13 @@ class TestQuickStartTemplates(BaseCliTestCase): "results_filename": ("test/fixtures/results/integration/metadata.json"), "exit_code": 4, }, + { + "filename": ("test/fixtures/templates/integration/availability-zones.yaml"), + "results_filename": ( + "test/fixtures/results/integration/availability-zones.json" + ), + "exit_code": 2, + }, ] def test_templates(self):