Fixing tests
This commit is contained in:
parent
26b47438c6
commit
885590c099
2 changed files with 9 additions and 7 deletions
|
|
@ -60,16 +60,18 @@ describe("OAuth Authorization", () => {
|
|||
// Verify second call was made without header
|
||||
expect(mockFetch).toHaveBeenCalledTimes(2);
|
||||
const secondCallOptions = mockFetch.mock.calls[1][1];
|
||||
expect(secondCallOptions).toBeUndefined(); // No options means no headers
|
||||
// The second call still has options but doesn't include MCP-Protocol-Version header
|
||||
expect(secondCallOptions).toBeDefined();
|
||||
expect(secondCallOptions?.headers).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined when all fetch attempts fail", async () => {
|
||||
it("throws an error when all fetch attempts fail", async () => {
|
||||
// Both requests fail
|
||||
mockFetch.mockRejectedValueOnce(new Error("Network error"));
|
||||
mockFetch.mockRejectedValueOnce(new Error("Network error"));
|
||||
|
||||
const metadata = await discoverOAuthMetadata("https://auth.example.com");
|
||||
expect(metadata).toBeUndefined();
|
||||
await expect(discoverOAuthMetadata("https://auth.example.com"))
|
||||
.rejects.toThrow("Network error");
|
||||
expect(mockFetch).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -75,13 +75,13 @@ export function clientRegistrationHandler({
|
|||
}
|
||||
|
||||
const clientMetadata = parseResult.data;
|
||||
const isPublicClient = clientMetadata.token_endpoint_auth_method !== 'none'
|
||||
const isPublicClient = clientMetadata.token_endpoint_auth_method === 'none'
|
||||
|
||||
// Generate client credentials
|
||||
const clientId = crypto.randomUUID();
|
||||
const clientSecret = isPublicClient
|
||||
? crypto.randomBytes(32).toString('hex')
|
||||
: undefined;
|
||||
? undefined
|
||||
: crypto.randomBytes(32).toString('hex');
|
||||
const clientIdIssuedAt = Math.floor(Date.now() / 1000);
|
||||
|
||||
// Calculate client secret expiry time
|
||||
|
|
|
|||
Loading…
Reference in a new issue