|
9 | 9 |
|
10 | 10 | "github.com/github/github-mcp-server/internal/githubv4mock" |
11 | 11 | "github.com/github/github-mcp-server/internal/toolsnaps" |
12 | | - "github.com/github/github-mcp-server/pkg/lockdown" |
13 | 12 | "github.com/github/github-mcp-server/pkg/translations" |
14 | 13 | "github.com/google/go-github/v82/github" |
15 | 14 | "github.com/google/jsonschema-go/jsonschema" |
@@ -101,7 +100,7 @@ func Test_GetPullRequest(t *testing.T) { |
101 | 100 | deps := BaseDeps{ |
102 | 101 | Client: client, |
103 | 102 | GQLClient: gqlClient, |
104 | | - RepoAccessCache: stubRepoAccessCache(gqlClient, 5*time.Minute), |
| 103 | + RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute), |
105 | 104 | Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}), |
106 | 105 | } |
107 | 106 | handler := serverTool.Handler(deps) |
@@ -1202,7 +1201,7 @@ func Test_GetPullRequestFiles(t *testing.T) { |
1202 | 1201 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
1203 | 1202 | deps := BaseDeps{ |
1204 | 1203 | Client: client, |
1205 | | - RepoAccessCache: stubRepoAccessCache(githubv4.NewClient(githubv4mock.NewMockedHTTPClient()), 5*time.Minute), |
| 1204 | + RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute), |
1206 | 1205 | Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}), |
1207 | 1206 | } |
1208 | 1207 | handler := serverTool.Handler(deps) |
@@ -1362,7 +1361,7 @@ func Test_GetPullRequestStatus(t *testing.T) { |
1362 | 1361 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
1363 | 1362 | deps := BaseDeps{ |
1364 | 1363 | Client: client, |
1365 | | - RepoAccessCache: stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), |
| 1364 | + RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute), |
1366 | 1365 | Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}), |
1367 | 1366 | } |
1368 | 1367 | handler := serverTool.Handler(deps) |
@@ -1518,7 +1517,7 @@ func Test_GetPullRequestCheckRuns(t *testing.T) { |
1518 | 1517 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
1519 | 1518 | deps := BaseDeps{ |
1520 | 1519 | Client: client, |
1521 | | - RepoAccessCache: stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), |
| 1520 | + RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute), |
1522 | 1521 | Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}), |
1523 | 1522 | } |
1524 | 1523 | handler := serverTool.Handler(deps) |
@@ -1937,17 +1936,15 @@ func Test_GetPullRequestComments(t *testing.T) { |
1937 | 1936 | } |
1938 | 1937 |
|
1939 | 1938 | // Setup cache for lockdown mode |
1940 | | - var cache *lockdown.RepoAccessCache |
| 1939 | + var restClient *github.Client |
1941 | 1940 | if tc.lockdownEnabled { |
1942 | | - restClient := mockRESTPermissionServer(t, "read", map[string]string{ |
| 1941 | + restClient = mockRESTPermissionServer(t, "read", map[string]string{ |
1943 | 1942 | "maintainer": "write", |
1944 | 1943 | "external-user": "read", |
1945 | 1944 | "testuser": "read", |
1946 | 1945 | }) |
1947 | | - cache = stubLockdownCache(t, restClient, 5*time.Minute) |
1948 | | - } else { |
1949 | | - cache = stubRepoAccessCache(gqlClient, 5*time.Minute) |
1950 | 1946 | } |
| 1947 | + cache := stubRepoAccessCache(restClient, 5*time.Minute) |
1951 | 1948 |
|
1952 | 1949 | flags := stubFeatureFlags(map[string]bool{"lockdown-mode": tc.lockdownEnabled}) |
1953 | 1950 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
@@ -2111,20 +2108,14 @@ func Test_GetPullRequestReviews(t *testing.T) { |
2111 | 2108 | t.Run(tc.name, func(t *testing.T) { |
2112 | 2109 | // Setup client with mock |
2113 | 2110 | client := github.NewClient(tc.mockedClient) |
2114 | | - gqlClient := defaultGQLClient |
2115 | | - if tc.gqlHTTPClient != nil { |
2116 | | - gqlClient = githubv4.NewClient(tc.gqlHTTPClient) |
2117 | | - } |
2118 | | - var cache *lockdown.RepoAccessCache |
| 2111 | + var restClient *github.Client |
2119 | 2112 | if tc.lockdownEnabled { |
2120 | | - restClient := mockRESTPermissionServer(t, "read", map[string]string{ |
| 2113 | + restClient = mockRESTPermissionServer(t, "read", map[string]string{ |
2121 | 2114 | "maintainer": "write", |
2122 | 2115 | "testuser": "read", |
2123 | 2116 | }) |
2124 | | - cache = stubLockdownCache(t, restClient, 5*time.Minute) |
2125 | | - } else { |
2126 | | - cache = stubRepoAccessCache(gqlClient, 5*time.Minute) |
2127 | 2117 | } |
| 2118 | + cache := stubRepoAccessCache(restClient, 5*time.Minute) |
2128 | 2119 | flags := stubFeatureFlags(map[string]bool{"lockdown-mode": tc.lockdownEnabled}) |
2129 | 2120 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
2130 | 2121 | deps := BaseDeps{ |
@@ -3359,7 +3350,7 @@ index 5d6e7b2..8a4f5c3 100644 |
3359 | 3350 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
3360 | 3351 | deps := BaseDeps{ |
3361 | 3352 | Client: client, |
3362 | | - RepoAccessCache: stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), |
| 3353 | + RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute), |
3363 | 3354 | Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}), |
3364 | 3355 | } |
3365 | 3356 | handler := serverTool.Handler(deps) |
|
0 commit comments