HIGH-1: an agent-scoped credential pinned to the SAME agent it targets connects.
(t *testing.T)
| 241 | |
| 242 | // HIGH-1: an agent-scoped credential pinned to the SAME agent it targets connects. |
| 243 | func 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 | |
| 263 | func TestHandler_SuccessfulConnect(t *testing.T) { |
| 264 | hub := NewHub() |
nothing calls this directly
no test coverage detected