From 96ef00ec3894a0ad9202b9a9e78fb12a58ee071e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 21 Feb 2026 18:53:42 +0000 Subject: [PATCH] refactor(test): drop redundant env snapshots in skill download suites --- src/agents/skills-install.download-tarbz2.e2e.test.ts | 9 +-------- src/agents/skills-install.download.e2e.test.ts | 10 +--------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/agents/skills-install.download-tarbz2.e2e.test.ts b/src/agents/skills-install.download-tarbz2.e2e.test.ts index 0f486a28cca..c02c7947b4a 100644 --- a/src/agents/skills-install.download-tarbz2.e2e.test.ts +++ b/src/agents/skills-install.download-tarbz2.e2e.test.ts @@ -1,6 +1,5 @@ import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { captureEnv } from "../test-utils/env.js"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { withTempWorkspace, writeDownloadSkill } from "./skills-install.download-test-utils.js"; import { installSkill } from "./skills-install.js"; @@ -9,7 +8,6 @@ const mocks = { scanSummary: vi.fn(), fetchGuard: vi.fn(), }; -let envSnapshot: ReturnType; function mockDownloadResponse() { mocks.fetchGuard.mockResolvedValue({ @@ -91,7 +89,6 @@ vi.mock("../security/skill-scanner.js", async (importOriginal) => { describe("installSkill download extraction safety (tar.bz2)", () => { beforeEach(() => { - envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]); mocks.runCommand.mockReset(); mocks.scanSummary.mockReset(); mocks.fetchGuard.mockReset(); @@ -104,10 +101,6 @@ describe("installSkill download extraction safety (tar.bz2)", () => { }); }); - afterEach(() => { - envSnapshot.restore(); - }); - it("rejects tar.bz2 traversal before extraction", async () => { await withTempWorkspace(async ({ workspaceDir, stateDir }) => { const url = "https://example.invalid/evil.tbz2"; diff --git a/src/agents/skills-install.download.e2e.test.ts b/src/agents/skills-install.download.e2e.test.ts index 8ffe02249e2..2e24791d7bb 100644 --- a/src/agents/skills-install.download.e2e.test.ts +++ b/src/agents/skills-install.download.e2e.test.ts @@ -2,8 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import JSZip from "jszip"; import * as tar from "tar"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { captureEnv } from "../test-utils/env.js"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { withTempWorkspace, writeDownloadSkill } from "./skills-install.download-test-utils.js"; import { installSkill } from "./skills-install.js"; @@ -11,8 +10,6 @@ const runCommandWithTimeoutMock = vi.fn(); const scanDirectoryWithSummaryMock = vi.fn(); const fetchWithSsrFGuardMock = vi.fn(); -let envSnapshot: ReturnType; - vi.mock("../process/exec.js", () => ({ runCommandWithTimeout: (...args: unknown[]) => runCommandWithTimeoutMock(...args), })); @@ -73,7 +70,6 @@ async function installZipDownloadSkill(params: { describe("installSkill download extraction safety", () => { beforeEach(() => { - envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]); runCommandWithTimeoutMock.mockReset(); scanDirectoryWithSummaryMock.mockReset(); fetchWithSsrFGuardMock.mockReset(); @@ -86,10 +82,6 @@ describe("installSkill download extraction safety", () => { }); }); - afterEach(() => { - envSnapshot.restore(); - }); - it("rejects zip slip traversal", async () => { await withTempWorkspace(async ({ workspaceDir, stateDir }) => { const targetDir = path.join(stateDir, "tools", "zip-slip", "target");