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)
| 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. |
| 223 | func 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. |
| 243 | func TestHandler_AgentScoped_BoundAgent_Connects(t *testing.T) { |
nothing calls this directly
no test coverage detected