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

Function TestScope_AgentKeyPinnedToBoundAgent

internal/httpapi/scope_test.go:167–187  ·  view source on GitHub ↗

TestScope_AgentKeyPinnedToBoundAgent: a per-agent runtime route lets an agent-scoped credential act as its bound agent but 403s on any other agent; an account-scoped credential reaches both.

(t *testing.T)

Source from the content-addressed store, hash-verified

165// agent-scoped credential act as its bound agent but 403s on any other agent;
166// an account-scoped credential reaches both.
167func TestScope_AgentKeyPinnedToBoundAgent(t *testing.T) {
168 srv := scopeTestServer(t)
169
170 cases := []struct {
171 name, path, bearer string
172 wantStatus int
173 }{
174 {"bound-agent-ok", "/v1/agents/support%40acme.com", "agtSupport", 200},
175 {"other-agent-403", "/v1/agents/other%40acme.com", "agtSupport", 403},
176 {"account-reaches-support", "/v1/agents/support%40acme.com", "acct", 200},
177 {"account-reaches-other", "/v1/agents/other%40acme.com", "acct", 200},
178 }
179 for _, c := range cases {
180 t.Run(c.name, func(t *testing.T) {
181 code, body := sendJSON(t, "GET", srv.URL+c.path, c.bearer, nil)
182 if code != c.wantStatus {
183 t.Fatalf("GET %s as %s: status %d, want %d (body %v)", c.path, c.bearer, code, c.wantStatus, body)
184 }
185 })
186 }
187}
188
189// TestScope_LegacyAuthenticatorIsAccount: with only the legacy Authenticator
190// wired (no PrincipalAuthenticator), every caller is treated as account-scoped

Callers

nothing calls this directly

Calls 3

scopeTestServerFunction · 0.85
sendJSONFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected