add explicit permit/forbid test cases

This commit is contained in:
Peter Bieringer 2024-09-29 19:54:54 +02:00
parent 3e478ee6da
commit 72e4c4fadd

View file

@ -44,6 +44,16 @@ class TestBaseRequests(BaseTest):
self.configure({"rights": {"permit_delete_collection": True}}) self.configure({"rights": {"permit_delete_collection": True}})
with open(rights_file_path, "w") as f: with open(rights_file_path, "w") as f:
f.write("""\ f.write("""\
[permit delete collection]
user: .*
collection: test-permit-delete
permissions: RrWwD
[forbid delete collection]
user: .*
collection: test-forbid-delete
permissions: RrWwd
[allow all] [allow all]
user: .* user: .*
collection: .* collection: .*
@ -449,6 +459,24 @@ permissions: RrWw""")
_, responses = self.delete("/calendar.ics/", check=401) _, responses = self.delete("/calendar.ics/", check=401)
self.get("/calendar.ics/", check=200) self.get("/calendar.ics/", check=200)
def test_delete_collection_global_forbid_explicit_permit(self) -> None:
"""Delete a collection with permitted path (expect permit)."""
self.configure({"rights": {"permit_delete_collection": False}})
self.mkcalendar("/test-permit-delete/")
event = get_file_content("event1.ics")
self.put("/test-permit-delete/event1.ics", event)
_, responses = self.delete("/test-permit-delete/", check=200)
self.get("/test-permit-delete/", check=404)
def test_delete_collection_global_permit_explicit_forbid(self) -> None:
"""Delete a collection with permitted path (expect forbid)."""
self.configure({"rights": {"permit_delete_collection": True}})
self.mkcalendar("/test-forbid-delete/")
event = get_file_content("event1.ics")
self.put("/test-forbid-delete/event1.ics", event)
_, responses = self.delete("/test-forbid-delete/", check=401)
self.get("/test-forbid-delete/", check=200)
def test_delete_root_collection(self) -> None: def test_delete_root_collection(self) -> None:
"""Delete the root collection.""" """Delete the root collection."""
self.mkcalendar("/calendar.ics/") self.mkcalendar("/calendar.ics/")