diff --git a/src/services/mcp/utils/__tests__/oauth.spec.ts b/src/services/mcp/utils/__tests__/oauth.spec.ts index e2242c8ef8..b276f60fd4 100644 --- a/src/services/mcp/utils/__tests__/oauth.spec.ts +++ b/src/services/mcp/utils/__tests__/oauth.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach } from "vitest" +import { describe, it, expect, vi, beforeEach, afterAll } from "vitest" // Mock the SDK's discoverOAuthProtectedResourceMetadata vi.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({ @@ -9,6 +9,7 @@ import { discoverOAuthProtectedResourceMetadata } from "@modelcontextprotocol/sd import { fetchOAuthAuthServerMetadata } from "../oauth" const mockFetch = vi.fn() +const originalFetch = global.fetch global.fetch = mockFetch describe("fetchOAuthAuthServerMetadata", () => { @@ -16,6 +17,10 @@ describe("fetchOAuthAuthServerMetadata", () => { vi.clearAllMocks() }) + afterAll(() => { + global.fetch = originalFetch + }) + it("returns null when resource metadata has no authorization_servers", async () => { ;(discoverOAuthProtectedResourceMetadata as any).mockResolvedValue({ resource: "https://example.com/",