Ejemplo n.º 1
0
    def test_attributes(self, cfngin_context: MockCFNginContext) -> None:
        """Test attributes set during __init__."""
        # setup context
        cfngin_context.add_stubber("acm", "us-east-1")
        cfngin_context.add_stubber("route53", "us-east-1")
        cfngin_context.config.namespace = "test"

        result = Certificate(
            context=cfngin_context,
            provider=MagicMock(),
            alt_names=["example.net"],
            domain="example.com",
            hosted_zone_id="test",
            stack_name="stack-name",
            ttl=13,
        )

        assert result.stack_name == "stack-name"
        assert result.properties["DomainName"] == "example.com"
        assert result.properties["SubjectAlternativeNames"] == ["example.net"]
        # value tested in base class; just ensure its not None
        assert result.properties["Tags"]
        assert result.properties["ValidationMethod"] == "DNS"

        # blueprint attributes
        assert result.blueprint.VARIABLES["DomainName"]
        assert result.blueprint.VARIABLES["ValidateRecordTTL"]

        # template attributes
        template = result.blueprint.template
        assert template.description == result.get_template_description()
        assert not template.metadata
        assert not template.conditions
        assert not template.mappings
        assert template.outputs["DomainName"].Value.to_dict() == {
            "Ref": "DomainName"
        }
        assert template.outputs["ValidateRecordTTL"].Value.to_dict() == {
            "Ref": "ValidateRecordTTL"
        }
        assert not template.parameters
        assert isinstance(template.resources["Certificate"],
                          CertificateResource)
        assert not template.rules
        assert template.version == "2010-09-09"
        assert not template.transform

        # stack attributes
        assert result.stack.fqn == "test-stack-name"
        assert result.stack._blueprint == result.blueprint
Ejemplo n.º 2
0
    def test_attributes(self, cfngin_context):
        """Test attributes set during __init__."""
        # setup context
        cfngin_context.add_stubber('acm', 'us-east-1')
        cfngin_context.add_stubber('route53', 'us-east-1')
        cfngin_context.config.namespace = 'test'

        result = Certificate(context=cfngin_context,
                             provider=MagicMock(),
                             alt_names=['example.net'],
                             domain='example.com',
                             hosted_zone_id='test',
                             stack_name='stack-name',
                             ttl=13)

        assert result.stack_name == 'stack-name'
        assert result.properties.DomainName == 'example.com'
        assert result.properties.SubjectAlternativeNames == ['example.net']
        # value tested in base class; just ensure its not None
        assert result.properties.Tags
        assert result.properties.ValidationMethod == 'DNS'

        # blueprint attributes
        assert result.blueprint.VARIABLES['DomainName']
        assert result.blueprint.VARIABLES['ValidateRecordTTL']

        # template attributes
        template = result.blueprint.template
        assert template.description == result.get_template_description()
        assert not template.metadata
        assert not template.conditions
        assert not template.mappings
        assert template.outputs['DomainName'].Value.to_dict() == \
            {'Ref': 'DomainName'}
        assert template.outputs['ValidateRecordTTL'].Value.to_dict() == \
            {'Ref': 'ValidateRecordTTL'}
        assert not template.parameters
        assert isinstance(template.resources['Certificate'],
                          CertificateResource)
        assert not template.rules
        assert template.version == '2010-09-09'
        assert not template.transform

        # stack attributes
        assert result.stack.fqn == 'test-stack-name'
        assert result.stack._blueprint == result.blueprint