Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #99 from Kinto/safety-check-default-bucket
Browse files Browse the repository at this point in the history
Prevents crash with events on default bucket on Kinto < 3.3
  • Loading branch information
leplatrem committed Jul 20, 2016
2 parents d9c1d46 + 9ce01c3 commit 40736c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This document describes changes between each past release.
**Bug fix**

- Update the `last_modified` value when updating the collection status and signature (#97)
- Prevents crash with events on ``default`` bucket on Kinto < 3.3


0.7.0 (2016-06-28)
Expand Down
6 changes: 6 additions & 0 deletions kinto_signer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def on_collection_changed(event, resources):
and update the destination.
"""
payload = event.payload

if 'bucket_id' not in payload:
# Safety check for kinto < 3.3 where events have incoherent payloads
# on default bucket.
return

key = "/buckets/{bucket_id}/collections/{collection_id}".format(**payload)
resource = resources.get(key)

Expand Down
5 changes: 5 additions & 0 deletions kinto_signer/tests/test_plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ def test_updater_is_called_when_resource_and_status_matches(self):
mocked = self.updater_mocked.return_value
assert mocked.sign_and_update_destination.called

def test_updater_does_not_fail_when_payload_is_inconsistent(self):
# This happens with events on default bucket for kinto < 3.3
evt = mock.MagicMock(payload={"subpath": "collections/boom"})
on_collection_changed(evt, resources=utils.parse_resources("a/b;c/d"))


class SigningErrorTest(BaseWebTest, unittest.TestCase):
def test_returns_503_if_autograph_cannot_be_reached(self):
Expand Down

0 comments on commit 40736c5

Please sign in to comment.