返回 DeepSeek-Reasonix
mcp-oauth-eligibility.test.ts
根目录 / desktop / frontend / src / __tests__ / mcp-oauth-eligibility.test.ts
1 import { canUseNativeMCPOAuth } from "../lib/mcpOAuthEligibility";
2 import type { ServerView } from "../lib/types";
3
4 function server(overrides: Partial<ServerView>): ServerView {
5 return {
6 name: "server", transport: "http", status: "failed", configured: true,
7 autoStart: true, tools: 0, prompts: 0, resources: 0,
8 url: "https://mcp.example.test/mcp", ...overrides,
9 };
10 }
11
12 if (!canUseNativeMCPOAuth(server({}))) throw new Error("eligible Streamable HTTP server should offer OAuth");
13 if (canUseNativeMCPOAuth(server({ transport: "stdio", url: undefined }))) throw new Error("stdio must keep its retry path");
14 if (canUseNativeMCPOAuth(server({ transport: "sse" }))) throw new Error("legacy SSE must keep its retry path");
15 if (canUseNativeMCPOAuth(server({ authConfigured: true }))) throw new Error("static authentication must take precedence");
16 if (canUseNativeMCPOAuth(server({ url: "http://10.0.0.8/mcp" }))) throw new Error("remote HTTP must not offer OAuth");
17 if (!canUseNativeMCPOAuth(server({ url: "http://127.0.0.1:8787/mcp" }))) throw new Error("loopback HTTP should offer OAuth");
18 if (canUseNativeMCPOAuth(server({ url: "https://mcp.example.test/mcp?sig=abc" }))) throw new Error("signed URL must keep explicit auth");
19 if (canUseNativeMCPOAuth(server({ url: "https://user:pass@mcp.example.test/mcp" }))) throw new Error("URL userinfo must keep explicit auth");
20
20 lines TYPESCRIPT