test: trim auth and skill install setup

This commit is contained in:
Peter Steinberger
2026-04-18 20:34:40 +01:00
parent cd783b9946
commit 0c245c35c5
2 changed files with 21 additions and 11 deletions

View File

@@ -109,8 +109,10 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
]);
let tempRoot = "";
let agentDir = "";
let caseIndex = 0;
beforeAll(async () => {
tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-refresh-fallback-"));
({ resolveApiKeyForProfile } = await import("./oauth.js"));
});
@@ -131,10 +133,10 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
buildProviderAuthDoctorHintWithPluginMock.mockReset();
buildProviderAuthDoctorHintWithPluginMock.mockResolvedValue(undefined);
clearRuntimeAuthProfileStoreSnapshots();
tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-refresh-fallback-"));
agentDir = path.join(tempRoot, "agents", "main", "agent");
const caseRoot = path.join(tempRoot, `case-${++caseIndex}`);
agentDir = path.join(caseRoot, "agents", "main", "agent");
await fs.mkdir(agentDir, { recursive: true });
process.env.OPENCLAW_STATE_DIR = tempRoot;
process.env.OPENCLAW_STATE_DIR = caseRoot;
process.env.OPENCLAW_AGENT_DIR = agentDir;
process.env.PI_CODING_AGENT_DIR = agentDir;
});
@@ -143,6 +145,9 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
resetFileLockStateForTest();
clearRuntimeAuthProfileStoreSnapshots();
envSnapshot.restore();
});
afterAll(async () => {
await fs.rm(tempRoot, { recursive: true, force: true });
});

View File

@@ -202,22 +202,27 @@ describe("installDownloadSpec extraction safety", () => {
});
it("allows relative targetDir inside the per-skill tools root", async () => {
mockArchiveResponse(new Uint8Array(SAFE_ZIP_BUFFER));
mockArchiveResponse(new TextEncoder().encode("payload"));
const entry = buildEntry("relative-targetdir");
const result = await installDownloadSkill({
name: "relative-targetdir",
url: "https://example.invalid/good.zip",
archive: "zip",
targetDir: "runtime",
const result = await installDownloadSpec({
entry,
spec: {
kind: "download",
id: "dl",
url: "https://example.invalid/payload.bin",
extract: false,
targetDir: "runtime",
},
timeoutMs: 30_000,
});
expect(result.ok).toBe(true);
expect(
await fs.readFile(
path.join(resolveSkillToolsRootDir(entry), "runtime", "hello.txt"),
path.join(resolveSkillToolsRootDir(entry), "runtime", "payload.bin"),
"utf-8",
),
).toBe("hi");
).toBe("payload");
});
it.runIf(process.platform !== "win32")(