The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): prove the ticket and webapp control clients refuse a foreign listener
Teknium45136e3aa873
diff --git a/tests/gateway/test_control_socket_peer_security.py b/tests/gateway/test_control_socket_peer_security.pyindex 263c089723e..7b207619d63 100644--- a/tests/gateway/test_control_socket_peer_security.py+++ b/tests/gateway/test_control_socket_peer_security.py@@ -108,15 +108,19 @@ def test_clients_refuse_a_control_listener_run_by_another_uid(tmp_path, monkeypa# client must authenticate the listening process itself (SO_PEERCRED / getpeereid).import asyncioimport inspect+ from types import SimpleNamespacefrom gateway import control_socket, session_hosted_transport- from hermes_cli import gateway_client+ from hermes_cli import gateway_client, webapp_launcherfrom hermes_cli import gateway_runtime_discovery as discoveryhome = tmp_path / "home"home.mkdir(mode=0o700)real_uid = os.getuid()+ answered = []+ endpoint = SimpleNamespace(profile_id="default", instance_id="owner", control_home=None)async def run():- server = control_socket.GatewayControlServer(home, verb_handlers={"identify": lambda: {"pid": 1}})+ server = control_socket.GatewayControlServer(+ home, verb_handlers={"identify": lambda: answered.append("identify") or {"pid": 1}})assert await server.start()try:path = discovery._socket_path(home)@@ -124,6 +128,11 @@ def test_clients_refuse_a_control_listener_run_by_another_uid(tmp_path, monkeypamonkeypatch.setattr(discovery, "_socket_path", lambda _home: path)with pytest.raises(discovery.DiscoveryError, match="unsafe_control_peer"):await asyncio.to_thread(discovery.query_identify, home, timeout=2)+ with pytest.raises(discovery.DiscoveryError, match="unsafe_control_peer"):+ await asyncio.to_thread(gateway_client._session_ticket, home, endpoint)+ with pytest.raises(webapp_launcher.GatewayUnreachable, match="unsafe_control_peer"):+ await asyncio.to_thread(webapp_launcher._control, home, "identify")+ assert answered == [] # refused before a request reached the listenerfinally:monkeypatch.undo()await server.stop()@@ -135,11 +144,6 @@ def test_clients_refuse_a_control_listener_run_by_another_uid(tmp_path, monkeypafor client in (gateway_client.private_control_query, session_hosted_transport.owner_request, tui_bootstrap.bootstrap):source = inspect.getsource(client)assert "connect_private(" in source and "AF_UNIX" not in source, client.__qualname__- # The other control-socket clients dial through private_control_query.- from hermes_cli import webapp_launcher- for caller in (gateway_client._session_ticket, webapp_launcher._control):- source = inspect.getsource(caller)- assert "private_control_query(" in source and "AF_UNIX" not in source, caller.__qualname__def test_long_home_survives_a_squatted_shared_fallback_directory(tmp_path, monkeypatch):