Return error for GET requests on directories
Radicale doesn't support directory listings.
This commit is contained in:
parent
4ac2e68f5c
commit
1ea9b1dca9
@ -67,6 +67,8 @@ REQUEST_ENTITY_TOO_LARGE = (client.REQUEST_ENTITY_TOO_LARGE,
|
|||||||
"Request body too large.")
|
"Request body too large.")
|
||||||
REMOTE_DESTINATION = (client.BAD_GATEWAY, {"Content-type": "text/plain"},
|
REMOTE_DESTINATION = (client.BAD_GATEWAY, {"Content-type": "text/plain"},
|
||||||
"Remote destination not supported.")
|
"Remote destination not supported.")
|
||||||
|
DIRECTORY_LISTING = (client.FORBIDDEN, {"Content-type": "text/plain"},
|
||||||
|
"Directory listings are not supported.")
|
||||||
|
|
||||||
DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
|
DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
|
||||||
|
|
||||||
@ -451,6 +453,8 @@ class Application:
|
|||||||
return NOT_FOUND
|
return NOT_FOUND
|
||||||
if isinstance(item, self.Collection):
|
if isinstance(item, self.Collection):
|
||||||
collection = item
|
collection = item
|
||||||
|
if collection.get_meta("tag") not in ("VADDRESSBOOK", "VCALENDAR"):
|
||||||
|
return DIRECTORY_LISTING
|
||||||
else:
|
else:
|
||||||
collection = item.collection
|
collection = item.collection
|
||||||
content_type = xmlutils.MIMETYPES.get(
|
content_type = xmlutils.MIMETYPES.get(
|
||||||
|
@ -736,8 +736,8 @@ class BaseRequestsMixIn:
|
|||||||
def test_principal_collection_creation(self):
|
def test_principal_collection_creation(self):
|
||||||
"""Verify existence of the principal collection."""
|
"""Verify existence of the principal collection."""
|
||||||
status, headers, answer = self.request(
|
status, headers, answer = self.request(
|
||||||
"GET", "/user/", REMOTE_USER="user")
|
"PROPFIND", "/user/", REMOTE_USER="user")
|
||||||
assert status == 200
|
assert status == 207
|
||||||
|
|
||||||
def test_existence_of_root_collections(self):
|
def test_existence_of_root_collections(self):
|
||||||
"""Verify that the root collection always exists."""
|
"""Verify that the root collection always exists."""
|
||||||
@ -762,8 +762,8 @@ class BaseRequestsMixIn:
|
|||||||
"created_by_hook"))
|
"created_by_hook"))
|
||||||
status, headers, answer = self.request("MKCOL", "/calendar.ics/")
|
status, headers, answer = self.request("MKCOL", "/calendar.ics/")
|
||||||
assert status == 201
|
assert status == 201
|
||||||
status, headers, answer = self.request("GET", "/created_by_hook/")
|
status, headers, answer = self.request("PROPFIND", "/created_by_hook/")
|
||||||
assert status == 200
|
assert status == 207
|
||||||
|
|
||||||
def test_hook_read_access(self):
|
def test_hook_read_access(self):
|
||||||
"""Verify that hook is not run for read accesses."""
|
"""Verify that hook is not run for read accesses."""
|
||||||
@ -791,8 +791,8 @@ class BaseRequestsMixIn:
|
|||||||
"created_by_hook"))
|
"created_by_hook"))
|
||||||
status, headers, answer = self.request("GET", "/", REMOTE_USER="user")
|
status, headers, answer = self.request("GET", "/", REMOTE_USER="user")
|
||||||
assert status == 200
|
assert status == 200
|
||||||
status, headers, answer = self.request("GET", "/created_by_hook/")
|
status, headers, answer = self.request("PROPFIND", "/created_by_hook/")
|
||||||
assert status == 200
|
assert status == 207
|
||||||
|
|
||||||
def test_hook_fail(self):
|
def test_hook_fail(self):
|
||||||
"""Verify that a request fails if the hook fails."""
|
"""Verify that a request fails if the hook fails."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user