From 61f11a246a07435eadbf3ebf00ab336e45d68cd7 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 16 Oct 2017 08:46:32 -0200 Subject: [bug] use all default server config values Server config dictionary was being poorly updated, and not all default values were being added in runtime. This was mainly a problem in tests, but fixing may avoid possible bugs with this implementation in the future. --- src/leap/soledad/server/auth.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/leap/soledad/server') diff --git a/src/leap/soledad/server/auth.py b/src/leap/soledad/server/auth.py index 39eb09f6..d0884e01 100644 --- a/src/leap/soledad/server/auth.py +++ b/src/leap/soledad/server/auth.py @@ -48,13 +48,17 @@ from ._config import get_config log = Logger() +def _update_with_defaults(conf): + for k, v in get_config().items(): + conf.setdefault(k, v) + + @implementer(IRealm) class SoledadRealm(object): - def __init__(self, sync_pool, conf=None): + def __init__(self, sync_pool, conf={}): assert sync_pool is not None - if conf is None: - conf = get_config() + _update_with_defaults(conf) blobs = conf['blobs'] concurrent_writes = conf['concurrent_blob_writes'] blobs_resource = BlobsResource( @@ -110,9 +114,9 @@ class LocalServicesRealm(object): class FileTokenChecker(object): credentialInterfaces = [IUsernamePassword, IAnonymous] - def __init__(self, conf=None): + def __init__(self, conf={}): # conf parameter is only used during tests - conf = conf or get_config() + _update_with_defaults(conf) self._trusted_services_tokens = {} self._tokens_file_path = conf['services_tokens_file'] self._reload_tokens() -- cgit v1.2.3