diff --git a/data/model/tag.py b/data/model/tag.py index 199d99704..5875c95b1 100644 --- a/data/model/tag.py +++ b/data/model/tag.py @@ -134,6 +134,7 @@ def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None): .where(RepositoryTag.repository == repo_obj) .where(RepositoryTag.hidden == False) .order_by(RepositoryTag.lifetime_start_ts.desc()) + .order_by(RepositoryTag.name) .paginate(page, size)) if specific_tag: diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index 5246ee9c6..b8ad1906a 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -43,7 +43,7 @@ class ListRepositoryTags(RepositoryParamResource): specific_tag = args.get('specificTag') or None - page = min(1, args.get('start', 1)) + page = max(1, args.get('page', 1)) limit = min(100, max(1, args.get('limit', 50))) # Note: We ask for limit+1 here, so we can check to see if there are diff --git a/test/test_api_usage.py b/test/test_api_usage.py index c39ac4fec..163a10977 100644 --- a/test/test_api_usage.py +++ b/test/test_api_usage.py @@ -2079,6 +2079,7 @@ class TestRevertTag(ApiTestCase): self.assertEquals(previous_image_id, json['tags'][0]['docker_image_id']) + class TestListAndDeleteTag(ApiTestCase): def test_listdeletecreateandmovetag(self): self.login(ADMIN_ACCESS_USER) @@ -2166,6 +2167,19 @@ class TestListAndDeleteTag(ApiTestCase): self.assertEquals(prod_images, json['images']) + def test_listtagpagination(self): + self.login(ADMIN_ACCESS_USER) + + for i in xrange(1, 100): + model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "complex", "tag" + str(i), + "1d8cbff4e0363d1826c6a0b64ef0bc501d8cbff4e0363d1826c6a0b64ef0bc50") + + json = self.getJsonResponse(ListRepositoryTags, + params=dict(repository=ADMIN_ACCESS_USER + '/complex', page=2)) + + # 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'):