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

Function TestHandler_AgentScoped_WrongAgent_Forbidden

internal/ws/handler_test.go:223–240  ·  view source on GitHub ↗

HIGH-1 regression: an agent-scoped credential pinned to agent A must NOT be able to open agent B's stream, even when both agents share the same owner.

(t *testing.T)

Source from the content-addressed store, hash-verified

221// HIGH-1 regression: an agent-scoped credential pinned to agent A must NOT be
222// able to open agent B's stream, even when both agents share the same owner.
223func TestHandler_AgentScoped_WrongAgent_Forbidden(t *testing.T) {
224 hub := NewHub()
225 defer hub.Close()
226 store := &mockStore{
227 user: newTestUser(), // user_1
228 scope: identity.ScopeAgent, // agent-scoped credential…
229 agentID: "agent_OTHER", // …bound to a different agent
230 agent: newTestAgent("user_1"), // target agent (id agent_test), same owner
231 }
232 handler := NewHandler(hub, store)
233 srv := startServer(t, handler)
234
235 resp := doHTTP(t, srv, "bot@agents.e2a.dev", "agent_a_key")
236 defer resp.Body.Close()
237 if resp.StatusCode != http.StatusForbidden {
238 t.Fatalf("agent-scoped key for a different agent must be 403, got %d", resp.StatusCode)
239 }
240}
241
242// HIGH-1: an agent-scoped credential pinned to the SAME agent it targets connects.
243func TestHandler_AgentScoped_BoundAgent_Connects(t *testing.T) {

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
NewHubFunction · 0.85
newTestUserFunction · 0.85
newTestAgentFunction · 0.85
NewHandlerFunction · 0.85
startServerFunction · 0.85
doHTTPFunction · 0.85

Tested by

no test coverage detected