def test_retrieval_of_dns_record(): responses.add_passthru("https://") cert = certificate() request = Request("Create", cert["CertificateArn"]) response = handler(request, {}) assert response["Status"] == "SUCCESS", response["Reason"] assert "Name" in response["Data"] assert "Type" in response["Data"] assert "Value" in response["Data"] assert response["Data"]["Type"] == "CNAME" assert "PhysicalResourceId" in response record_name = response["Data"]["Name"] physical_resource_id = response["PhysicalResourceId"] assert physical_resource_id == record_name request = Request( "Create", cert["CertificateArn"], cert["SubjectAlternativeNames"][1], ) response = handler(request, {}) assert response["Status"] == "SUCCESS", response["Reason"] assert "Name" in response["Data"] assert "Type" in response["Data"] assert "Value" in response["Data"] assert response["Data"]["Type"] == "CNAME" assert "PhysicalResourceId" in response
def test_retrieval_of_non_existing_domain_name(): responses.add_passthru("https://") cert = certificate() request = Request("Update", cert["CertificateArn"]) request["ResourceProperties"]["DomainName"] = "nonexisting.domain.name" response = handler(request, {}) assert response["Status"] == "FAILED", response["Reason"] assert response["Reason"].startswith( "No validation option found for domain")
def test_retrieval_of_dns_record_via_update(): responses.add_passthru("https://") cert = certificate() request = Request("Update", cert["CertificateArn"]) response = handler(request, {}) assert response["Status"] == "SUCCESS", response["Reason"] assert "Name" in response["Data"] assert "Type" in response["Data"] assert "Value" in response["Data"] assert response["Data"]["Type"] == "CNAME" assert "PhysicalResourceId" in response assert response["PhysicalResourceId"] == response["Data"]["Name"]
def test_await_pending_completion(): counter = Counter() cert = certificate() issued_certificate_provider.invoke_lambda = counter.increment request = Request("Create", cert["CertificateArn"]) response = handler(request, ()) assert issued_certificate_provider.asynchronous assert counter.count == 1 request = Request("Update", cert["CertificateArn"]) response = handler(request, ()) assert issued_certificate_provider.asynchronous assert counter.count == 2
def test_await_completion_issued(): cert = certificate() arn = cert["CertificateArn"] acm = boto3.client("acm") cert = acm.get_certificate(CertificateArn=arn) cert['status'] = "ISSUED" counter = Counter() issued_certificate_provider.async_reinvoke = counter.increment request = Request("Create", arn) response = handler(request, ()) assert response["Status"] == "SUCCESS", response["Reason"] assert not issued_certificate_provider.asynchronous