Enable more unit tests for ACM (#3372)

* Enable more unit tests for ACM

* put a smile on travis-ci face

Co-authored-by: nom3ad <nom3ad@gmail.com>
Co-authored-by: Bert Blommers <bblommers@users.noreply.github.com>
This commit is contained in:
nom3ad 2020-10-12 19:13:36 +05:30 committed by GitHub
parent 0a938f7bb4
commit fe361f861d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,9 +8,10 @@ import uuid
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
from moto import mock_acm from moto import mock_acm, settings
from moto.core import ACCOUNT_ID from moto.core import ACCOUNT_ID
from nose import SkipTest
from nose.tools import assert_raises from nose.tools import assert_raises
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources") RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
@ -493,70 +494,81 @@ def test_request_certificate_no_san():
resp2.should.contain("Certificate") resp2.should.contain("Certificate")
# # Also tests the SAN code # Also tests the SAN code
# # requires Pull: https://github.com/spulec/freezegun/pull/210 @freeze_time("2012-01-01 12:00:00", as_arg=True)
# @freeze_time("2012-01-01 12:00:00", as_arg=True) @mock_acm
# @mock_acm def test_request_certificate_issued_status(frozen_time):
# def test_request_certificate(frozen_time): # After requesting a certificate, it should then auto-validate after 1 minute
# # After requesting a certificate, it should then auto-validate after 1 minute # Some sneaky programming for that ;-)
# # Some sneaky programming for that ;-) client = boto3.client("acm", region_name="eu-central-1")
# client = boto3.client('acm', region_name='eu-central-1')
# resp = client.request_certificate(
# resp = client.request_certificate( DomainName="google.com",
# DomainName='google.com', SubjectAlternativeNames=["google.com", "www.google.com", "mail.google.com"],
# SubjectAlternativeNames=['google.com', 'www.google.com', 'mail.google.com'], )
# ) arn = resp["CertificateArn"]
# arn = resp['CertificateArn']
# resp = client.describe_certificate(CertificateArn=arn)
# resp = client.describe_certificate(CertificateArn=arn) resp["Certificate"]["CertificateArn"].should.equal(arn)
# resp['Certificate']['CertificateArn'].should.equal(arn) resp["Certificate"]["DomainName"].should.equal("google.com")
# resp['Certificate']['DomainName'].should.equal('google.com') resp["Certificate"]["Issuer"].should.equal("Amazon")
# resp['Certificate']['Issuer'].should.equal('Amazon') resp["Certificate"]["KeyAlgorithm"].should.equal("RSA_2048")
# resp['Certificate']['KeyAlgorithm'].should.equal('RSA_2048') resp["Certificate"]["Status"].should.equal("PENDING_VALIDATION")
# resp['Certificate']['Status'].should.equal('PENDING_VALIDATION') resp["Certificate"]["Type"].should.equal("AMAZON_ISSUED")
# resp['Certificate']['Type'].should.equal('AMAZON_ISSUED') len(resp["Certificate"]["SubjectAlternativeNames"]).should.equal(3)
# len(resp['Certificate']['SubjectAlternativeNames']).should.equal(3)
# # validation will be pending for 1 minute.
# # Move time resp = client.describe_certificate(CertificateArn=arn)
# frozen_time.move_to('2012-01-01 12:02:00') resp["Certificate"]["CertificateArn"].should.equal(arn)
# resp = client.describe_certificate(CertificateArn=arn) resp["Certificate"]["Status"].should.equal("PENDING_VALIDATION")
# resp['Certificate']['CertificateArn'].should.equal(arn)
# resp['Certificate']['Status'].should.equal('ISSUED') if not settings.TEST_SERVER_MODE:
# # Move time to get it issued.
# frozen_time.move_to("2012-01-01 12:02:00")
# # requires Pull: https://github.com/spulec/freezegun/pull/210 resp = client.describe_certificate(CertificateArn=arn)
# @freeze_time("2012-01-01 12:00:00", as_arg=True) resp["Certificate"]["CertificateArn"].should.equal(arn)
# @mock_acm resp["Certificate"]["Status"].should.equal("ISSUED")
# def test_request_certificate(frozen_time):
# # After requesting a certificate, it should then auto-validate after 1 minute
# # Some sneaky programming for that ;-) @freeze_time("2012-01-01 12:00:00", as_arg=True)
# client = boto3.client('acm', region_name='eu-central-1') @mock_acm
# def test_request_certificate_with_mutiple_times(frozen_time):
# resp = client.request_certificate( if settings.TEST_SERVER_MODE:
# IdempotencyToken='test_token', raise SkipTest("Cant manipulate time in server mode")
# DomainName='google.com',
# SubjectAlternativeNames=['google.com', 'www.google.com', 'mail.google.com'], # After requesting a certificate, it should then auto-validate after 1 minute
# ) # Some sneaky programming for that ;-)
# original_arn = resp['CertificateArn'] client = boto3.client("acm", region_name="eu-central-1")
#
# # Should be able to request a certificate multiple times in an hour resp = client.request_certificate(
# # after that it makes a new one IdempotencyToken="test_token",
# for time_intervals in ('2012-01-01 12:15:00', '2012-01-01 12:30:00', '2012-01-01 12:45:00'): DomainName="google.com",
# frozen_time.move_to(time_intervals) SubjectAlternativeNames=["google.com", "www.google.com", "mail.google.com"],
# resp = client.request_certificate( )
# IdempotencyToken='test_token', original_arn = resp["CertificateArn"]
# DomainName='google.com',
# SubjectAlternativeNames=['google.com', 'www.google.com', 'mail.google.com'], # Should be able to request a certificate multiple times in an hour
# ) # after that it makes a new one
# arn = resp['CertificateArn'] for time_intervals in (
# arn.should.equal(original_arn) "2012-01-01 12:15:00",
# "2012-01-01 12:30:00",
# # Move time "2012-01-01 12:45:00",
# frozen_time.move_to('2012-01-01 13:01:00') ):
# resp = client.request_certificate( frozen_time.move_to(time_intervals)
# IdempotencyToken='test_token', resp = client.request_certificate(
# DomainName='google.com', IdempotencyToken="test_token",
# SubjectAlternativeNames=['google.com', 'www.google.com', 'mail.google.com'], DomainName="google.com",
# ) SubjectAlternativeNames=["google.com", "www.google.com", "mail.google.com"],
# arn = resp['CertificateArn'] )
# arn.should_not.equal(original_arn) arn = resp["CertificateArn"]
arn.should.equal(original_arn)
# Move time
frozen_time.move_to("2012-01-01 13:01:00")
resp = client.request_certificate(
IdempotencyToken="test_token",
DomainName="google.com",
SubjectAlternativeNames=["google.com", "www.google.com", "mail.google.com"],
)
arn = resp["CertificateArn"]
arn.should_not.equal(original_arn)