Implement the full spec for the old Docker V1 registry search API

This API is still (apparently) being used by the Docker CLI for `docker search` (why?!) and we therefore have customers expecting this to work the same way as the DockerHub.
This commit is contained in:
Joseph Schorr 2017-02-08 11:59:22 -08:00
parent 6384b47849
commit a0bc0e9488
2 changed files with 59 additions and 14 deletions

View file

@ -1289,6 +1289,31 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
self.assertEquals(1, len(data['results']))
def test_search_pagination(self):
# Check for the first page.
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1'))
data = resp.json()
self.assertEquals('s', data['query'])
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
# Check for the followup pages.
for page_index in range(1, data['num_pages']):
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1', page=page_index))
data = resp.json()
self.assertEquals('s', data['query'])
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
def test_users(self):
# Not logged in, should 404.
self.conduct('GET', '/v1/users', expected_code=404)