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)
| 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. |
| 192 | func 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 | } |
nothing calls this directly
no test coverage detected