mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 01:51:24 +00:00
test: remove low-value resolveStorePath tilde-expansion unit case
This commit is contained in:
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|||||||
import fsPromises from "node:fs/promises";
|
import fsPromises from "node:fs/promises";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import type { SessionConfig } from "../types.base.js";
|
import type { SessionConfig } from "../types.base.js";
|
||||||
import type { SessionEntry } from "./types.js";
|
import type { SessionEntry } from "./types.js";
|
||||||
import {
|
import {
|
||||||
@@ -15,7 +15,6 @@ import { deriveSessionMetaPatch } from "./metadata.js";
|
|||||||
import {
|
import {
|
||||||
resolveSessionFilePath,
|
resolveSessionFilePath,
|
||||||
resolveSessionTranscriptPathInDir,
|
resolveSessionTranscriptPathInDir,
|
||||||
resolveStorePath,
|
|
||||||
validateSessionId,
|
validateSessionId,
|
||||||
} from "./paths.js";
|
} from "./paths.js";
|
||||||
import { resolveSessionResetPolicy } from "./reset.js";
|
import { resolveSessionResetPolicy } from "./reset.js";
|
||||||
@@ -44,25 +43,6 @@ describe("deriveSessionMetaPatch", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("resolveStorePath", () => {
|
|
||||||
afterEach(() => {
|
|
||||||
vi.unstubAllEnvs();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("uses OPENCLAW_HOME for tilde expansion", () => {
|
|
||||||
vi.stubEnv("OPENCLAW_HOME", "/srv/openclaw-home");
|
|
||||||
vi.stubEnv("HOME", "/home/other");
|
|
||||||
|
|
||||||
const resolved = resolveStorePath("~/.openclaw/agents/{agentId}/sessions/sessions.json", {
|
|
||||||
agentId: "research",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved).toBe(
|
|
||||||
path.resolve("/srv/openclaw-home/.openclaw/agents/research/sessions/sessions.json"),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("session path safety", () => {
|
describe("session path safety", () => {
|
||||||
it("rejects unsafe session IDs", () => {
|
it("rejects unsafe session IDs", () => {
|
||||||
expect(() => validateSessionId("../etc/passwd")).toThrow(/Invalid session ID/);
|
expect(() => validateSessionId("../etc/passwd")).toThrow(/Invalid session ID/);
|
||||||
|
|||||||
Reference in New Issue
Block a user