From e29abb2606607107f4769a404527b66a0bcf108b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 23 Apr 2026 05:01:22 +0100 Subject: [PATCH] test: slim live auth staging --- test/test-env.test.ts | 15 +++++++++++++++ test/test-env.ts | 20 ++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/test/test-env.test.ts b/test/test-env.test.ts index e7e0df43000..8595659c766 100644 --- a/test/test-env.test.ts +++ b/test/test-env.test.ts @@ -97,6 +97,14 @@ describe("installTestEnv", () => { JSON.stringify({ version: 1, profiles: { default: { provider: "openai" } } }, null, 2), ); writeFile(path.join(realHome, ".claude", ".credentials.json"), '{"accessToken":"token"}\n'); + writeFile(path.join(realHome, ".claude", "projects", "old-session.jsonl"), "session\n"); + fs.mkdirSync(path.join(realHome, ".claude", "settings.local.json"), { recursive: true }); + writeFile(path.join(realHome, ".codex", "auth.json"), '{"OPENAI_API_KEY":"token"}\n'); + writeFile(path.join(realHome, ".codex", "config.toml"), 'model = "gpt-5.4"\n'); + writeFile( + path.join(realHome, ".codex", "sessions", "2026", "02", "26", "rollout.jsonl"), + "session\n", + ); process.env.HOME = realHome; process.env.USERPROFILE = realHome; @@ -164,6 +172,13 @@ describe("installTestEnv", () => { ), ).toBe(true); expect(fs.existsSync(path.join(testEnv.tempHome, ".claude", ".credentials.json"))).toBe(true); + expect(fs.existsSync(path.join(testEnv.tempHome, ".claude", "projects"))).toBe(false); + expect(fs.existsSync(path.join(testEnv.tempHome, ".claude", "settings.local.json"))).toBe( + false, + ); + expect(fs.existsSync(path.join(testEnv.tempHome, ".codex", "auth.json"))).toBe(true); + expect(fs.existsSync(path.join(testEnv.tempHome, ".codex", "config.toml"))).toBe(true); + expect(fs.existsSync(path.join(testEnv.tempHome, ".codex", "sessions"))).toBe(false); }); it("allows explicit live runs against the real HOME", () => { diff --git a/test/test-env.ts b/test/test-env.ts index adc49380c1f..31818965fd7 100644 --- a/test/test-env.ts +++ b/test/test-env.ts @@ -7,8 +7,15 @@ import JSON5 from "json5"; type RestoreEntry = { key: string; value: string | undefined }; -const LIVE_EXTERNAL_AUTH_DIRS = [".claude", ".codex", ".gemini", ".minimax"] as const; -const LIVE_EXTERNAL_AUTH_FILES = [".claude.json"] as const; +const LIVE_EXTERNAL_AUTH_DIRS = [".claude/backups", ".gemini", ".minimax"] as const; +const LIVE_EXTERNAL_AUTH_FILES = [ + ".claude.json", + ".claude/.credentials.json", + ".claude/settings.json", + ".claude/settings.local.json", + ".codex/auth.json", + ".codex/config.toml", +] as const; const requireFromHere = createRequire(import.meta.url); type LegacyConfigCompatApi = @@ -259,6 +266,15 @@ function copyFileIfExists(sourcePath: string, targetPath: string): void { if (!fs.existsSync(sourcePath)) { return; } + let stat: fs.Stats; + try { + stat = fs.statSync(sourcePath); + } catch { + return; + } + if (!stat.isFile()) { + return; + } ensureParentDir(targetPath); fs.copyFileSync(sourcePath, targetPath); }