|
|
@@ -779,10 +779,10 @@ class BaseRequestsMixIn:
|
|
|
|
|
|
def test_authentication(self):
|
|
|
"""Test if server sends authentication request."""
|
|
|
- self.configuration.set("auth", "type", "htpasswd")
|
|
|
- self.configuration.set("auth", "htpasswd_filename", os.devnull)
|
|
|
- self.configuration.set("auth", "htpasswd_encryption", "plain")
|
|
|
- self.configuration.set("rights", "type", "owner_only")
|
|
|
+ self.configuration["auth"]["type"] = "htpasswd"
|
|
|
+ self.configuration["auth"]["htpasswd_filename"] = os.devnull
|
|
|
+ self.configuration["auth"]["htpasswd_encryption"] = "plain"
|
|
|
+ self.configuration["rights"]["type"] = "owner_only"
|
|
|
self.application = Application(self.configuration, self.logger)
|
|
|
status, headers, answer = self.request("MKCOL", "/user/")
|
|
|
assert status in (401, 403)
|
|
|
@@ -791,7 +791,8 @@ class BaseRequestsMixIn:
|
|
|
def test_principal_collection_creation(self):
|
|
|
"""Verify existence of the principal collection."""
|
|
|
status, headers, answer = self.request(
|
|
|
- "PROPFIND", "/user/", REMOTE_USER="user")
|
|
|
+ "PROPFIND", "/user/", HTTP_AUTHORIZATION=(
|
|
|
+ "Basic " + base64.b64encode(b"user:").decode()))
|
|
|
assert status == 207
|
|
|
|
|
|
def test_existence_of_root_collections(self):
|
|
|
@@ -806,15 +807,14 @@ class BaseRequestsMixIn:
|
|
|
|
|
|
def test_fsync(self):
|
|
|
"""Create a directory and file with syncing enabled."""
|
|
|
- self.configuration.set("storage", "filesystem_fsync", "True")
|
|
|
+ self.configuration["storage"]["filesystem_fsync"] = "True"
|
|
|
status, headers, answer = self.request("MKCALENDAR", "/calendar.ics/")
|
|
|
assert status == 201
|
|
|
|
|
|
def test_hook(self):
|
|
|
"""Run hook."""
|
|
|
- self.configuration.set(
|
|
|
- "storage", "hook", "mkdir %s" % os.path.join(
|
|
|
- "collection-root", "created_by_hook"))
|
|
|
+ self.configuration["storage"]["hook"] = (
|
|
|
+ "mkdir %s" % os.path.join("collection-root", "created_by_hook"))
|
|
|
status, headers, answer = self.request("MKCOL", "/calendar.ics/")
|
|
|
assert status == 201
|
|
|
status, headers, answer = self.request("PROPFIND", "/created_by_hook/")
|
|
|
@@ -822,9 +822,8 @@ class BaseRequestsMixIn:
|
|
|
|
|
|
def test_hook_read_access(self):
|
|
|
"""Verify that hook is not run for read accesses."""
|
|
|
- self.configuration.set(
|
|
|
- "storage", "hook", "mkdir %s" % os.path.join(
|
|
|
- "collection-root", "created_by_hook"))
|
|
|
+ self.configuration["storage"]["hook"] = (
|
|
|
+ "mkdir %s" % os.path.join("collection-root", "created_by_hook"))
|
|
|
status, headers, answer = self.request("GET", "/")
|
|
|
assert status == 303
|
|
|
status, headers, answer = self.request("GET", "/created_by_hook/")
|
|
|
@@ -834,24 +833,25 @@ class BaseRequestsMixIn:
|
|
|
reason="flock command not found")
|
|
|
def test_hook_storage_locked(self):
|
|
|
"""Verify that the storage is locked when the hook runs."""
|
|
|
- self.configuration.set(
|
|
|
- "storage", "hook", "flock -n .Radicale.lock || exit 0; exit 1")
|
|
|
+ self.configuration["storage"]["hook"] = (
|
|
|
+ "flock -n .Radicale.lock || exit 0; exit 1")
|
|
|
status, headers, answer = self.request("MKCOL", "/calendar.ics/")
|
|
|
assert status == 201
|
|
|
|
|
|
def test_hook_principal_collection_creation(self):
|
|
|
"""Verify that the hooks runs when a new user is created."""
|
|
|
- self.configuration.set(
|
|
|
- "storage", "hook", "mkdir %s" % os.path.join(
|
|
|
- "collection-root", "created_by_hook"))
|
|
|
- status, headers, answer = self.request("GET", "/", REMOTE_USER="user")
|
|
|
+ self.configuration["storage"]["hook"] = (
|
|
|
+ "mkdir %s" % os.path.join("collection-root", "created_by_hook"))
|
|
|
+ status, headers, answer = self.request(
|
|
|
+ "GET", "/", HTTP_AUTHORIZATION=(
|
|
|
+ "Basic " + base64.b64encode(b"user:").decode()))
|
|
|
assert status == 303
|
|
|
status, headers, answer = self.request("PROPFIND", "/created_by_hook/")
|
|
|
assert status == 207
|
|
|
|
|
|
def test_hook_fail(self):
|
|
|
"""Verify that a request fails if the hook fails."""
|
|
|
- self.configuration.set("storage", "hook", "exit 1")
|
|
|
+ self.configuration["storage"]["hook"] = "exit 1"
|
|
|
try:
|
|
|
status, headers, answer = self.request("MKCOL", "/calendar.ics/")
|
|
|
assert status != 201
|
|
|
@@ -877,13 +877,13 @@ class BaseFileSystemTest(BaseTest):
|
|
|
|
|
|
def setup(self):
|
|
|
self.configuration = config.load()
|
|
|
- self.configuration.set("storage", "type", self.storage_type)
|
|
|
+ self.configuration["storage"]["type"] = self.storage_type
|
|
|
self.colpath = tempfile.mkdtemp()
|
|
|
- self.configuration.set("storage", "filesystem_folder", self.colpath)
|
|
|
+ self.configuration["storage"]["filesystem_folder"] = self.colpath
|
|
|
# Disable syncing to disk for better performance
|
|
|
- self.configuration.set("storage", "filesystem_fsync", "False")
|
|
|
+ self.configuration["storage"]["filesystem_fsync"] = "False"
|
|
|
# Required on Windows, doesn't matter on Unix
|
|
|
- self.configuration.set("storage", "filesystem_close_lock_file", "True")
|
|
|
+ self.configuration["storage"]["filesystem_close_lock_file"] = "True"
|
|
|
self.application = Application(self.configuration, self.logger)
|
|
|
|
|
|
def teardown(self):
|