mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 06:31:11 +00:00
test: slim live auth staging
This commit is contained in:
parent
f3c60e9c0d
commit
e29abb2606
2 changed files with 33 additions and 2 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue