Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tests/cli/cli-access-audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,15 @@ describe("bounded regular audio files", () => {
expect(value.size).toBe(25_000_000); expect(value.name).toBe("audio.wav");
});
test("directory and device are refused", async () => {
for (const path of [root, "/dev/null"]) {
expect(await handleAccessAudioCommand(args(path), deps())).toBe(2);
}
expect(await handleAccessAudioCommand(args(root), deps())).toBe(2);
// POSIX stats /dev/null as a character device (usage refusal). Windows has no /dev; its NUL
// device may not stat at all, which is a read failure. Either way nothing is read or sent.
let requests = 0;
const device = process.platform === "win32" ? "NUL" : "/dev/null";
const code = await handleAccessAudioCommand(args(device), deps({ fetchImpl: fetcher(() => { requests++; return Response.json({ text: "" }); }) }));
if (process.platform === "win32") expect([1, 2]).toContain(code);
else expect(code).toBe(2);
expect(requests).toBe(0);
});
test("growing file is bounded by actual reads, not the stale stat", async () => {
expect(await handleAccessAudioCommand(args(), deps({ audioOpen: async (path, flags) => {
Expand Down
5 changes: 4 additions & 1 deletion tests/cli/cli-account-login-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { handleAccountAuthCommand } from "../../src/cli/account-auth";
import type { RuntimeApiDeps } from "../../src/cli/runtime-api";
import { createTempHome, type TempHome } from "../helpers/temp-home";
import { repoPath } from "../helpers/repo-root";
import { pathToFileURL } from "node:url";

const SECRET = "synthetic-private-value";
let home: TempHome;
Expand Down Expand Up @@ -172,7 +174,8 @@ describe("login terminal and code boundaries", () => {
});
test("human instructions preserve intended lines but escape terminal controls", async () => {
mkdirSync(home.codexHome, { recursive: true });
const source = new URL("../../src/cli/account-auth.ts", import.meta.url).pathname;
// A file URL imports on every platform; a URL pathname is "/D:/..." on Windows.
const source = pathToFileURL(repoPath("src", "cli", "account-auth.ts")).href;
const script = `import {handleAccountAuthCommand} from ${JSON.stringify(source)};
globalThis.fetch = async () => { throw new Error('Network forbidden'); };
const result = await handleAccountAuthCommand('login', ['openai','--no-wait'], {
Expand Down
Loading