test(mcp): add tests for OAuth 2.1, addon gating, and budget reorder

Covers OAuth integration flow, scope enforcement, addon-gated tool access,
oauthService unit tests, and budget reorder/permission/reservation-sync scenarios.
This commit is contained in:
jubnl
2026-04-09 23:12:48 +02:00
parent 830f6c0706
commit f2908fdd65
8 changed files with 2494 additions and 4 deletions
+6 -2
View File
@@ -28,15 +28,19 @@ export interface McpHarnessOptions {
withResources?: boolean;
/** Register read-write tools (default: true) */
withTools?: boolean;
/** OAuth scopes to restrict tools; null = full access (default: null) */
scopes?: string[] | null;
/** Whether the session is authenticated via a static API token (default: false) */
isStaticToken?: boolean;
}
export async function createMcpHarness(options: McpHarnessOptions): Promise<McpHarness> {
const { userId, withResources = true, withTools = true } = options;
const { userId, withResources = true, withTools = true, scopes = null, isStaticToken = false } = options;
const server = new McpServer({ name: 'trek-test', version: '1.0.0' });
if (withResources) registerResources(server, userId);
if (withTools) registerTools(server, userId);
if (withTools) registerTools(server, userId, scopes ?? null, isStaticToken);
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();