Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 8f1c4ef

Browse files
committed
cfn: add more validations to intrinsic functions
1 parent 8ec82ab commit 8f1c4ef

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

tests/aws/services/cloudformation/engine/test_conditions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import json
12
import os.path
23

34
import pytest
5+
from botocore.exceptions import ClientError
46
from tests.aws.services.cloudformation.conftest import skip_if_legacy_engine
57

68
from localstack.services.cloudformation.v2.utils import is_v2_engine
@@ -515,3 +517,28 @@ def test_update_conditions(self, deploy_cfn_template, aws_client):
515517
assert aws_client.s3.head_bucket(Bucket=bucket_1)
516518
with pytest.raises(aws_client.s3.exceptions.ClientError):
517519
aws_client.s3.head_bucket(Bucket=bucket_2)
520+
521+
522+
class TestValidateConditions:
523+
@markers.aws.validated
524+
def test_validate_equals_args_len(self, aws_client, snapshot):
525+
template = {
526+
"Conditions": {"ShouldDeploy": {"Fn::Equals": ["a"]}},
527+
"Resources": {
528+
"Topic1": {
529+
"Type": "AWS::SNS::Topic",
530+
},
531+
},
532+
}
533+
534+
stack_name = f"stack-{short_uid()}"
535+
change_set_name = f"ch-{short_uid()}"
536+
with pytest.raises(ClientError) as ex:
537+
aws_client.cloudformation.create_change_set(
538+
StackName=stack_name,
539+
ChangeSetName=change_set_name,
540+
ChangeSetType="CREATE",
541+
TemplateBody=json.dumps(template),
542+
)
543+
544+
snapshot.match("error", ex.value.response)

tests/aws/services/cloudformation/engine/test_conditions.validation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,14 @@
3434
},
3535
"tests/aws/services/cloudformation/engine/test_conditions.py::TestCloudFormationConditions::test_update_conditions": {
3636
"last_validated_date": "2024-06-18T19:43:43+00:00"
37+
},
38+
"tests/aws/services/cloudformation/engine/test_conditions.py::TestValidateConditions::test_validate_equals_args_len": {
39+
"last_validated_date": "2025-10-02T20:27:04+00:00",
40+
"durations_in_seconds": {
41+
"setup": 0.24,
42+
"call": 0.32,
43+
"teardown": 0.0,
44+
"total": 0.56
45+
}
3746
}
3847
}

0 commit comments

Comments
 (0)