Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Default bucket integration (fixes #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed May 23, 2017
1 parent 500f9b1 commit 4f052fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kinto_elasticsearch/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def __init__(self, request):
@search.post(permission=authorization.DYNAMIC)
def get_search(request):
bucket_id = request.matchdict['bucket_id']
if bucket_id == "default":
try:
bucket_id = request.default_bucket_id
except AttributeError as e: # pragma: no cover
pass # `default` bucket without default_bucket plugin.

collection_id = request.matchdict['collection_id']

query = request.body
Expand Down
1 change: 1 addition & 0 deletions tests/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use = egg:kinto
kinto.userid_hmac_secret = some-secret-string

kinto.includes = kinto_elasticsearch
kinto.plugins.default_bucket
kinto.plugins.flush
# We need indices to be refreshed immediately for assertions.
kinto.elasticsearch.force_refresh = true
6 changes: 6 additions & 0 deletions tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def test_search_on_empty_collection_returns_empty_list(self):
result = resp.json
assert len(result["hits"]["hits"]) == 0

def test_search_on_default_bucket_implicit_collection_returns_empty_list(self):
resp = self.app.post("/buckets/default/collections/yeah/search",
headers=self.headers)
result = resp.json
assert len(result["hits"]["hits"]) == 0


class PermissionsCheck(BaseWebTest, unittest.TestCase):
def test_search_is_allowed_if_write_on_bucket(self):
Expand Down

0 comments on commit 4f052fe

Please sign in to comment.