Exemple #1
0
    def test_put_record_set(self, cfngin_context: MockCFNginContext) -> None:
        """Test put_record."""
        # setup context
        cfngin_context.add_stubber("acm", "us-east-1")
        r53_stubber = cfngin_context.add_stubber("route53", "us-east-1")
        cfngin_context.config.namespace = "test"

        cert = Certificate(
            context=cfngin_context,
            provider=MagicMock(),
            domain="example.com",
            hosted_zone_id="test",
        )

        r53_stubber.add_response(
            "change_resource_record_sets",
            gen_change_resource_record_sets(),
            {
                "HostedZoneId":
                cert.args.hosted_zone_id,
                "ChangeBatch":
                gen_change_batch(changes=[
                    gen_change(record_set=cast(
                        "ResourceRecordSetTypeDef",
                        gen_record_set(use_resource_record=True,
                                       TTL=cert.args.ttl),
                    ))
                ]),
            },
        )

        with r53_stubber:
            assert not cert.put_record_set(
                cast("ResourceRecordTypeDef", gen_record_set()))
        r53_stubber.assert_no_pending_responses()
Exemple #2
0
    def test_put_record_set(self, cfngin_context):
        """Test put_record."""
        # setup context
        cfngin_context.add_stubber('acm', 'us-east-1')
        r53_stubber = cfngin_context.add_stubber('route53', 'us-east-1')
        cfngin_context.config.namespace = 'test'

        cert = Certificate(context=cfngin_context,
                           provider=MagicMock(),
                           domain='example.com',
                           hosted_zone_id='test')

        r53_stubber.add_response(
            'change_resource_record_sets', gen_change_resource_record_sets(), {
                'HostedZoneId':
                cert.args.hosted_zone_id,
                'ChangeBatch':
                gen_change_batch(changes=[
                    gen_change(record_set=gen_record_set(
                        use_resource_record=True, TTL=cert.args.ttl))
                ])
            })

        with r53_stubber:
            assert not cert.put_record_set(gen_record_set())
        r53_stubber.assert_no_pending_responses()