import { describe, expect, it } from "vitest"; import { fields, resourceMetadata, shown, syntheticNumber } from "../mcp-walk.ts"; describe("the MCP walk's readers", () => { it("reads the authorize page's hidden fields", () => { expect(fields('')).toEqual({ state: "a&b", step: "phone" }); }); it("finds the resource metadata a 401 names", () => { expect(resourceMetadata('Bearer resource_metadata="https://x.test/.well-known/oauth-protected-resource/mcp", scope="owner"')).toBe("https://x.test/.well-known/oauth-protected-resource/mcp"); expect(resourceMetadata(null)).toBeNull(); }); it("never shows a secret, only what it names", () => { const id = "11111111-1111-4111-8111-111111111111"; expect(shown(`ctn_${id}_s3cr3t`)).toBe(`ctn_${id}_…`); expect(shown("s3cr3t-code")).toBe("s3cr…"); }); it("makes numbers in its own synthetic range", () => { expect(syntheticNumber()).toMatch(/^\+9190009\d{5}$/); }); });