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

Function TestScope_LegacyAuthenticatorIsAccount

internal/httpapi/scope_test.go:192–212  ·  view source on GitHub ↗

TestScope_LegacyAuthenticatorIsAccount: with only the legacy Authenticator wired (no PrincipalAuthenticator), every caller is treated as account-scoped — the pre-Slice-5a behavior, so the ceiling never falsely 403s old deployments.

(t *testing.T)

Source from the content-addressed store, hash-verified

190// wired (no PrincipalAuthenticator), every caller is treated as account-scoped
191// — the pre-Slice-5a behavior, so the ceiling never falsely 403s old deployments.
192func TestScope_LegacyAuthenticatorIsAccount(t *testing.T) {
193 deps := Deps{
194 Authenticator: func(r *http.Request) (*identity.User, error) {
195 if r.Header.Get("Authorization") == "Bearer good" {
196 return &identity.User{ID: "u_1"}, nil
197 }
198 return nil, errors.New("unauthorized")
199 },
200 ListAgents: func(ctx context.Context, userID string) ([]identity.AgentIdentity, error) {
201 return []identity.AgentIdentity{sampleAgent()}, nil
202 },
203 Legacy: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusTeapot) }),
204 }
205 srv := httptest.NewServer(New(deps))
206 t.Cleanup(srv.Close)
207
208 code, body := sendJSON(t, "GET", srv.URL+"/v1/agents", "good", nil)
209 if code != 200 {
210 t.Fatalf("legacy authenticator on account route: status %d, want 200 (body %v)", code, body)
211 }
212}

Callers

nothing calls this directly

Calls 6

sampleAgentFunction · 0.85
sendJSONFunction · 0.85
CleanupMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected