mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 03:20:43 +00:00
Merged via squash.
Prepared head SHA: bf533f8654
Co-authored-by: Codex <noreply@openai.com>
Reviewed-by: @joshp123
52 lines
1.4 KiB
TypeScript
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);
|
|
},
|
|
);
|
|
});
|