From 7a2b05314a37d33f46415689e7adcac5f4ad5f78 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 13:24:59 +0000 Subject: [PATCH] test: speed up onboarding provider auth and temp-path guard scans --- .../onboard-non-interactive.provider-auth.test.ts | 13 ++++++++++++- src/security/temp-path-guard.test.ts | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/commands/onboard-non-interactive.provider-auth.test.ts b/src/commands/onboard-non-interactive.provider-auth.test.ts index bfd5e2e40a7..e98777c2d7c 100644 --- a/src/commands/onboard-non-interactive.provider-auth.test.ts +++ b/src/commands/onboard-non-interactive.provider-auth.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { setTimeout as delay } from "node:timers/promises"; -import { beforeAll, describe, expect, it } from "vitest"; +import { beforeAll, describe, expect, it, vi } from "vitest"; import { makeTempWorkspace } from "../test-helpers/workspace.js"; import { withEnvAsync } from "../test-utils/env.js"; import { MINIMAX_API_BASE_URL, MINIMAX_CN_API_BASE_URL } from "./onboard-auth.js"; @@ -17,6 +17,17 @@ type OnboardEnv = { configPath: string; runtime: NonInteractiveRuntime; }; + +const ensureWorkspaceAndSessionsMock = vi.fn(async (..._args: unknown[]) => {}); + +vi.mock("./onboard-helpers.js", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + ensureWorkspaceAndSessions: ensureWorkspaceAndSessionsMock, + }; +}); + let ensureAuthProfileStore: typeof import("../agents/auth-profiles.js").ensureAuthProfileStore; let upsertAuthProfile: typeof import("../agents/auth-profiles.js").upsertAuthProfile; diff --git a/src/security/temp-path-guard.test.ts b/src/security/temp-path-guard.test.ts index 8fa99feba2a..d5d2abb88f7 100644 --- a/src/security/temp-path-guard.test.ts +++ b/src/security/temp-path-guard.test.ts @@ -44,7 +44,14 @@ function isDynamicTemplateSegment(node: ts.Expression): boolean { return ts.isTemplateExpression(node); } +function mightContainDynamicTmpdirJoin(source: string): boolean { + return source.includes("path.join") && source.includes("os.tmpdir") && source.includes("`"); +} + function hasDynamicTmpdirJoin(source: string, filePath = "fixture.ts"): boolean { + if (!mightContainDynamicTmpdirJoin(source)) { + return false; + } const sourceFile = ts.createSourceFile( filePath, source, @@ -138,7 +145,7 @@ describe("temp path guard", () => { if (shouldSkip(relativePath)) { continue; } - const source = await fs.readFile(file, "utf-8"); + const source = await fs.readFile(file, "utf8"); if (hasDynamicTmpdirJoin(source, relativePath)) { offenders.push(relativePath); }