fix: retry next endpoint on CORS error during auth server discovery (#827)

This commit is contained in:
Xiao Yijun 2025-08-04 22:43:09 +08:00 • committed by GitHub
commit f657ead472
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -899,6 +899,18 @@ describe("OAuth Authorization", () => {
"MCP-Protocol-Version": "2025-01-01"
});
});
it("returns undefined when all URLs fail with CORS errors", async () => {
// All fetch attempts fail with CORS errors (TypeError)
mockFetch.mockImplementation(() => Promise.reject(new TypeError("CORS error")));
const metadata = await discoverAuthorizationServerMetadata("https://auth.example.com/tenant1");
expect(metadata).toBeUndefined();
// Verify that all discovery URLs were attempted
expect(mockFetch).toHaveBeenCalledTimes(8); // 4 URLs × 2 attempts each (with and without headers)
});
});
describe("startAuthorization", () => {