parent
6ae13096c7
commit
bab17932ac
2 changed files with 21 additions and 1 deletions
|
@ -315,7 +315,7 @@ def _conduct_repo_search(username, query, results):
|
||||||
if repo.is_public:
|
if repo.is_public:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return ReadRepositoryPermission(repo.namespace_name, repo.name).can()
|
return ReadRepositoryPermission(repo.namespace_user.username, repo.name).can()
|
||||||
|
|
||||||
only_public = username is None
|
only_public = username is None
|
||||||
matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read, limit=5)
|
matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read, limit=5)
|
||||||
|
|
|
@ -1273,6 +1273,26 @@ class RegistryTestsMixin(object):
|
||||||
class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMixin,
|
class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMixin,
|
||||||
RegistryTestCaseMixin, LiveServerTestCase):
|
RegistryTestCaseMixin, LiveServerTestCase):
|
||||||
""" Tests for V1 registry. """
|
""" Tests for V1 registry. """
|
||||||
|
def test_search(self):
|
||||||
|
# Public
|
||||||
|
resp = self.conduct('GET', '/v1/search', params=dict(q='public'))
|
||||||
|
data = resp.json()
|
||||||
|
self.assertEquals(1, data['num_results'])
|
||||||
|
self.assertEquals(1, len(data['results']))
|
||||||
|
|
||||||
|
# Simple (not logged in, no results)
|
||||||
|
resp = self.conduct('GET', '/v1/search', params=dict(q='simple'))
|
||||||
|
data = resp.json()
|
||||||
|
self.assertEquals(0, data['num_results'])
|
||||||
|
self.assertEquals(0, len(data['results']))
|
||||||
|
|
||||||
|
# Simple (logged in)
|
||||||
|
resp = self.conduct('GET', '/v1/search', params=dict(q='simple'), auth=('devtable', 'password'))
|
||||||
|
data = resp.json()
|
||||||
|
self.assertEquals(1, data['num_results'])
|
||||||
|
self.assertEquals(1, len(data['results']))
|
||||||
|
|
||||||
|
|
||||||
def test_users(self):
|
def test_users(self):
|
||||||
# Not logged in, should 404.
|
# Not logged in, should 404.
|
||||||
self.conduct('GET', '/v1/users', expected_code=404)
|
self.conduct('GET', '/v1/users', expected_code=404)
|
||||||
|
|
Reference in a new issue