Files
openclaw/src/plugins/install-provenance.test.ts
T
Jesse Merhi 00364ee777 improve: warn before non-ClawHub plugin installs (#102197)
Merged via squash.

Prepared head SHA: e08d9e737d
Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Reviewed-by: @jesse-merhi
2026-07-15 03:25:36 +10:00

36 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { BundledPluginSource } from "./bundled-sources.js";
import { isOpenClawTrustedPluginInstallSpec } from "./install-provenance.js";
const bundledSources = new Map<string, BundledPluginSource>([
[
"discord",
{
pluginId: "discord",
localPath: "/opt/openclaw/extensions/discord",
npmSpec: "@openclaw/discord",
},
],
]);
describe("plugin install provenance", () => {
it.each([
"discord",
"@openclaw/discord",
"npm:@openclaw/discord",
"/opt/openclaw/extensions/discord",
"brave",
"npm:@openclaw/brave-plugin",
"clawhub:openclaw-demo",
])("trusts OpenClaw-owned install source %s", (spec) => {
expect(isOpenClawTrustedPluginInstallSpec(spec, bundledSources)).toBe(true);
});
it.each(["npm:discord", "npm:@example/plugin", "/tmp/example-plugin"])(
"keeps arbitrary install source %s untrusted",
(spec) => {
expect(isOpenClawTrustedPluginInstallSpec(spec, bundledSources)).toBe(false);
},
);
});