fix: verify_ssl: true in YAML now uses DEFAULT_REDMINE_VERIFY path
Previously boolean True was passed directly to python-redmine which used system CA bundle instead of the project's default CA file. Now 'true' in YAML maps to DEFAULT_REDMINE_VERIFY path.
This commit is contained in:
@@ -139,13 +139,13 @@ class AppConfig:
|
|||||||
if value is None:
|
if value is None:
|
||||||
return DEFAULT_REDMINE_VERIFY
|
return DEFAULT_REDMINE_VERIFY
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
return value
|
return DEFAULT_REDMINE_VERIFY if value else False
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
normalized = value.lower()
|
normalized = value.lower()
|
||||||
if normalized in FALSE_VALUES:
|
if normalized in FALSE_VALUES:
|
||||||
return False
|
return False
|
||||||
if normalized in TRUE_VALUES:
|
if normalized in TRUE_VALUES:
|
||||||
return True
|
return DEFAULT_REDMINE_VERIFY
|
||||||
return resolve_env_vars(value)
|
return resolve_env_vars(value)
|
||||||
return DEFAULT_REDMINE_VERIFY
|
return DEFAULT_REDMINE_VERIFY
|
||||||
|
|
||||||
|
|||||||
@@ -247,6 +247,26 @@ class TestAppConfigFromYaml:
|
|||||||
|
|
||||||
assert cfg.redmine_api_key == "secret-token"
|
assert cfg.redmine_api_key == "secret-token"
|
||||||
|
|
||||||
|
def test_verify_ssl_true_returns_default_ca_path(self):
|
||||||
|
"""verify_ssl: true → DEFAULT_REDMINE_VERIFY (путь), не Python True."""
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
yaml_path = Path(tmp) / "config.yml"
|
||||||
|
yaml_path.write_text("redmine:\n verify_ssl: true\n")
|
||||||
|
|
||||||
|
cfg = AppConfig.from_yaml(yaml_path)
|
||||||
|
|
||||||
|
assert cfg.redmine_verify == DEFAULT_REDMINE_VERIFY
|
||||||
|
assert cfg.redmine_verify is not True # не бул!
|
||||||
|
|
||||||
|
def test_verify_ssl_false_returns_false(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
yaml_path = Path(tmp) / "config.yml"
|
||||||
|
yaml_path.write_text("redmine:\n verify_ssl: false\n")
|
||||||
|
|
||||||
|
cfg = AppConfig.from_yaml(yaml_path)
|
||||||
|
|
||||||
|
assert cfg.redmine_verify is False
|
||||||
|
|
||||||
def test_missing_env_var_logs_warning(self, caplog):
|
def test_missing_env_var_logs_warning(self, caplog):
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user