From fd66843cf79c7b320af0caa319f6e4ecfd4b142c Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Sun, 26 Feb 2023 21:45:54 +0100 Subject: [PATCH] ACM: Include more info to the list_certificates (#5973) --- moto/acm/responses.py | 7 +------ tests/test_acm/test_acm.py | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/moto/acm/responses.py b/moto/acm/responses.py index 8194cd5a5..1248b0c3d 100644 --- a/moto/acm/responses.py +++ b/moto/acm/responses.py @@ -130,12 +130,7 @@ class AWSCertificateManagerResponse(BaseResponse): certs = [] statuses = self._get_param("CertificateStatuses") for cert_bundle in self.acm_backend.get_certificates_list(statuses): - certs.append( - { - "CertificateArn": cert_bundle.arn, - "DomainName": cert_bundle.common_name, - } - ) + certs.append(cert_bundle.describe()["Certificate"]) result = {"CertificateSummaryList": certs} return json.dumps(result) diff --git a/tests/test_acm/test_acm.py b/tests/test_acm/test_acm.py index f6f58303d..2fdc3e706 100644 --- a/tests/test_acm/test_acm.py +++ b/tests/test_acm/test_acm.py @@ -14,7 +14,6 @@ from moto import mock_acm, mock_elb, settings from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID from unittest import SkipTest, mock - RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources") @@ -94,12 +93,18 @@ def test_list_certificates(): issued_arn = _import_cert(client) 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.should.contain(moto_arn) - certs.should.contain(google_arn) + [c["CertificateArn"] for c in certs].should.contain(issued_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"]) len(resp["CertificateSummaryList"]).should.equal(0) @@ -107,20 +112,20 @@ def test_list_certificates(): certs = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])[ "CertificateSummaryList" ] - certs.should.contain(google_arn) - certs.shouldnt.contain(moto_arn) + [c["CertificateArn"] for c in certs].shouldnt.contain(issued_arn) + [c["CertificateArn"] for c in certs].should.contain(pending_arn) certs = client.list_certificates(CertificateStatuses=["ISSUED"])[ "CertificateSummaryList" ] - certs.shouldnt.contain(google_arn) - certs.should.contain(moto_arn) + [c["CertificateArn"] for c in certs].should.contain(issued_arn) + [c["CertificateArn"] for c in certs].shouldnt.contain(pending_arn) certs = client.list_certificates( CertificateStatuses=["ISSUED", "PENDING_VALIDATION"] )["CertificateSummaryList"] - certs.should.contain(google_arn) - certs.should.contain(moto_arn) + [c["CertificateArn"] for c in certs].should.contain(issued_arn) + [c["CertificateArn"] for c in certs].should.contain(pending_arn) @mock_acm