Repository: Kinto/kinto

Issue:
Deleting a collection doesn't delete access_control_entries for its children
`buckets.py` has an event listener that ensures that when a bucket is deleted, everything underneath it is recursively deleted. `collections.py` has one too but it doesn't appear to be as robust -- it doesn't have a wildcard to match objects more than one level below it (which might be OK, since only records are below collections now), and `delete_object_permissions` is only called on the collection rather than its children.


Discussion:
I'd like to work on this issue.
Great!

The problem seems to be this line:
https://github.com/Kinto/kinto/blob/a7f94773610566ec91f2d6172da910fb73fa84ef/kinto/views/collections.py#L59

Which does not contain a `*`, and thus does not delete children rows.

The starting point is http://kinto.readthedocs.io/en/stable/community.html#hack let us know if you need help!
Is this still relevant? @janani-sridhar are you on this? If not I'd like to take a look.
@janani-sridhar @OhadArzouan Are you guys on this one? I can pick it up if needed.
@alexryabkov if you can figure it out, please do.
@OhadArzouan sorry for the lack of response. sorry I wasn't able to work on it.
@Natim @leplatrem guys, just to make sure I understand correctly: this issue is already covered by test _test_permissions_are_deleted_when_collection_is_deleted_, correct?
Unfortunately, as awkward as it would look, it is not :( (because of #710)

The notion of *collection* in Kinto core is different, and so is the related test in `kinto/tests/core/resource/test_object_permissions.py`. I'm sorry, I know this is confusing.

Instead you should add a new test in `CollectionDeletionTest` in `tests/test_views_collections.py`

You can run this individual test with `py.test -k test_permissions_are_removed...`

Have fun ;) 
@leplatrem Thanks, will do my best ))

Resolving patch:
diff --git a/kinto/views/collections.py b/kinto/views/collections.py
--- a/kinto/views/collections.py
+++ b/kinto/views/collections.py
@@ -56,4 +56,4 @@ def on_collections_deleted(event):
                            with_deleted=False)
         storage.purge_deleted(collection_id=None,
                               parent_id=parent_id)
-        permission.delete_object_permissions(parent_id)
+        permission.delete_object_permissions(parent_id + '/*')


Test patch:
diff --git a/tests/test_views_collections.py b/tests/test_views_collections.py
--- a/tests/test_views_collections.py
+++ b/tests/test_views_collections.py
@@ -158,6 +158,14 @@ def test_can_be_created_after_deletion_with_if_none_match_star(self):
         self.app.put_json(self.collection_url, MINIMALIST_COLLECTION,
                           headers=headers, status=201)
 
+    def test_collection_permissions_are_removed_after_collection_deleted(self):
+        self.assertDictEqual(self.permission.get_object_permissions(
+                             self.collection_url), {})
+
+    def test_records_permissions_are_removed_after_collection_deleted(self):
+        self.assertDictEqual(self.permission.get_object_permissions(
+                             self.record_url), {})
+
 
 class CollectionCreationTest(BaseWebTest, unittest.TestCase):