Skip to content

Commit

Permalink
Prepend 'sha256' to an image Id if not already present
Browse files Browse the repository at this point in the history
  • Loading branch information
lubosmj committed Dec 9, 2019
1 parent 92fbeec commit 3114faa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/5830.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prepend 'sha256' to image Id if not already present
11 changes: 9 additions & 2 deletions pulp_container/tests/functional/api/test_token_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_pull_image_with_raw_http_requests(self):
)
self.compare_config_blob_digests(content_response['config']['digest'])

def test_pull_image_with_real_docker_client(self):
def test_pull_image_with_real_container_client(self):
"""
Test if a CLI client is able to pull an image from an authenticated registry.
Expand All @@ -121,7 +121,14 @@ def test_pull_image_with_real_docker_client(self):
registry.pull(image_with_tag)

image = registry.inspect(image_with_tag)
self.compare_config_blob_digests(image[0]['Id'])

# The docker client returns a different Id compared to an Id returned by the podman client.
# 'Id': 'sha256:d21d863f69b5de1a973a41344488f2ec89a625f2624195f51b4e2d54a97fc53b' (docker)
# 'Id': 'd21d863f69b5de1a973a41344488f2ec89a625f2624195f51b4e2d54a97fc53b' (podman)
# As long as the output differs in this manner, it is necessary to prepend the string
# 'sha256:' to the fetched digest.
image_digest = 'sha256:' + image[0]['Id'].lstrip('sha256:')
self.compare_config_blob_digests(image_digest)

def compare_config_blob_digests(self, pulled_manifest_digest):
"""Check if a valid config was pulled from a registry."""
Expand Down

0 comments on commit 3114faa

Please sign in to comment.