Merge pull request #1923 from coreos-inc/numeric-tag-test

Fix issue in V1 registry code with accessing locations under HEAD
This commit is contained in:
josephschorr 2016-10-03 17:20:45 +03:00 committed by GitHub
commit 6f55d4d793
3 changed files with 12 additions and 15 deletions

View file

@ -22,14 +22,6 @@ class DockerRegistryV1DataInterface(object):
Interface that represents all data store interactions required by a Docker Registry v1. Interface that represents all data store interactions required by a Docker Registry v1.
""" """
@abstractmethod
def placement_locations_docker_v1(self, namespace_name, repo_name, image_id):
"""
Returns all the placements for the image with the given V1 Docker ID, found under the given
repository or None if no image was found.
"""
pass
@abstractmethod @abstractmethod
def placement_locations_and_path_docker_v1(self, namespace_name, repo_name, image_id): def placement_locations_and_path_docker_v1(self, namespace_name, repo_name, image_id):
""" """
@ -233,12 +225,6 @@ class PreOCIModel(DockerRegistryV1DataInterface):
PreOCIModel implements the data model for the v1 Docker Registry protocol using a database schema PreOCIModel implements the data model for the v1 Docker Registry protocol using a database schema
before it was changed to support the OCI specification. before it was changed to support the OCI specification.
""" """
def placement_locations_docker_v1(self, namespace_name, repo_name, image_id):
repo_image = model.image.get_repo_image_and_storage(namespace_name, repo_name, image_id)
if repo_image is None or repo_image.storage is None:
return None
return repo_image.storage.locations
def placement_locations_and_path_docker_v1(self, namespace_name, repo_name, image_id): def placement_locations_and_path_docker_v1(self, namespace_name, repo_name, image_id):
repo_image = model.image.get_repo_image_extended(namespace_name, repo_name, image_id) repo_image = model.image.get_repo_image_extended(namespace_name, repo_name, image_id)
if not repo_image or repo_image.storage is None: if not repo_image or repo_image.storage is None:

View file

@ -84,7 +84,7 @@ def head_image_layer(namespace, repository, image_id, headers):
logger.debug('Checking repo permissions') logger.debug('Checking repo permissions')
if permission.can() or model.repository_is_public(namespace, repository): if permission.can() or model.repository_is_public(namespace, repository):
logger.debug('Looking up placement locations') logger.debug('Looking up placement locations')
locations = model.placement_locations_docker_v1(namespace, repository, image_id) locations, _ = model.placement_locations_and_path_docker_v1(namespace, repository, image_id)
if locations is None: if locations is None:
logger.debug('Could not find any blob placement locations') logger.debug('Could not find any blob placement locations')
abort(404, 'Image %(image_id)s not found', issue='unknown-image', abort(404, 'Image %(image_id)s not found', issue='unknown-image',

View file

@ -438,6 +438,10 @@ class V1RegistryPullMixin(V1RegistryMixin):
response = self.conduct('GET', image_prefix + 'json', auth='sig') response = self.conduct('GET', image_prefix + 'json', auth='sig')
self.assertEquals(image_id, response.json()['id']) self.assertEquals(image_id, response.json()['id'])
# Ensure we can HEAD the image layer.
self.conduct('HEAD', image_prefix + 'layer', auth='sig')
# And retrieve the layer data.
response = self.conduct('GET', image_prefix + 'layer', auth='sig') response = self.conduct('GET', image_prefix + 'layer', auth='sig')
# Ensure we can parse the layer bytes and that they contain the contents. # Ensure we can parse the layer bytes and that they contain the contents.
@ -1143,6 +1147,13 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMixin, class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMixin,
RegistryTestCaseMixin, LiveServerTestCase): RegistryTestCaseMixin, LiveServerTestCase):
""" Tests for V2 registry. """ """ Tests for V2 registry. """
def test_numeric_tag(self):
# Push a new repository.
self.do_push('public', 'new-repo', 'public', 'password', tag_name='1234')
# Pull the repository.
self.do_pull('public', 'new-repo', 'public', 'password', manifest_id='1234')
def test_label_invalid_manifest(self): def test_label_invalid_manifest(self):
images = [{ images = [{
'id': 'someid', 'id': 'someid',