From b7cf2d4478d8b6c2f77189dc792ad08e6774dc54 Mon Sep 17 00:00:00 2001 From: Peter Lithammer Date: Thu, 5 Nov 2020 15:10:23 +0100 Subject: [PATCH] ecr: Fix "imageDigest" value in ecr.list_images() response (#3436) --- moto/ecr/models.py | 2 +- tests/test_ecr/test_ecr_boto3.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/moto/ecr/models.py b/moto/ecr/models.py index 33a0201fd..299ed48a7 100644 --- a/moto/ecr/models.py +++ b/moto/ecr/models.py @@ -164,7 +164,7 @@ class Image(BaseObject): def response_list_object(self): response_object = self.gen_response_object() response_object["imageTag"] = self.image_tag - response_object["imageDigest"] = "i don't know" + response_object["imageDigest"] = self.get_image_digest() return { k: v for k, v in response_object.items() if v is not None and v != [None] } diff --git a/tests/test_ecr/test_ecr_boto3.py b/tests/test_ecr/test_ecr_boto3.py index 6c6840a7e..fd678f661 100644 --- a/tests/test_ecr/test_ecr_boto3.py +++ b/tests/test_ecr/test_ecr_boto3.py @@ -318,6 +318,9 @@ def test_list_images(): type(response["imageIds"]).should.be(list) len(response["imageIds"]).should.be(3) + for image in response["imageIds"]: + image["imageDigest"].should.contain("sha") + image_tags = ["latest", "v1", "v2"] set( [ @@ -331,6 +334,7 @@ def test_list_images(): type(response["imageIds"]).should.be(list) len(response["imageIds"]).should.be(1) response["imageIds"][0]["imageTag"].should.equal("oldest") + response["imageIds"][0]["imageDigest"].should.contain("sha") @mock_ecr