From dab4e2cece5b2f7249a0ed7e936ff22c43b09b11 Mon Sep 17 00:00:00 2001 From: Elliott de Launay Date: Fri, 24 Apr 2026 09:52:50 -0400 Subject: [PATCH] test(oauth): restoring mocked global --- src/services/mcp/utils/__tests__/oauth.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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/",