Files
insights/services/mcp/tests/integration/mcp-protocol.cf.integration.test.ts
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

43 lines
1.5 KiB
TypeScript

import { afterAll, beforeAll } from 'vitest'
import { startCfHarness } from './harness/cf'
import { loadIntegrationEnv, type IntegrationEnv, type IntegrationHarness } from './harness/types'
import { defineAuthTests, type ProtocolTestHarness } from './mcp-protocol-suite'
// Auth-boundary test against the Cloudflare Workers entry point.
// - Real workerd via `wrangler unstable_dev`
// - Real Insights stack at `TEST_INSIGHTS_API_BASE_URL` (defaults to localhost:8010)
// - Real personal API key from `TEST_INSIGHTS_PERSONAL_API_KEY`
//
// Boot the local Insights stack with `./bin/start` before running this suite.
//
// The worker proxies all `/mcp` traffic to the Hono runtime — protocol,
// resilience, resource-catalog and tool-behavior suites run against the runtime
// that actually serves them in `mcp-protocol.hono.integration.test.ts`. Only the
// bearer-token gate still lives in the worker, so that's all this file asserts
// (every `defineAuthTests` case is a 401 that fires before any proxying).
let env: IntegrationEnv
let harness: IntegrationHarness
beforeAll(async () => {
env = loadIntegrationEnv()
harness = await startCfHarness(env)
}, 60_000)
afterAll(async () => {
await harness?.stop()
})
const harnessFor = (): ProtocolTestHarness => ({
baseUrl: harness.baseUrl,
fetch: globalThis.fetch,
token: env.apiToken,
token2: env.apiToken2,
orgId: env.orgId,
projectId: env.projectId,
publicRoutes: false,
})
defineAuthTests('Cloudflare Workers (real stack)', harnessFor)