Change default value for external users

This commit is contained in:
Unrud 2020-01-12 23:32:26 +01:00
parent a7f4ffa7d4
commit caf5ff1080
9 changed files with 16 additions and 15 deletions

View File

@ -110,8 +110,7 @@ def run():
os.environ.get("RADICALE_CONFIG"), os.environ.get("RADICALE_CONFIG"),
args.config)) args.config))
if arguments_config: if arguments_config:
configuration.update( configuration.update(arguments_config, "arguments")
arguments_config, "arguments", internal=False)
except Exception as e: except Exception as e:
logger.fatal("Invalid configuration: %s", e, exc_info=True) logger.fatal("Invalid configuration: %s", e, exc_info=True)
exit(1) exit(1)

View File

@ -274,7 +274,7 @@ def load(paths=()):
except Exception as e: except Exception as e:
raise RuntimeError( raise RuntimeError(
"Failed to load %s: %s" % (config_source, e)) from e "Failed to load %s: %s" % (config_source, e)) from e
configuration.update(config, config_source, internal=False) configuration.update(config, config_source)
return configuration return configuration
@ -298,9 +298,9 @@ class Configuration:
if option.startswith("_"): if option.startswith("_"):
continue continue
values[section][option] = schema[section][option]["value"] values[section][option] = schema[section][option]["value"]
self.update(values, "default config") self.update(values, "default config", internal=True)
def update(self, config, source, internal=True): def update(self, config, source, internal=False):
"""Update the configuration. """Update the configuration.
``config`` a dict of the format {SECTION: {OPTION: VALUE, ...}, ...}. ``config`` a dict of the format {SECTION: {OPTION: VALUE, ...}, ...}.

View File

@ -247,7 +247,8 @@ def serve(configuration, shutdown_socket=None):
logger.info("Starting Radicale") logger.info("Starting Radicale")
# Copy configuration before modifying # Copy configuration before modifying
configuration = configuration.copy() configuration = configuration.copy()
configuration.update({"internal": {"internal_server": "True"}}, "server") configuration.update({"internal": {"internal_server": "True"}}, "server",
internal=True)
# Create collection servers # Create collection servers
servers = {} servers = {}

View File

@ -47,7 +47,7 @@ class TestBaseAuthRequests(BaseTest):
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}, "internal": {"filesystem_fsync": "False"},
# Set incorrect authentication delay to a very low value # Set incorrect authentication delay to a very low value
"auth": {"delay": "0.002"}}, "test") "auth": {"delay": "0.002"}}, "test", internal=True)
def teardown(self): def teardown(self):
shutil.rmtree(self.colpath) shutil.rmtree(self.colpath)

View File

@ -1476,7 +1476,7 @@ permissions: RrWw""")
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}, "internal": {"filesystem_fsync": "False"},
"rights": {"file": rights_file_path, "rights": {"file": rights_file_path,
"type": "from_file"}}, "test") "type": "from_file"}}, "test", internal=True)
self.application = Application(self.configuration) self.application = Application(self.configuration)
def teardown(self): def teardown(self):
@ -1490,7 +1490,7 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_fsync(self): def test_fsync(self):
"""Create a directory and file with syncing enabled.""" """Create a directory and file with syncing enabled."""
self.configuration.update({ self.configuration.update({
"internal": {"filesystem_fsync": "True"}}, "test") "internal": {"filesystem_fsync": "True"}}, "test", internal=True)
self.application = Application(self.configuration) self.application = Application(self.configuration)
status, _, _ = self.request("MKCALENDAR", "/calendar.ics/") status, _, _ = self.request("MKCALENDAR", "/calendar.ics/")
assert status == 201 assert status == 201

View File

@ -134,10 +134,11 @@ class TestConfig:
def test_internal(self): def test_internal(self):
configuration = config.load() configuration = config.load()
configuration.update({"internal": {"internal_server": "True"}}, "test") configuration.update({"internal": {"internal_server": "True"}}, "test",
internal=True)
with pytest.raises(Exception) as exc_info: with pytest.raises(Exception) as exc_info:
configuration.update({"internal": {"internal_server": "True"}}, configuration.update(
"test", internal=False) {"internal": {"internal_server": "True"}}, "test")
e = exc_info.value e = exc_info.value
assert "Invalid section 'internal'" in str(e) assert "Invalid section 'internal'" in str(e)

View File

@ -38,7 +38,7 @@ class TestBaseRightsRequests(BaseTest):
self.configuration.update({ self.configuration.update({
"storage": {"filesystem_folder": self.colpath}, "storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}}, "test") "internal": {"filesystem_fsync": "False"}}, "test", internal=True)
def teardown(self): def teardown(self):
shutil.rmtree(self.colpath) shutil.rmtree(self.colpath)

View File

@ -68,7 +68,7 @@ class TestBaseServerRequests:
# Enable debugging for new processes # Enable debugging for new processes
"logging": {"level": "debug"}, "logging": {"level": "debug"},
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}}, "test") "internal": {"filesystem_fsync": "False"}}, "test", internal=True)
self.thread = threading.Thread(target=server.serve, args=( self.thread = threading.Thread(target=server.serve, args=(
self.configuration, shutdown_socket_out)) self.configuration, shutdown_socket_out))
ssl_context = ssl.create_default_context() ssl_context = ssl.create_default_context()

View File

@ -36,7 +36,7 @@ class TestBaseWebRequests(BaseTest):
self.configuration.update({ self.configuration.update({
"storage": {"filesystem_folder": self.colpath}, "storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}}, "test") "internal": {"filesystem_fsync": "False"}}, "test", internal=True)
self.application = Application(self.configuration) self.application = Application(self.configuration)
def teardown(self): def teardown(self):