15 lines
943 B
TypeScript
15 lines
943 B
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { resolve } from "node:path";
|
|
import { expect, it } from "vitest";
|
|
|
|
it("rejects a TTY before reading credentials and directs the operator to a controlled pipe", () => {
|
|
const script = resolve(import.meta.dirname, "../../../scripts/probe-image-video-mcp.mjs");
|
|
// Instrument only the process boundary; do not provide a token or allow a network call.
|
|
const source = `Object.defineProperty(process.stdin,'isTTY',{value:true}); const fakeRead=()=>{throw new Error('UNSAFE_STDIN_READ');}; process.stdin.on=fakeRead; await import(${JSON.stringify(script)});`;
|
|
const result = spawnSync(process.execPath, ["--input-type=module", "-e", source], { encoding: "utf8", timeout: 5000 });
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain("controlled pipe");
|
|
expect(result.stderr).not.toContain("UNSAFE_STDIN_READ");
|
|
expect(result.stdout).not.toContain("hidden stdin");
|
|
});
|