Files
simstudioai--sim/apps/sim/app/api/mcp/copilot/route.test.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

63 lines
2.3 KiB
TypeScript

/**
* Tests for the deprecated Copilot MCP route
*
* @vitest-environment node
*/
import { NextRequest } from 'next/server'
import { describe, expect, it } from 'vitest'
import { GET as authServerDiscoveryGET } from '@/app/api/mcp/copilot/.well-known/oauth-authorization-server/route'
import { GET as protectedResourceDiscoveryGET } from '@/app/api/mcp/copilot/.well-known/oauth-protected-resource/route'
import { DELETE, GET, POST } from '@/app/api/mcp/copilot/route'
const URL = 'http://localhost:3000/api/mcp/copilot'
describe('Deprecated Copilot MCP route', () => {
it('GET returns 410', async () => {
const response = await GET(new NextRequest(URL))
expect(response.status).toBe(410)
})
it('POST returns 410 with a JSON-RPC error envelope', async () => {
const request = new NextRequest(URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize' }),
})
const response = await POST(request)
expect(response.status).toBe(410)
const body = (await response.json()) as { jsonrpc?: string; error?: { message?: string } }
expect(body.jsonrpc).toBe('2.0')
expect(body.error?.message).toContain('deprecated')
})
it('POST still returns 410 when an x-api-key header is present', async () => {
const request = new NextRequest(URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'sk-sim-copilot-test' },
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' }),
})
const response = await POST(request)
expect(response.status).toBe(410)
})
it('DELETE returns 410', async () => {
const response = await DELETE(new NextRequest(URL, { method: 'DELETE' }))
expect(response.status).toBe(410)
})
it('copilot OAuth authorization-server discovery returns 410', async () => {
const response = await authServerDiscoveryGET(
new NextRequest(`${URL}/.well-known/oauth-authorization-server`)
)
expect(response.status).toBe(410)
})
it('copilot OAuth protected-resource discovery returns 410', async () => {
const response = await protectedResourceDiscoveryGET(
new NextRequest(`${URL}/.well-known/oauth-protected-resource`)
)
expect(response.status).toBe(410)
})
})