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) {