From a5c5483b65a738f806011d9dbc99fa41138ec454 Mon Sep 17 00:00:00 2001 From: Michael D'Angelo Date: Thu, 13 Aug 2026 17:16:02 -0700 Subject: [PATCH] test: remove duplicate launcher and runtime coverage --- sdk/typescript/tests-ts/cli-launcher.test.ts | 1 + sdk/typescript/tests-ts/cli.test.ts | 96 +------------------- sdk/typescript/tests-ts/runtime.test.ts | 27 ------ 3 files changed, 2 insertions(+), 122 deletions(-) diff --git a/sdk/typescript/tests-ts/cli-launcher.test.ts b/sdk/typescript/tests-ts/cli-launcher.test.ts index 92a0e777..2f1bde3e 100644 --- a/sdk/typescript/tests-ts/cli-launcher.test.ts +++ b/sdk/typescript/tests-ts/cli-launcher.test.ts @@ -111,6 +111,7 @@ describe("CLI launcher", () => { ); expect(build.error).toBeUndefined(); expect(build.status).toBe(0); + expect(build.stderr).toBe(""); expect(await readFile(join(dist, "cli.js"), "utf8")).toContain( 'from "./api.js"', diff --git a/sdk/typescript/tests-ts/cli.test.ts b/sdk/typescript/tests-ts/cli.test.ts index 09eb2157..0389d2a5 100644 --- a/sdk/typescript/tests-ts/cli.test.ts +++ b/sdk/typescript/tests-ts/cli.test.ts @@ -1,19 +1,17 @@ import { execFileSync, spawnSync } from "node:child_process"; import { - copyFile, mkdir, mkdtemp, readFile, realpath, rm, stat, - symlink, writeFile, } from "node:fs/promises"; import { tmpdir } from "node:os"; import { delimiter, join, normalize } from "node:path"; import { Writable } from "node:stream"; -import { fileURLToPath, pathToFileURL } from "node:url"; +import { fileURLToPath } from "node:url"; import { stripVTControlCharacters } from "node:util"; import { describe, expect, test } from "bun:test"; import { parse as parseToml } from "smol-toml"; @@ -1853,98 +1851,6 @@ describe("CLI", () => { expect(stderr.text()).toBe(""); }); - test("runs split TypeScript output from an npm-style bin when Node preserves main symlinks", async () => { - const root = await mkdtemp(join(tmpdir(), "codex-security-cli-node-bin-")); - try { - const source = join(import.meta.dir, ".."); - const installed = join(root, "node_modules", "@openai", "codex-security"); - const dist = join(installed, "dist"); - const build = spawnSync( - "node", - [ - join(source, "node_modules", "typescript", "bin", "tsc"), - "-p", - join(source, "tsconfig.build.json"), - "--outDir", - dist, - "--pretty", - "false", - ], - { encoding: "utf8", cwd: source }, - ); - expect(build.status).toBe(0); - expect(build.stderr).toBe(""); - expect(await readFile(join(dist, "cli.js"), "utf8")).toContain( - 'from "./api.js"', - ); - const launcher = join(installed, "bin", "codex-security.mjs"); - await mkdir(join(installed, "bin"), { recursive: true }); - await copyFile(join(source, "bin", "codex-security.mjs"), launcher); - await copyFile( - join(source, "package.json"), - join(installed, "package.json"), - ); - await symlink( - join(source, "node_modules"), - join(installed, "node_modules"), - "dir", - ); - const binDirectory = join(root, "node_modules", ".bin"); - await mkdir(binDirectory, { recursive: true }); - const bin = join(binDirectory, "codex-security"); - await symlink(launcher, bin); - const child = spawnSync("node", [bin, "--version"], { - encoding: "utf8", - env: { - ...process.env, - NODE_OPTIONS: - "--preserve-symlinks-main --no-experimental-detect-module", - NODE_USE_ENV_PROXY: undefined, - }, - }); - expect(child.status).toBe(0); - expect(child.stderr).toBe(""); - expect(child.stdout).toBe(`${VERSION}\n`); - - const preload = join(root, "unavailable-cwd.mjs"); - await writeFile( - preload, - [ - "const originalCwd = process.cwd;", - 'Object.defineProperty(process, "cwd", {', - " value() {", - ' if (/[\\\\/]dist[\\\\/]cli\\.js:/u.test(new Error().stack ?? "")) {', - ' throw new Error("working directory is unavailable");', - " }", - " return originalCwd.call(process);", - " },", - "});\n", - ].join("\n"), - ); - const failed = spawnSync( - "node", - ["--import", pathToFileURL(preload).href, bin, "scan"], - { - encoding: "utf8", - env: { - ...process.env, - NODE_OPTIONS: - "--preserve-symlinks-main --no-experimental-detect-module", - NODE_USE_ENV_PROXY: undefined, - }, - timeout: 30_000, - }, - ); - expect([failed.status, failed.stdout, failed.stderr]).toEqual([ - 2, - "", - "working directory is unavailable\n", - ]); - } finally { - await rm(root, { recursive: true, force: true }); - } - }, 30_000); - test("uses Incur version and command help", async () => { const version = capture(); const stderr = capture(); diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.ts index cd58449d..4aed2ca7 100644 --- a/sdk/typescript/tests-ts/runtime.test.ts +++ b/sdk/typescript/tests-ts/runtime.test.ts @@ -1890,33 +1890,6 @@ describe("runtime directories and plugin Python boundary", () => { }, ); - testPosix("rejects sticky shared parents controlled by another user", () => { - expect(() => - requireTrustedOutputAncestor( - { mode: 0o41777, uid: 1001 }, - "/shared", - 1000, - ), - ).toThrow("trusted owner"); - expect(() => - requireTrustedOutputAncestor( - { mode: 0o40755, uid: 1001 }, - "/shared", - 1000, - ), - ).toThrow("trusted owner"); - expect(() => - requireTrustedOutputAncestor( - { mode: 0o41777, uid: 1000 }, - "/shared", - 1000, - ), - ).not.toThrow(); - expect(() => - requireTrustedOutputAncestor({ mode: 0o41777, uid: 0 }, "/tmp", 1000), - ).not.toThrow(); - }); - testPosix( "rejects a credential home that is no longer private to the current user", async () => {