Files
openclaw/src/plugins/hardlink-policy.test.ts
the sun gif man 954d20ece2 fix: allow Nix store plugin hardlinks (#79344)
Merged via squash.

Prepared head SHA: bf533f8654

Co-authored-by: Codex <noreply@openai.com>
Reviewed-by: @joshp123
2026-05-08 16:59:53 +02:00

52 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { isNixStorePluginRoot, shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js";
const nixEnv: NodeJS.ProcessEnv = { OPENCLAW_NIX_MODE: "1" };
describe("plugin hardlink policy", () => {
it("does not reject bundled plugin files", () => {
expect(
shouldRejectHardlinkedPluginFiles({
origin: "bundled",
rootDir: "/tmp/plugin",
env: {},
}),
).toBe(false);
});
it("rejects hardlinked external plugin files by default", () => {
expect(
shouldRejectHardlinkedPluginFiles({
origin: "config",
rootDir: "/tmp/plugin",
env: {},
}),
).toBe(true);
});
it("does not treat OPENCLAW_NIX_MODE as enough by itself", () => {
expect(
shouldRejectHardlinkedPluginFiles({
origin: "config",
rootDir: "/tmp/plugin",
env: nixEnv,
}),
).toBe(true);
});
it.runIf(process.platform !== "win32")(
"does not reject hardlinked external plugin files when Nix mode loads from the Nix store",
() => {
expect(isNixStorePluginRoot("/nix/store/abc-openclaw-plugin")).toBe(true);
expect(isNixStorePluginRoot("/tmp/nix/store/abc-openclaw-plugin")).toBe(false);
expect(
shouldRejectHardlinkedPluginFiles({
origin: "config",
rootDir: "/nix/store/abc-openclaw-plugin",
env: nixEnv,
}),
).toBe(false);
},
);
});