Move internal options to other sections

This commit is contained in:
Unrud 2020-02-19 09:50:36 +01:00
parent 8e3465b5d4
commit 180e96b332
10 changed files with 36 additions and 37 deletions

View File

@ -281,7 +281,7 @@ class Application(
logger.warning("Access to principal path %r denied by "
"rights backend", principal_path)
if self.configuration.get("_internal", "internal_server"):
if self.configuration.get("server", "_internal_server"):
# Verify content length
content_length = int(environ.get("CONTENT_LENGTH") or 0)
if content_length:

View File

@ -132,7 +132,11 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
"value": "",
"help": "set CA certificate for validating clients",
"aliases": ["--certificate-authority"],
"type": filepath})])),
"type": filepath}),
("_internal_server", {
"value": "False",
"help": "the internal server is used",
"type": bool})])),
("encoding", OrderedDict([
("request", {
"value": "utf-8",
@ -191,7 +195,11 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
("hook", {
"value": "",
"help": "command that is run after changes to storage",
"type": str})])),
"type": str}),
("_filesystem_fsync", {
"value": "True",
"help": "sync all changes to filesystem during requests",
"type": bool})])),
("web", OrderedDict([
("type", {
"value": "internal",
@ -208,16 +216,7 @@ DEFAULT_CONFIG_SCHEMA = OrderedDict([
"help": "mask passwords in logs",
"type": bool})])),
("headers", OrderedDict([
("_allow_extra", str)])),
("_internal", OrderedDict([
("filesystem_fsync", {
"value": "True",
"help": "sync all changes to filesystem during requests",
"type": bool}),
("internal_server", {
"value": "False",
"help": "the internal server is used",
"type": bool})]))])
("_allow_extra", str)]))])
def parse_compound_paths(*compound_paths):

View File

@ -200,7 +200,7 @@ def serve(configuration, shutdown_socket):
logger.info("Starting Radicale")
# Copy configuration before modifying
configuration = configuration.copy()
configuration.update({"_internal": {"internal_server": "True"}}, "server",
configuration.update({"server": {"_internal_server": "True"}}, "server",
privileged=True)
use_ssl = configuration.get("server", "ssl")

View File

@ -125,7 +125,7 @@ class Storage(
return os.path.join(filesystem_folder, "collection-root")
def _fsync(self, fd):
if self.configuration.get("_internal", "filesystem_fsync"):
if self.configuration.get("storage", "_filesystem_fsync"):
pathutils.fsync(fd)
def _sync_directory(self, path):
@ -134,7 +134,7 @@ class Storage(
This only works on POSIX and does nothing on other systems.
"""
if not self.configuration.get("_internal", "filesystem_fsync"):
if not self.configuration.get("storage", "_filesystem_fsync"):
return
if os.name == "posix":
try:

View File

@ -42,9 +42,9 @@ class TestBaseAuthRequests(BaseTest):
self.configuration = config.load()
self.colpath = tempfile.mkdtemp()
self.configuration.update({
"storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance
"_internal": {"filesystem_fsync": "False"},
"storage": {"filesystem_folder": self.colpath,
# Disable syncing to disk for better performance
"_filesystem_fsync": "False"},
# Set incorrect authentication delay to a very low value
"auth": {"delay": "0.002"}}, "test", privileged=True)

View File

@ -1348,9 +1348,9 @@ collection: .*
permissions: RrWw""")
self.configuration.update({
"storage": {"type": self.storage_type,
"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance
"_internal": {"filesystem_fsync": "False"},
"filesystem_folder": self.colpath,
# Disable syncing to disk for better performance
"_filesystem_fsync": "False"},
"rights": {"file": rights_file_path,
"type": "from_file"}}, "test", privileged=True)
self.application = Application(self.configuration)
@ -1373,7 +1373,7 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_fsync(self):
"""Create a directory and file with syncing enabled."""
self.configuration.update({"_internal": {"filesystem_fsync": "True"}},
self.configuration.update({"storage": {"_filesystem_fsync": "True"}},
"test", privileged=True)
self.application = Application(self.configuration)
self.mkcalendar("/calendar.ics/")

View File

@ -131,15 +131,15 @@ class TestConfig:
assert "section 'server" in str(e)
assert "'x'" in str(e)
def test_internal(self):
def test_privileged(self):
configuration = config.load()
configuration.update({"_internal": {"internal_server": "True"}},
configuration.update({"server": {"_internal_server": "True"}},
"test", privileged=True)
with pytest.raises(Exception) as exc_info:
configuration.update(
{"_internal": {"internal_server": "True"}}, "test")
{"server": {"_internal_server": "True"}}, "test")
e = exc_info.value
assert "Invalid section '_internal'" in str(e)
assert "Invalid option '_internal_server'" in str(e)
def test_plugin_schema(self):
plugin_schema = {"auth": {"new_option": {"value": "False",

View File

@ -35,9 +35,9 @@ class TestBaseRightsRequests(BaseTest):
self.configuration = config.load()
self.colpath = tempfile.mkdtemp()
self.configuration.update({
"storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance
"_internal": {"filesystem_fsync": "False"}},
"storage": {"filesystem_folder": self.colpath,
# Disable syncing to disk for better performance
"_filesystem_fsync": "False"}},
"test", privileged=True)
def teardown(self):

View File

@ -63,12 +63,12 @@ class TestBaseServerRequests(BaseTest):
sock.bind(("127.0.0.1", 0))
self.sockname = sock.getsockname()
self.configuration.update({
"storage": {"filesystem_folder": self.colpath},
"storage": {"filesystem_folder": self.colpath,
# Disable syncing to disk for better performance
"_filesystem_fsync": "False"},
"server": {"hosts": "[%s]:%d" % self.sockname},
# Enable debugging for new processes
"logging": {"level": "debug"},
# Disable syncing to disk for better performance
"_internal": {"filesystem_fsync": "False"}},
"logging": {"level": "debug"}},
"test", privileged=True)
self.thread = threading.Thread(target=server.serve, args=(
self.configuration, shutdown_socket_out))

View File

@ -33,9 +33,9 @@ class TestBaseWebRequests(BaseTest):
self.configuration = config.load()
self.colpath = tempfile.mkdtemp()
self.configuration.update({
"storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance
"_internal": {"filesystem_fsync": "False"}},
"storage": {"filesystem_folder": self.colpath,
# Disable syncing to disk for better performance
"_filesystem_fsync": "False"}},
"test", privileged=True)
self.application = Application(self.configuration)