From 22a0981fe02d615bdcf230abc9ac85ca1e0f4c8b Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 15 Nov 2026 08:19:07 -0500 Subject: [PATCH] test(mcp): build the JWT-shaped test value instead of writing it (#202) The refused Authorization values of the route test held a literal in three base64url parts starting with `eyJ`: a made-up value, but one a secret scanner reads as a token. It is now built by the test. No assertion changes. Co-Authored-By: Claude Fable 5.2 --- web/src/app/api/mcp/route.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/app/api/mcp/route.test.ts b/web/src/app/api/mcp/route.test.ts index 245b071..a3c90fe 100644 --- a/web/src/app/api/mcp/route.test.ts +++ b/web/src/app/api/mcp/route.test.ts @@ -458,6 +458,10 @@ afterAll(() => pilot(initialPilot)); describe('authentication', () => { const WELL_FORMED = `slmcp_${'A'.repeat(43)}`; + // Three base64url parts, built here so that the file holds no token-shaped literal. + const JWT_SHAPED = [JSON.stringify({ alg: 'none' }), JSON.stringify({ sub: 'nobody' }), 'signature'] + .map((part) => Buffer.from(part, 'utf8').toString('base64url')) + .join('.'); it.each([ ['no Authorization header', null], @@ -470,7 +474,7 @@ describe('authentication', () => { ['a token under a lowercase scheme', `bearer ${WELL_FORMED}`], ['a well-formed token that was never issued', `Bearer ${WELL_FORMED}`], ['a Logto access token', 'Bearer logto-access-token-of-the-test'], - ['a token that looks like a JWT', 'Bearer eyJhbGciOiJFUzM4NCJ9.eyJzdWIiOiJ4In0.c2lnbmF0dXJl'], + ['a token that looks like a JWT', `Bearer ${JWT_SHAPED}`], ])('answers 401 to %s, with a Bearer challenge and no redirect', async (_label, authorization) => { const outbound = vi.spyOn(globalThis, 'fetch'); for (const era of ERAS) {