Merge pull request #597 from coreos-inc/tag-validation
Update tag validation
This commit is contained in:
commit
c6da322ec1
6 changed files with 40 additions and 5 deletions
|
@ -212,8 +212,7 @@ class RegistryTestCase(LiveServerTestCase):
|
|||
|
||||
|
||||
# PUT /v1/repositories/{namespace}/{repository}/tags/latest
|
||||
self.conduct('PUT', '/v1/repositories/%s/%s/tags/latest' % (namespace, repository),
|
||||
data='"' + images[0]['id'] + '"')
|
||||
self.do_tag(namespace, repository, 'latest', images[0]['id'])
|
||||
|
||||
# PUT /v1/repositories/{namespace}/{repository}/images
|
||||
self.conduct('PUT', '/v1/repositories/%s/%s/images' % (namespace, repository),
|
||||
|
@ -246,6 +245,10 @@ class RegistryTestCase(LiveServerTestCase):
|
|||
self.conduct('GET', image_prefix + 'json')
|
||||
self.conduct('GET', image_prefix + 'layer')
|
||||
|
||||
def do_tag(self, namespace, repository, tag, image_id, expected_code=200):
|
||||
self.conduct('PUT', '/v1/repositories/%s/%s/tags/%s' % (namespace, repository, tag),
|
||||
data='"%s"' % image_id, expected_code=expected_code)
|
||||
|
||||
def conduct_api_login(self, username, password):
|
||||
self.conduct('POST', '/api/v1/signin',
|
||||
data=json.dumps(dict(username=username, password=password)),
|
||||
|
@ -437,5 +440,19 @@ class RegistryTests(RegistryTestCase):
|
|||
# org.
|
||||
self.do_pull('buynlarge', 'newrepo', 'devtable', 'password')
|
||||
|
||||
def test_tag_validation(self):
|
||||
image_id = 'onlyimagehere'
|
||||
images = [{
|
||||
'id': image_id
|
||||
}]
|
||||
self.do_push('public', 'newrepo', 'public', 'password', images)
|
||||
self.do_tag('public', 'newrepo', '1', image_id)
|
||||
self.do_tag('public', 'newrepo', 'x' * 128, image_id)
|
||||
self.do_tag('public', 'newrepo', '', image_id, expected_code=400)
|
||||
self.do_tag('public', 'newrepo', 'x' * 129, image_id, expected_code=400)
|
||||
self.do_tag('public', 'newrepo', '.fail', image_id, expected_code=400)
|
||||
self.do_tag('public', 'newrepo', '-fail', image_id, expected_code=400)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -2164,6 +2164,12 @@ class TestListAndDeleteTag(ApiTestCase):
|
|||
|
||||
self.assertEquals(staging_images, json['images'])
|
||||
|
||||
# Require a valid tag name.
|
||||
self.putResponse(RepositoryTag,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='-fail'),
|
||||
data=dict(image=staging_images[0]['id']),
|
||||
expected_code=400)
|
||||
|
||||
# Add a new tag to the staging image.
|
||||
self.putResponse(RepositoryTag,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='sometag'),
|
||||
|
|
Reference in a new issue