27 lines
827 B
TypeScript
27 lines
827 B
TypeScript
import { readFileSync } from 'node:fs';
|
|
export interface Fixture {
|
|
origin: string;
|
|
upstream: string;
|
|
password: string;
|
|
adminToken: string;
|
|
aliceToken: string;
|
|
bobToken: string;
|
|
scopedToken: string;
|
|
readToken: string;
|
|
repoId: number;
|
|
bobRepoId: number;
|
|
orgRepoId: number;
|
|
teamId: number;
|
|
env: Record<string, string>;
|
|
path: string;
|
|
project?: string;
|
|
}
|
|
export function readFixture(): Fixture {
|
|
if (!process.env.MCP_FIXTURE_PATH)
|
|
throw new Error('Run through test:integration; no fixture was provided.');
|
|
const fixture = JSON.parse(readFileSync(process.env.MCP_FIXTURE_PATH, 'utf8')) as Fixture;
|
|
for (const value of [fixture.origin, fixture.upstream])
|
|
if (new URL(value).hostname !== '127.0.0.1')
|
|
throw new Error('Refusing a non-loopback integration target.');
|
|
return fixture;
|
|
}
|