fix(gateway): bridge webhook env settings for config enablement
This commit is contained in:
@@ -316,9 +316,15 @@ def _api_server(config: GatewayConfig) -> None:
|
||||
|
||||
|
||||
def _webhook(config: GatewayConfig) -> None:
|
||||
if is_truthy_value(getenv("WEBHOOK_ENABLED")):
|
||||
extra = _enable_from_env(config, Platform.WEBHOOK, pop_marker=True, warn=False).extra
|
||||
_env_extras(extra, (("port", "WEBHOOK_PORT", _INT), ("secret", "WEBHOOK_SECRET")))
|
||||
enabled = is_truthy_value(getenv("WEBHOOK_ENABLED"))
|
||||
if not (enabled or Platform.WEBHOOK in config.platforms):
|
||||
return
|
||||
webhook_config = (
|
||||
_enable_from_env(config, Platform.WEBHOOK, pop_marker=True, warn=False)
|
||||
if enabled
|
||||
else config.platforms[Platform.WEBHOOK]
|
||||
)
|
||||
_env_extras(webhook_config.extra, (("port", "WEBHOOK_PORT", _INT), ("secret", "WEBHOOK_SECRET")))
|
||||
|
||||
|
||||
def _msgraph_webhook(config: GatewayConfig) -> None:
|
||||
|
||||
@@ -1479,6 +1479,27 @@ class TestApiServerEnvOverride:
|
||||
|
||||
|
||||
class TestWebhookEnvOverride:
|
||||
def test_config_enabled_webhook_reads_env_port_and_secret(self, tmp_path, monkeypatch):
|
||||
"""A config.yaml-enabled webhook still receives its .env listener settings."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"platforms:\n"
|
||||
" webhook:\n"
|
||||
" enabled: true\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
monkeypatch.delenv("WEBHOOK_ENABLED", raising=False)
|
||||
monkeypatch.setenv("WEBHOOK_PORT", "9012")
|
||||
monkeypatch.setenv("WEBHOOK_SECRET", "webhook-env-secret")
|
||||
|
||||
webhook = load_gateway_config().platforms[Platform.WEBHOOK]
|
||||
|
||||
assert webhook.enabled is True
|
||||
assert webhook.extra["port"] == 9012
|
||||
assert webhook.extra["secret"] == "webhook-env-secret"
|
||||
|
||||
def test_env_key_does_not_reenable_explicitly_disabled_webhook(self):
|
||||
"""An explicit ``platforms.webhook.enabled: false`` must survive
|
||||
_apply_env_overrides() even when WEBHOOK_ENABLED is truthy in the env.
|
||||
|
||||
Reference in New Issue
Block a user