Visitar URL original
test: tighten public repo scope coverage · github/github-mcp-server@d0b863f · GitHub
Skip to content

Commit d0b863f

Browse files
test: tighten public repo scope coverage
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 7a42c6f commit d0b863f

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

‎pkg/github/public_repo_scopes_test.go‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package github
22

33
import (
4-
"context"
54
"testing"
65

76
"github.com/github/github-mcp-server/pkg/inventory"
@@ -11,7 +10,7 @@ import (
1110
"github.com/stretchr/testify/require"
1211
)
1312

14-
func TestPublicRepoContributionToolScopes(t *testing.T) {
13+
func TestPublicRepoContributionToolOAuthScopes(t *testing.T) {
1514
t.Parallel()
1615

1716
tools := []struct {
@@ -20,28 +19,21 @@ func TestPublicRepoContributionToolScopes(t *testing.T) {
2019
}{
2120
{name: "fork_repository", tool: ForkRepository(translations.NullTranslationHelper)},
2221
{name: "create_branch", tool: CreateBranch(translations.NullTranslationHelper)},
23-
{name: "push_files", tool: PushFiles(translations.NullTranslationHelper)},
2422
{name: "create_pull_request", tool: CreatePullRequest(translations.NullTranslationHelper)},
2523
{name: "issue_write", tool: IssueWrite(translations.NullTranslationHelper)},
2624
{name: "add_issue_comment", tool: AddIssueComment(translations.NullTranslationHelper)},
2725
}
2826

2927
for _, tt := range tools {
3028
t.Run(tt.name, func(t *testing.T) {
31-
assert.True(t, tt.tool.ScopeAccess.Visible([]string{string(scopes.PublicRepo)}))
32-
assert.True(t, tt.tool.ScopeAccess.Visible([]string{string(scopes.Repo)}))
33-
29+
assert.Equal(t, []string{string(scopes.PublicRepo)}, tt.tool.ScopeAccess.Scopes)
30+
assert.Equal(t, []string{string(scopes.PublicRepo)}, tt.tool.ScopeAccess.Challenge(nil, nil))
3431
for _, activeScopes := range [][]string{
3532
{string(scopes.PublicRepo)},
3633
{string(scopes.Repo)},
3734
} {
3835
assert.Empty(t, tt.tool.ScopeAccess.Challenge(nil, activeScopes))
3936
}
40-
41-
if tt.name != "push_files" {
42-
assert.Equal(t, []string{string(scopes.PublicRepo)}, tt.tool.ScopeAccess.Scopes)
43-
assert.Equal(t, []string{string(scopes.PublicRepo)}, tt.tool.ScopeAccess.Challenge(nil, nil))
44-
}
4537
})
4638
}
4739
}
@@ -62,7 +54,7 @@ func TestPublicRepoContributionToolsVisibleToPATs(t *testing.T) {
6254
t.Run(string(tokenScope), func(t *testing.T) {
6355
filter := CreateToolScopeFilter([]string{string(tokenScope)})
6456
for i := range tools {
65-
included, err := filter(context.Background(), &tools[i])
57+
included, err := filter(t.Context(), &tools[i])
6658
require.NoError(t, err)
6759
assert.True(t, included, "%s should be visible", tools[i].Tool.Name)
6860
}

0 commit comments

Comments
 (0)