Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(auth): keep scope benchmark local
Remove the temporary performance benchmark from the committed test suite while retaining its measurements in the pull request description.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
SamMorrowDrums and Copilot committed Aug 25, 2026
commit 8de98b3e51e143a9e06ee7fb7587837d07bcacf5
55 changes: 0 additions & 55 deletions pkg/http/middleware/scope_challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,58 +366,3 @@ func scopeChallengeContextWithScopes(ctx context.Context, activeScopes []string)
ctx = ghcontext.WithTokenScopes(ctx, activeScopes)
return ctx
}

func BenchmarkWithScopeChallengeDynamicPolicy(b *testing.B) {
scopes.SetGlobalToolScopeMap(scopes.ToolScopeMap{
"write_file": scopes.DynamicChallenge(
[]scopes.Scope{scopes.Repo, scopes.Workflow},
func([]string) bool { return true },
func(arguments map[string]any, activeScopes []string) []string {
if path, _ := arguments["path"].(string); strings.HasPrefix(path, ".github/workflows/") {
return scopes.ChallengeAll(activeScopes, scopes.Repo, scopes.Workflow)
}
return scopes.ChallengeAll(activeScopes, scopes.Repo)
},
),
})
b.Cleanup(func() { scopes.SetGlobalToolScopeMap(nil) })

for _, payload := range []struct {
name string
size int
}{
{name: "small_arguments", size: 256},
{name: "large_arguments", size: 32 * 1024},
} {
body := `{"jsonrpc":"2.0","method":"tools/call","params":{"name":"write_file","arguments":{"path":"README.md","nested":[{"payload":"` +
strings.Repeat("x", payload.size) + `"},[1,2,3]]}}}`
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var downstreamRequest mcpJSONRPCRequest
_ = json.NewDecoder(r.Body).Decode(&downstreamRequest)
var arguments map[string]any
_ = json.Unmarshal(downstreamRequest.Params.Arguments, &arguments)
w.WriteHeader(http.StatusNoContent)
})
handler := WithMCPParse()(WithScopeChallenge(&oauth.Config{}, &mockScopeFetcher{})(next))

b.Run(payload.name, func(b *testing.B) {
for _, benchmark := range []struct {
name string
activeScopes []string
}{
{name: "maximum_scopes_fast_path", activeScopes: []string{"repo", "workflow"}},
{name: "call_specific_decode", activeScopes: []string{"repo"}},
} {
b.Run(benchmark.name, func(b *testing.B) {
b.ReportAllocs()
b.SetBytes(int64(len(body)))
for b.Loop() {
request := httptest.NewRequest(http.MethodPost, "/mcp", strings.NewReader(body))
request = request.WithContext(scopeChallengeContextWithScopes(request.Context(), benchmark.activeScopes))
handler.ServeHTTP(httptest.NewRecorder(), request)
}
})
}
})
}
}
Loading