mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Every role-local MCP spec gates itself on the service flag and skips when the surface is off, so nothing ever checked that switching it off removes it. A surface still serving after the flag went false was indistinguishable from one that was never deployed: both read as a green skip. The gating helper had no inverse at all, so there was no way to assert what a disabled service must not do. A shared assertion now probes the endpoint with both a GET and a POST while the flag is false and fails on any answer that shows something listening. It counts 401 and 403 as listening, which is the point: a refused credential still means the surface is there. The check is transport-agnostic because the roles differ in their enabled-state probes, over SSE, Streamable HTTP or plain JSON-RPC, while an endpoint that is gone answers none of them. Each role passes its endpoint URL as a thunk, since some resolve it only once a test is running. The coverage lint requires the registration, and derives the role set from meta/mcp.yml rather than from a filename convention, which is how the tenth role surfaced: its spec is not named like the other nine. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
const { test, expect } = require("@playwright/test");
|
|
const { skipUnlessServiceEnabled } = require("./service-gating");
|
|
const { normalizeBaseUrl } = require("./personas");
|
|
const { registerMcpDisabledState } = require("./mcp-endpoint");
|
|
|
|
const UNKNOWN_ENDPOINT_KEY = "0".repeat(32);
|
|
|
|
test.use({ ignoreHTTPSErrors: true });
|
|
|
|
test("mcp: an unauthenticated probe of the MCP endpoint is rejected", async ({ page }) => {
|
|
skipUnlessServiceEnabled("mcp");
|
|
|
|
const baseUrl = normalizeBaseUrl(process.env.BASEROW_BASE_URL || "");
|
|
expect(baseUrl, "BASEROW_BASE_URL must be set").toBeTruthy();
|
|
|
|
const response = await page.request.get(`${baseUrl}/mcp/${UNKNOWN_ENDPOINT_KEY}/sse`, {
|
|
failOnStatusCode: false,
|
|
});
|
|
|
|
expect(
|
|
response.headers()["content-type"] || "",
|
|
"a probe carrying no valid endpoint key must never be upgraded to the MCP stream",
|
|
).not.toContain("text/event-stream");
|
|
expect(
|
|
await response.text(),
|
|
"a probe carrying no valid endpoint key must never receive an MCP session endpoint",
|
|
).not.toContain("event: endpoint");
|
|
});
|
|
|
|
registerMcpDisabledState(
|
|
() =>
|
|
`${normalizeBaseUrl(process.env.BASEROW_BASE_URL || "")}/mcp/${UNKNOWN_ENDPOINT_KEY}/sse`,
|
|
);
|