Make it possible to customize the ACM cert validation wait time. (#3843)
* Make it possible to customize the ACM cert validation wait time. Signed-off-by: Kai Xia <kaix+github@fastmail.com> * address PR comments & change requests. Signed-off-by: Kai Xia <kaix+github@fastmail.com> * make tests work. Signed-off-by: Kai Xia <kaix+github@fastmail.com>
This commit is contained in:
parent
d45233fa00
commit
5eb99da75a
3 changed files with 47 additions and 5 deletions
|
|
@ -6,11 +6,17 @@ import uuid
|
|||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
import sys
|
||||
from botocore.exceptions import ClientError
|
||||
from freezegun import freeze_time
|
||||
from moto import mock_acm, settings
|
||||
from moto.core import ACCOUNT_ID
|
||||
from unittest import SkipTest
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
import mock
|
||||
from unittest import SkipTest
|
||||
else:
|
||||
from unittest import SkipTest, mock
|
||||
|
||||
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
|
||||
_GET_RESOURCE = lambda x: open(os.path.join(RESOURCE_FOLDER, x), "rb").read()
|
||||
|
|
@ -530,6 +536,36 @@ def test_request_certificate_issued_status():
|
|||
resp["Certificate"]["Status"].should.equal("ISSUED")
|
||||
|
||||
|
||||
@mock.patch("moto.settings.ACM_VALIDATION_WAIT", 3)
|
||||
@mock_acm
|
||||
def test_request_certificate_issued_status_with_wait_in_envvar():
|
||||
# After requesting a certificate, it should then auto-validate after 3 seconds
|
||||
if settings.TEST_SERVER_MODE:
|
||||
raise SkipTest("Cant manipulate time in server mode")
|
||||
|
||||
client = boto3.client("acm", region_name="eu-central-1")
|
||||
|
||||
with freeze_time("2012-01-01 12:00:00"):
|
||||
resp = client.request_certificate(DomainName="google.com",)
|
||||
arn = resp["CertificateArn"]
|
||||
|
||||
with freeze_time("2012-01-01 12:00:00"):
|
||||
resp = client.describe_certificate(CertificateArn=arn)
|
||||
resp["Certificate"]["CertificateArn"].should.equal(arn)
|
||||
resp["Certificate"]["Status"].should.equal("PENDING_VALIDATION")
|
||||
|
||||
# validation will be pending for 3 seconds.
|
||||
with freeze_time("2012-01-01 12:00:02"):
|
||||
resp = client.describe_certificate(CertificateArn=arn)
|
||||
resp["Certificate"]["CertificateArn"].should.equal(arn)
|
||||
resp["Certificate"]["Status"].should.equal("PENDING_VALIDATION")
|
||||
|
||||
with freeze_time("2012-01-01 12:00:04"):
|
||||
resp = client.describe_certificate(CertificateArn=arn)
|
||||
resp["Certificate"]["CertificateArn"].should.equal(arn)
|
||||
resp["Certificate"]["Status"].should.equal("ISSUED")
|
||||
|
||||
|
||||
@mock_acm
|
||||
def test_request_certificate_with_mutiple_times():
|
||||
if settings.TEST_SERVER_MODE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue