mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:42:44 +00:00
chore(ci): fix cross-platform symlink path assertions in agents file tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
@@ -515,7 +516,7 @@ describe("agents.files.get/set symlink safety", () => {
|
|||||||
|
|
||||||
it("rejects agents.files.get when allowlisted file symlink escapes workspace", async () => {
|
it("rejects agents.files.get when allowlisted file symlink escapes workspace", async () => {
|
||||||
const workspace = "/workspace/test-agent";
|
const workspace = "/workspace/test-agent";
|
||||||
const candidate = `${workspace}/AGENTS.md`;
|
const candidate = path.resolve(workspace, "AGENTS.md");
|
||||||
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
||||||
if (p === workspace) {
|
if (p === workspace) {
|
||||||
return workspace;
|
return workspace;
|
||||||
@@ -548,7 +549,7 @@ describe("agents.files.get/set symlink safety", () => {
|
|||||||
|
|
||||||
it("rejects agents.files.set when allowlisted file symlink escapes workspace", async () => {
|
it("rejects agents.files.set when allowlisted file symlink escapes workspace", async () => {
|
||||||
const workspace = "/workspace/test-agent";
|
const workspace = "/workspace/test-agent";
|
||||||
const candidate = `${workspace}/AGENTS.md`;
|
const candidate = path.resolve(workspace, "AGENTS.md");
|
||||||
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
||||||
if (p === workspace) {
|
if (p === workspace) {
|
||||||
return workspace;
|
return workspace;
|
||||||
@@ -583,8 +584,8 @@ describe("agents.files.get/set symlink safety", () => {
|
|||||||
|
|
||||||
it("allows in-workspace symlink targets for get/set", async () => {
|
it("allows in-workspace symlink targets for get/set", async () => {
|
||||||
const workspace = "/workspace/test-agent";
|
const workspace = "/workspace/test-agent";
|
||||||
const candidate = `${workspace}/AGENTS.md`;
|
const candidate = path.resolve(workspace, "AGENTS.md");
|
||||||
const target = `${workspace}/policies/AGENTS.md`;
|
const target = path.resolve(workspace, "policies", "AGENTS.md");
|
||||||
const targetStat = makeFileStat({ size: 7, mtimeMs: 1700, dev: 9, ino: 42 });
|
const targetStat = makeFileStat({ size: 7, mtimeMs: 1700, dev: 9, ino: 42 });
|
||||||
|
|
||||||
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
mocks.fsRealpath.mockImplementation(async (p: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user