MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestHandler_AgentScoped_BoundAgent_Connects

Function TestHandler_AgentScoped_BoundAgent_Connects

internal/ws/handler_test.go:243–261  ·  view source on GitHub ↗

HIGH-1: an agent-scoped credential pinned to the SAME agent it targets connects.

(t *testing.T)

Source from the content-addressed store, hash-verified

241
242// HIGH-1: an agent-scoped credential pinned to the SAME agent it targets connects.
243func TestHandler_AgentScoped_BoundAgent_Connects(t *testing.T) {
244 hub := NewHub()
245 defer hub.Close()
246 store := &mockStore{
247 user: newTestUser(),
248 scope: identity.ScopeAgent,
249 agentID: "agent_test", // matches newTestAgent's ID
250 agent: newTestAgent("user_1"),
251 }
252 handler := NewHandler(hub, store)
253 srv := startServer(t, handler)
254
255 conn, _ := dialWS(t, srv, "bot@agents.e2a.dev", "agent_test_key")
256 if conn == nil {
257 t.Fatal("agent-scoped key for its own agent should connect")
258 }
259 defer conn.Close(websocket.StatusNormalClosure, "")
260 waitConnected(t, hub, "agent_test")
261}
262
263func TestHandler_SuccessfulConnect(t *testing.T) {
264 hub := NewHub()

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
NewHubFunction · 0.85
newTestUserFunction · 0.85
newTestAgentFunction · 0.85
NewHandlerFunction · 0.85
startServerFunction · 0.85
dialWSFunction · 0.85
waitConnectedFunction · 0.85

Tested by

no test coverage detected