The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): trim allowlist test runner stub and isolate BlueBubbles env
kshitijk4poor8dfae717c15f
diff --git a/tests/gateway/test_allowlist_qualified_ids.py b/tests/gateway/test_allowlist_qualified_ids.pyindex fcfad547efe..0b3239c5820 100644--- a/tests/gateway/test_allowlist_qualified_ids.py+++ b/tests/gateway/test_allowlist_qualified_ids.py@@ -7,13 +7,10 @@ dedicated alias expansion. Left unconditional, it makes a bare allowlist entry'@'-shaped (email, Google Chat, iMessage handles) — domains the sender controls."""-from types import SimpleNamespace-from unittest.mock import AsyncMock, MagicMock-import pytestfrom gateway.authz_mixin import _principal_matches_allowlist-from gateway.config import GatewayConfig, Platform, PlatformConfig+from gateway.config import Platformfrom gateway.session import SessionSource@@ -27,34 +24,26 @@ def _source(platform: Platform, user_id: str) -> SessionSource:)-def _make_runner(platform: Platform):+def _make_runner():from gateway.run import GatewayRunnerrunner = object.__new__(GatewayRunner)- runner.config = GatewayConfig(platforms={platform: PlatformConfig(enabled=True)})- runner.adapters = {platform: SimpleNamespace(send=AsyncMock())}- runner.pairing_store = MagicMock()- runner.pairing_store.is_approved.return_value = False- runner.pairing_store._is_rate_limited.return_value = False- runner._running_agents = {}- runner._running_agents_ts = {}- runner._update_prompts = {}- runner.hooks = SimpleNamespace(dispatch=AsyncMock(return_value=None))- runner._sessions = {}+ runner.pairing_store = Nonereturn runner-# BlueBubbles registers no platform allowlist env and its adapter does no sender-# gate, so GATEWAY_ALLOWED_USERS is the only enforcement on that path.+# The BlueBubbles adapter does no sender gate of its own, so with its platform+# allowlist unset GATEWAY_ALLOWED_USERS is the only enforcement on that path.@pytest.mark.parametrize(("platform", "env_var"),[(Platform.EMAIL, "EMAIL_ALLOWED_USERS"), (Platform.BLUEBUBBLES, "GATEWAY_ALLOWED_USERS")],)def test_bare_localpart_entry_admits_no_foreign_domain(monkeypatch, platform, env_var):- for key in ("EMAIL_ALLOWED_USERS", "EMAIL_ALLOW_ALL_USERS", "GATEWAY_ALLOWED_USERS", "GATEWAY_ALLOW_ALL_USERS"):+ # conftest's hermetic env blanks the EMAIL_/GATEWAY_ vars but not BlueBubbles' own.+ for key in ("BLUEBUBBLES_ALLOWED_USERS", "BLUEBUBBLES_ALLOW_ALL_USERS"):monkeypatch.delenv(key, raising=False)monkeypatch.setenv(env_var, "alice,[email protected]")- runner = _make_runner(platform)+ runner = _make_runner()assert runner._is_user_authorized(_source(platform, "[email protected]")) is Falseassert runner._is_user_authorized(_source(platform, "[email protected]")) is False@@ -71,5 +60,4 @@ def test_bare_localpart_entry_admits_no_foreign_domain(monkeypatch, platform, en],)def test_whatsapp_bare_phone_entry_still_matches_jid(platform, user_id):- """The original intent survives via the scoped WhatsApp expansion, not the generic split."""assert _principal_matches_allowlist(_source(platform, user_id), user_id, {"15550000001"}) is True