mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:01:23 +00:00
refactor(test): drop redundant env snapshots in skill download suites
This commit is contained in:
@@ -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<typeof captureEnv>;
|
||||
|
||||
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";
|
||||
|
||||
@@ -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<typeof captureEnv>;
|
||||
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user