Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Session-based channel discovery must not resurrect disconnected platforms.
|
||||
|
||||
Surgical reapply of the directory portion of PR #25959: historical session
|
||||
origins for platforms with no connected adapter must not become active
|
||||
send_message targets."""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
from gateway.channel_directory import build_channel_directory
|
||||
from gateway.platforms.base import Platform
|
||||
|
||||
|
||||
def test_does_not_resurrect_disconnected_platforms_from_session_history(tmp_path, monkeypatch):
|
||||
cache_file = tmp_path / "channel_directory.json"
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_build_from_sessions(plat_name):
|
||||
calls.append(plat_name)
|
||||
return {"channels": [{"id": "1", "name": "old"}]}
|
||||
|
||||
with patch("gateway.channel_directory._build_from_sessions", side_effect=fake_build_from_sessions), \
|
||||
patch("gateway.channel_directory.DIRECTORY_PATH", cache_file):
|
||||
# Only telegram is connected; no discord/slack/whatsapp adapters.
|
||||
directory = asyncio.run(build_channel_directory({Platform.TELEGRAM: object()}))
|
||||
|
||||
plats = directory["platforms"]
|
||||
assert "telegram" in plats
|
||||
# Disconnected platforms must not appear via session discovery.
|
||||
for stale in ("whatsapp", "signal", "matrix"):
|
||||
assert stale not in plats, f"{stale} resurrected from session history"
|
||||
assert set(calls) <= {"telegram"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user