Skip to content

Commit badb5dc

Browse files
committed
fix tests
1 parent b16a415 commit badb5dc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/client/auth.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ describe("OAuth Authorization", () => {
11251125
expect(body.get("refresh_token")).toBe("refresh123");
11261126
});
11271127

1128-
it("handles empty resource parameter", async () => {
1128+
it("handles derived resource parameter from serverUrl", async () => {
11291129
// Mock successful metadata discovery
11301130
mockFetch.mockImplementation((url) => {
11311131
const urlString = url.toString();
@@ -1154,17 +1154,18 @@ describe("OAuth Authorization", () => {
11541154
(mockProvider.saveCodeVerifier as jest.Mock).mockResolvedValue(undefined);
11551155
(mockProvider.redirectToAuthorization as jest.Mock).mockResolvedValue(undefined);
11561156

1157-
// Call auth with empty resource parameter
1157+
// Call auth with just serverUrl (resource is derived from it)
11581158
const result = await auth(mockProvider, {
11591159
serverUrl: "https://api.example.com/mcp-server",
11601160
});
11611161

11621162
expect(result).toBe("REDIRECT");
11631163

1164-
// Verify that empty resource is not included in the URL
1164+
// Verify that resource parameter is always included (derived from serverUrl)
11651165
const redirectCall = (mockProvider.redirectToAuthorization as jest.Mock).mock.calls[0];
11661166
const authUrl: URL = redirectCall[0];
1167-
expect(authUrl.searchParams.has("resource")).toBe(false);
1167+
expect(authUrl.searchParams.has("resource")).toBe(true);
1168+
expect(authUrl.searchParams.get("resource")).toBe("https://api.example.com/mcp-server");
11681169
});
11691170

11701171
it("handles resource with multiple fragments", async () => {

src/examples/server/demoInMemoryOAuthProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('DemoInMemoryOAuthProvider', () => {
178178
await expect(provider.exchangeRefreshToken(
179179
mockClient,
180180
'refresh-token'
181-
)).rejects.toThrow('Refresh tokens not implemented for example demo');
181+
)).rejects.toThrow('Not implemented for example demo');
182182
});
183183
});
184184

0 commit comments

Comments
 (0)