ACM: Include more info to the list_certificates (#5973)
This commit is contained in:
parent
651722689f
commit
fd66843cf7
@ -130,12 +130,7 @@ class AWSCertificateManagerResponse(BaseResponse):
|
|||||||
certs = []
|
certs = []
|
||||||
statuses = self._get_param("CertificateStatuses")
|
statuses = self._get_param("CertificateStatuses")
|
||||||
for cert_bundle in self.acm_backend.get_certificates_list(statuses):
|
for cert_bundle in self.acm_backend.get_certificates_list(statuses):
|
||||||
certs.append(
|
certs.append(cert_bundle.describe()["Certificate"])
|
||||||
{
|
|
||||||
"CertificateArn": cert_bundle.arn,
|
|
||||||
"DomainName": cert_bundle.common_name,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
result = {"CertificateSummaryList": certs}
|
result = {"CertificateSummaryList": certs}
|
||||||
return json.dumps(result)
|
return json.dumps(result)
|
||||||
|
@ -14,7 +14,6 @@ from moto import mock_acm, mock_elb, settings
|
|||||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||||
from unittest import SkipTest, mock
|
from unittest import SkipTest, mock
|
||||||
|
|
||||||
|
|
||||||
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
|
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
|
||||||
|
|
||||||
|
|
||||||
@ -94,12 +93,18 @@ def test_list_certificates():
|
|||||||
issued_arn = _import_cert(client)
|
issued_arn = _import_cert(client)
|
||||||
pending_arn = client.request_certificate(DomainName="google.com")["CertificateArn"]
|
pending_arn = client.request_certificate(DomainName="google.com")["CertificateArn"]
|
||||||
|
|
||||||
moto_arn = {"CertificateArn": issued_arn, "DomainName": SERVER_COMMON_NAME}
|
|
||||||
google_arn = {"CertificateArn": pending_arn, "DomainName": "google.com"}
|
|
||||||
|
|
||||||
certs = client.list_certificates()["CertificateSummaryList"]
|
certs = client.list_certificates()["CertificateSummaryList"]
|
||||||
certs.should.contain(moto_arn)
|
[c["CertificateArn"] for c in certs].should.contain(issued_arn)
|
||||||
certs.should.contain(google_arn)
|
[c["CertificateArn"] for c in certs].should.contain(pending_arn)
|
||||||
|
for cert in certs:
|
||||||
|
cert.should.have.key("CertificateArn")
|
||||||
|
cert.should.have.key("DomainName")
|
||||||
|
cert.should.have.key("Status")
|
||||||
|
cert.should.have.key("Type")
|
||||||
|
cert.should.have.key("KeyAlgorithm")
|
||||||
|
cert.should.have.key("RenewalEligibility")
|
||||||
|
cert.should.have.key("NotBefore")
|
||||||
|
cert.should.have.key("NotAfter")
|
||||||
|
|
||||||
resp = client.list_certificates(CertificateStatuses=["EXPIRED", "INACTIVE"])
|
resp = client.list_certificates(CertificateStatuses=["EXPIRED", "INACTIVE"])
|
||||||
len(resp["CertificateSummaryList"]).should.equal(0)
|
len(resp["CertificateSummaryList"]).should.equal(0)
|
||||||
@ -107,20 +112,20 @@ def test_list_certificates():
|
|||||||
certs = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])[
|
certs = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])[
|
||||||
"CertificateSummaryList"
|
"CertificateSummaryList"
|
||||||
]
|
]
|
||||||
certs.should.contain(google_arn)
|
[c["CertificateArn"] for c in certs].shouldnt.contain(issued_arn)
|
||||||
certs.shouldnt.contain(moto_arn)
|
[c["CertificateArn"] for c in certs].should.contain(pending_arn)
|
||||||
|
|
||||||
certs = client.list_certificates(CertificateStatuses=["ISSUED"])[
|
certs = client.list_certificates(CertificateStatuses=["ISSUED"])[
|
||||||
"CertificateSummaryList"
|
"CertificateSummaryList"
|
||||||
]
|
]
|
||||||
certs.shouldnt.contain(google_arn)
|
[c["CertificateArn"] for c in certs].should.contain(issued_arn)
|
||||||
certs.should.contain(moto_arn)
|
[c["CertificateArn"] for c in certs].shouldnt.contain(pending_arn)
|
||||||
|
|
||||||
certs = client.list_certificates(
|
certs = client.list_certificates(
|
||||||
CertificateStatuses=["ISSUED", "PENDING_VALIDATION"]
|
CertificateStatuses=["ISSUED", "PENDING_VALIDATION"]
|
||||||
)["CertificateSummaryList"]
|
)["CertificateSummaryList"]
|
||||||
certs.should.contain(google_arn)
|
[c["CertificateArn"] for c in certs].should.contain(issued_arn)
|
||||||
certs.should.contain(moto_arn)
|
[c["CertificateArn"] for c in certs].should.contain(pending_arn)
|
||||||
|
|
||||||
|
|
||||||
@mock_acm
|
@mock_acm
|
||||||
|
Loading…
Reference in New Issue
Block a user