Files
wehub-resource-sync fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:28:29 +08:00

51 lines
1.6 KiB
TypeScript

/**
* Spawn/stop the mock OIDC IdP (scripts/e2e/mock_oidc_idp.py) for oidc specs.
*/
import { spawn } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const MOCK_OIDC_PORT = Number(process.env.MOCK_OIDC_PORT ?? 7999);
export const MOCK_OIDC_ISSUER = `http://127.0.0.1:${MOCK_OIDC_PORT}`;
/**
* Start the mock IdP as a child process and wait for `/healthz`. The backend
* must have been booted with `AUTH_TYPE=oidc` (see scripts/e2e/env.sh for the
* matching OIDC_* defaults). Returns a `stop()` that SIGTERMs the child.
*/
export async function startMockIdp(): Promise<{ stop: () => void }> {
const repoRoot = path.resolve(
fileURLToPath(new URL('../../..', import.meta.url)),
);
const python =
process.env.E2E_PYTHON ?? path.join(repoRoot, '.venv', 'bin', 'python');
const child = spawn(
python,
[path.join(repoRoot, 'scripts', 'e2e', 'mock_oidc_idp.py')],
{
env: { ...process.env, MOCK_OIDC_PORT: String(MOCK_OIDC_PORT) },
// stderr passes through so PKCE/code failures show up in test output.
stdio: ['ignore', 'ignore', 'inherit'],
},
);
const stop = () => {
if (!child.killed) child.kill('SIGTERM');
};
const deadline = Date.now() + 15_000;
while (Date.now() < deadline) {
try {
const res = await fetch(`${MOCK_OIDC_ISSUER}/healthz`);
if (res.ok) return { stop };
} catch {
// not listening yet
}
await new Promise((resolve) => setTimeout(resolve, 250));
}
stop();
throw new Error(
`mock OIDC IdP did not become healthy on ${MOCK_OIDC_ISSUER} within 15s`,
);
}