Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
config_dir_path and data_dir_path are not optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Apr 7, 2022
1 parent d86adae commit ca9238b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
4 changes: 1 addition & 3 deletions synapse/_scripts/review_recent_signups.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def main() -> None:
config_args = parser.parse_args(sys.argv[1:])
config_files = find_config_files(search_paths=config_args.config_path)
config_dict = read_config_files(config_files)
config.parse_config_dict(
config_dict,
)
config.parse_config_dict(config_dict, "", "")

since_ms = time.time() * 1000 - Config.parse_duration(config_args.since)
exclude_users_with_email = config_args.exclude_emails
Expand Down
5 changes: 1 addition & 4 deletions synapse/config/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,7 @@ def load_or_generate_config(
return obj

def parse_config_dict(
self,
config_dict: Dict[str, Any],
config_dir_path: Optional[str] = None,
data_dir_path: Optional[str] = None,
self, config_dict: Dict[str, Any], config_dir_path: str, data_dir_path: str
) -> None:
"""Read the information from the config dict into this Config object.
Expand Down
5 changes: 1 addition & 4 deletions synapse/config/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ class RootConfig:
@classmethod
def invoke_all_static(cls, func_name: str, *args: Any, **kwargs: Any) -> None: ...
def parse_config_dict(
self,
config_dict: Dict[str, Any],
config_dir_path: Optional[str] = ...,
data_dir_path: Optional[str] = ...,
self, config_dict: Dict[str, Any], config_dir_path: str, data_dir_path: str
) -> None: ...
def generate_config(
self,
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class KeyConfig(Config):
section = "key"

def read_config(
self, config: JsonDict, config_dir_path: Optional[str], **kwargs: Any
self, config: JsonDict, config_dir_path: str, **kwargs: Any
) -> None:
# the signing key can be specified inline or in a separate file
if "signing_key" in config:
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
self.inhibit_user_in_use_error = config.get("inhibit_user_in_use_error", False)

def generate_config_section(
self, generate_secrets: Optional[bool] = False, **kwargs: Any
self, generate_secrets: bool = False, **kwargs: Any
) -> str:
if generate_secrets:
registration_shared_secret = 'registration_shared_secret: "%s"' % (
Expand Down
4 changes: 1 addition & 3 deletions synapse/config/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
"url_preview_accept_language"
) or ["en"]

def generate_config_section(
self, data_dir_path: Optional[str], **kwargs: Any
) -> str:
def generate_config_section(self, data_dir_path: str, **kwargs: Any) -> str:
assert data_dir_path is not None
media_store = os.path.join(data_dir_path, "media_store")

Expand Down
24 changes: 18 additions & 6 deletions tests/config/test_registration_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
"session_lifetime": "30m",
"nonrefreshable_access_token_lifetime": "31m",
**config_dict,
}
},
"",
"",
)

with self.assertRaises(ConfigError):
Expand All @@ -46,7 +48,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
"session_lifetime": "30m",
"refreshable_access_token_lifetime": "31m",
**config_dict,
}
},
"",
"",
)

with self.assertRaises(ConfigError):
Expand All @@ -55,7 +59,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
"session_lifetime": "30m",
"refresh_token_lifetime": "31m",
**config_dict,
}
},
"",
"",
)

# Then test all the fine conditions
Expand All @@ -64,19 +70,25 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
"session_lifetime": "31m",
"nonrefreshable_access_token_lifetime": "31m",
**config_dict,
}
},
"",
"",
)

HomeServerConfig().parse_config_dict(
{
"session_lifetime": "31m",
"refreshable_access_token_lifetime": "31m",
**config_dict,
}
},
"",
"",
)

HomeServerConfig().parse_config_dict(
{"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict}
{"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict},
"",
"",
)

def test_refuse_to_start_if_open_registration_and_no_verification(self):
Expand Down

0 comments on commit ca9238b

Please sign in to comment.