fix(gateway): keep env-token Slack enabled
This commit is contained in:
@@ -356,6 +356,81 @@ def test_config_bridges_slack_free_response_channels(monkeypatch, tmp_path):
|
||||
assert _os.environ["SLACK_FREE_RESPONSE_CHANNELS"] == "C0AQWDLHY9M,C9999999999"
|
||||
|
||||
|
||||
def test_top_level_slack_settings_do_not_disable_env_token_setup(monkeypatch, tmp_path):
|
||||
from gateway.config import load_gateway_config
|
||||
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"slack:\n"
|
||||
" require_mention: false\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
monkeypatch.setenv("SLACK_BOT_TOKEN", "xoxb-test")
|
||||
monkeypatch.delenv("SLACK_REQUIRE_MENTION", raising=False)
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
slack_config = config.platforms[Platform.SLACK]
|
||||
assert slack_config.enabled is True
|
||||
assert slack_config.token == "xoxb-test"
|
||||
assert slack_config.extra.get("require_mention") is False
|
||||
assert "_enabled_explicit" not in slack_config.extra
|
||||
|
||||
|
||||
def test_explicit_top_level_slack_enabled_false_wins_over_env_token(monkeypatch, tmp_path):
|
||||
from gateway.config import load_gateway_config
|
||||
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"slack:\n"
|
||||
" enabled: false\n"
|
||||
" require_mention: false\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
monkeypatch.setenv("SLACK_BOT_TOKEN", "xoxb-test")
|
||||
monkeypatch.delenv("SLACK_REQUIRE_MENTION", raising=False)
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
slack_config = config.platforms[Platform.SLACK]
|
||||
assert slack_config.enabled is False
|
||||
assert slack_config.token == "xoxb-test"
|
||||
assert slack_config.extra.get("require_mention") is False
|
||||
assert "_enabled_explicit" not in slack_config.extra
|
||||
|
||||
|
||||
def test_explicit_platforms_slack_enabled_false_wins_over_env_token(monkeypatch, tmp_path):
|
||||
from gateway.config import load_gateway_config
|
||||
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"platforms:\n"
|
||||
" slack:\n"
|
||||
" enabled: false\n"
|
||||
" extra:\n"
|
||||
" reply_in_thread: false\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
monkeypatch.setenv("SLACK_BOT_TOKEN", "xoxb-test")
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
slack_config = config.platforms[Platform.SLACK]
|
||||
assert slack_config.enabled is False
|
||||
assert slack_config.token == "xoxb-test"
|
||||
assert slack_config.extra.get("reply_in_thread") is False
|
||||
assert "_enabled_explicit" not in slack_config.extra
|
||||
|
||||
|
||||
def test_config_bridges_slack_reply_in_thread(monkeypatch, tmp_path):
|
||||
from gateway.config import load_gateway_config
|
||||
|
||||
|
||||
Reference in New Issue
Block a user