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

[WIP] Default bucket integration (fixes #25) #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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