parent
c3a401d960
commit
b1b0da7afd
3 changed files with 50 additions and 16 deletions
|
@ -2411,15 +2411,51 @@ class TestListAndDeleteTag(ApiTestCase):
|
|||
|
||||
latest_image = model.tag.get_tag_image(ADMIN_ACCESS_USER, "complex", "prod")
|
||||
|
||||
for i in xrange(1, 100):
|
||||
model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "complex", "tag" + str(i), latest_image.docker_image_id)
|
||||
# Create 10 tags in an empty repo.
|
||||
user = model.user.get_user_or_org(ADMIN_ACCESS_USER)
|
||||
repo = model.repository.create_repository(ADMIN_ACCESS_USER, "empty", user)
|
||||
|
||||
image = model.image.find_create_or_link_image(latest_image.docker_image_id, repo,
|
||||
ADMIN_ACCESS_USER, {}, ['local_us'])
|
||||
remaining_tags = set()
|
||||
for i in xrange(1, 11):
|
||||
tag_name = "tag" + str(i)
|
||||
remaining_tags.add(tag_name)
|
||||
model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "empty", tag_name,
|
||||
image.docker_image_id)
|
||||
|
||||
# Make sure we can iterate over all of them.
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/empty', page=1,
|
||||
limit=5))
|
||||
self.assertEquals(1, json['page'])
|
||||
self.assertEquals(5, len(json['tags']))
|
||||
self.assertTrue(json['has_additional'])
|
||||
|
||||
names = {tag['name'] for tag in json['tags']}
|
||||
remaining_tags = remaining_tags - names
|
||||
self.assertEquals(5, len(remaining_tags))
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/complex', page=2))
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/empty', page=2,
|
||||
limit=5))
|
||||
|
||||
self.assertEquals(2, json['page'])
|
||||
self.assertEquals(5, len(json['tags']))
|
||||
self.assertFalse(json['has_additional'])
|
||||
|
||||
names = {tag['name'] for tag in json['tags']}
|
||||
remaining_tags = remaining_tags - names
|
||||
self.assertEquals(0, len(remaining_tags))
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/empty', page=3,
|
||||
limit=5))
|
||||
|
||||
self.assertEquals(3, json['page'])
|
||||
self.assertEquals(0, len(json['tags']))
|
||||
self.assertFalse(json['has_additional'])
|
||||
|
||||
# Make sure that we're able to see the second page of results.
|
||||
assert json['page'] == 2
|
||||
assert len(json['tags']) == 50
|
||||
|
||||
class TestRepoPermissions(ApiTestCase):
|
||||
def listUserPermissions(self, namespace=ADMIN_ACCESS_USER, repo='simple'):
|
||||
|
|
Reference in a new issue