Skip to content

Commit 885590c

Browse files
Fixing tests
1 parent 26b4743 commit 885590c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/client/auth.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ describe("OAuth Authorization", () => {
6060
// Verify second call was made without header
6161
expect(mockFetch).toHaveBeenCalledTimes(2);
6262
const secondCallOptions = mockFetch.mock.calls[1][1];
63-
expect(secondCallOptions).toBeUndefined(); // No options means no headers
63+
// The second call still has options but doesn't include MCP-Protocol-Version header
64+
expect(secondCallOptions).toBeDefined();
65+
expect(secondCallOptions?.headers).toBeUndefined();
6466
});
6567

66-
it("returns undefined when all fetch attempts fail", async () => {
68+
it("throws an error when all fetch attempts fail", async () => {
6769
// Both requests fail
6870
mockFetch.mockRejectedValueOnce(new Error("Network error"));
6971
mockFetch.mockRejectedValueOnce(new Error("Network error"));
7072

71-
const metadata = await discoverOAuthMetadata("https://auth.example.com");
72-
expect(metadata).toBeUndefined();
73+
await expect(discoverOAuthMetadata("https://auth.example.com"))
74+
.rejects.toThrow("Network error");
7375
expect(mockFetch).toHaveBeenCalledTimes(2);
7476
});
7577

src/server/auth/handlers/register.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export function clientRegistrationHandler({
7575
}
7676

7777
const clientMetadata = parseResult.data;
78-
const isPublicClient = clientMetadata.token_endpoint_auth_method !== 'none'
78+
const isPublicClient = clientMetadata.token_endpoint_auth_method === 'none'
7979

8080
// Generate client credentials
8181
const clientId = crypto.randomUUID();
8282
const clientSecret = isPublicClient
83-
? crypto.randomBytes(32).toString('hex')
84-
: undefined;
83+
? undefined
84+
: crypto.randomBytes(32).toString('hex');
8585
const clientIdIssuedAt = Math.floor(Date.now() / 1000);
8686

8787
// Calculate client secret expiry time

0 commit comments

Comments
 (0)