mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
perf(test): seed MCP Doctor fixtures without config mutations (#129498)
This commit is contained in:
committed by
GitHub
parent
e06e804955
commit
03edb00a1c
+46
-33
@@ -21,6 +21,17 @@ import {
|
||||
import { writeProbeMcpServer } from "./mcp-cli.test-support.js";
|
||||
import { runCliWithExitFinalization } from "./one-shot-exit.js";
|
||||
|
||||
async function writeMcpDoctorServers(
|
||||
home: string,
|
||||
servers: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
await fs.writeFile(
|
||||
path.join(home, ".openclaw", "openclaw.json"),
|
||||
`${JSON.stringify({ mcp: { servers } })}\n`,
|
||||
"utf8",
|
||||
);
|
||||
}
|
||||
|
||||
describe("mcp cli", () => {
|
||||
beforeEach(() => {
|
||||
resetMcpCliTestState();
|
||||
@@ -609,30 +620,31 @@ describe("mcp cli", () => {
|
||||
});
|
||||
|
||||
it("reports ignored OAuth Authorization headers regardless of casing", async () => {
|
||||
await withTempHome("openclaw-cli-mcp-home-", async () => {
|
||||
await withTempHome("openclaw-cli-mcp-home-", async (home) => {
|
||||
const workspaceDir = await createWorkspace();
|
||||
vi.spyOn(process, "cwd").mockReturnValue(workspaceDir);
|
||||
readMcpOAuthCredentialsStatus.mockResolvedValue({ state: "authorized" });
|
||||
|
||||
for (const { name, header, oauth } of [
|
||||
{ name: "lowercase", header: "authorization", oauth: true },
|
||||
{ name: "titlecase", header: "Authorization", oauth: true },
|
||||
{ name: "uppercase", header: "AUTHORIZATION", oauth: true },
|
||||
{ name: "proxy", header: "Proxy-Authorization", oauth: true },
|
||||
{ name: "unrelated", header: "X-Tenant", oauth: true },
|
||||
{ name: "without-oauth", header: "AUTHORIZATION", oauth: false },
|
||||
]) {
|
||||
await runMcpCommand([
|
||||
"mcp",
|
||||
"set",
|
||||
name,
|
||||
JSON.stringify({
|
||||
url: "https://mcp.example.com/mcp",
|
||||
headers: { [header]: "$MCP_HEADER" },
|
||||
...(oauth ? { auth: "oauth" } : {}),
|
||||
}),
|
||||
]);
|
||||
}
|
||||
await writeMcpDoctorServers(
|
||||
home,
|
||||
Object.fromEntries(
|
||||
[
|
||||
{ name: "lowercase", header: "authorization", oauth: true },
|
||||
{ name: "titlecase", header: "Authorization", oauth: true },
|
||||
{ name: "uppercase", header: "AUTHORIZATION", oauth: true },
|
||||
{ name: "proxy", header: "Proxy-Authorization", oauth: true },
|
||||
{ name: "unrelated", header: "X-Tenant", oauth: true },
|
||||
{ name: "without-oauth", header: "AUTHORIZATION", oauth: false },
|
||||
].map(({ name, header, oauth }) => [
|
||||
name,
|
||||
{
|
||||
url: "https://mcp.example.com/mcp",
|
||||
headers: { [header]: "$MCP_HEADER" },
|
||||
...(oauth ? { auth: "oauth" } : {}),
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
mockLog.mockClear();
|
||||
|
||||
await runMcpCommand(["mcp", "doctor", "--json"]);
|
||||
@@ -662,21 +674,22 @@ describe("mcp cli", () => {
|
||||
});
|
||||
|
||||
it("bounds concurrent MCP doctor server checks", async () => {
|
||||
await withTempHome("openclaw-cli-mcp-home-", async () => {
|
||||
await withTempHome("openclaw-cli-mcp-home-", async (home) => {
|
||||
const workspaceDir = await createWorkspace();
|
||||
vi.spyOn(process, "cwd").mockReturnValue(workspaceDir);
|
||||
for (let index = 0; index < 6; index += 1) {
|
||||
await runMcpCommand([
|
||||
"mcp",
|
||||
"set",
|
||||
`server-${index}`,
|
||||
JSON.stringify({
|
||||
url: `https://mcp-${index}.example.com`,
|
||||
transport: "streamable-http",
|
||||
auth: "oauth",
|
||||
}),
|
||||
]);
|
||||
}
|
||||
await writeMcpDoctorServers(
|
||||
home,
|
||||
Object.fromEntries(
|
||||
Array.from({ length: 6 }, (_, index) => [
|
||||
`server-${index}`,
|
||||
{
|
||||
url: `https://mcp-${index}.example.com`,
|
||||
transport: "streamable-http",
|
||||
auth: "oauth",
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
const checksBlocked = createDeferred();
|
||||
readMcpOAuthCredentialsStatus.mockImplementation(async () => {
|
||||
|
||||
Reference in New Issue
Block a user