























@@ -131,11 +131,13 @@ function readFirstMockCall(mock: unknown, label: string): unknown[] {
131131132132type NpmPackInstallCall = {
133133archivePath?: string;
134+config?: OpenClawConfig;
134135expectedPluginId?: string;
135136trustedSourceLinkedOfficialInstall?: boolean;
136137};
137138138139type NpmSpecInstallCall = {
140+config?: OpenClawConfig;
139141expectedIntegrity?: string;
140142expectedPluginId?: string;
141143mode?: string;
@@ -145,6 +147,7 @@ type NpmSpecInstallCall = {
145147};
146148147149type ClawHubInstallCall = {
150+config?: OpenClawConfig;
148151expectedPluginId?: string;
149152mode?: string;
150153spec?: string;
@@ -313,6 +316,19 @@ describe("ensureOnboardingPluginInstalled", () => {
313316314317it("uses a guarded npm-pack install override for the matching plugin id", async () => {
315318const archivePath = path.resolve("tmp/demo-plugin.tgz");
319+const cfg: OpenClawConfig = {
320+security: {
321+installPolicy: {
322+enabled: true,
323+exec: {
324+source: "exec",
325+command: process.execPath,
326+args: ["-e", "process.exit(1)"],
327+allowInsecurePath: true,
328+},
329+},
330+},
331+};
316332process.env.OPENCLAW_ALLOW_PLUGIN_INSTALL_OVERRIDES = "1";
317333process.env.OPENCLAW_PLUGIN_INSTALL_OVERRIDES = JSON.stringify({
318334"other-plugin": "npm:@demo/other@1.0.0",
@@ -337,7 +353,7 @@ describe("ensureOnboardingPluginInstalled", () => {
337353338354const select = vi.fn(async () => "npm");
339355const result = await ensureOnboardingPluginInstalled({
340-cfg: {},
356+ cfg,
341357entry: {
342358pluginId: "demo-plugin",
343359label: "Demo Plugin",
@@ -361,6 +377,7 @@ describe("ensureOnboardingPluginInstalled", () => {
361377"installPluginFromNpmPackArchive",
362378) as [NpmPackInstallCall];
363379expect(packCall.archivePath).toBe(archivePath);
380+expect(packCall.config).toBe(cfg);
364381expect(packCall.expectedPluginId).toBe("demo-plugin");
365382expect(packCall).not.toHaveProperty("trustedSourceLinkedOfficialInstall");
366383const [, recordUpdate] = readFirstMockCall(recordPluginInstall, "recordPluginInstall") as [
@@ -428,6 +445,19 @@ describe("ensureOnboardingPluginInstalled", () => {
428445});
429446430447it("installs and records ClawHub provider plugins with source facts", async () => {
448+const cfg: OpenClawConfig = {
449+security: {
450+installPolicy: {
451+enabled: true,
452+exec: {
453+source: "exec",
454+command: process.execPath,
455+args: ["-e", "process.exit(1)"],
456+allowInsecurePath: true,
457+},
458+},
459+},
460+};
431461installPluginFromClawHub.mockImplementation(async (params) => {
432462params.logger?.info?.("Downloading demo-plugin from ClawHub…");
433463return {
@@ -457,7 +487,7 @@ describe("ensureOnboardingPluginInstalled", () => {
457487const update = vi.fn();
458488459489const result = await ensureOnboardingPluginInstalled({
460-cfg: {},
490+ cfg,
461491entry: {
462492pluginId: "demo-plugin",
463493label: "Demo Provider",
@@ -479,6 +509,7 @@ describe("ensureOnboardingPluginInstalled", () => {
479509"installPluginFromClawHub",
480510) as [ClawHubInstallCall];
481511expect(clawHubCall.spec).toBe("clawhub:demo-plugin@2026.5.2");
512+expect(clawHubCall.config).toBe(cfg);
482513expect(clawHubCall.expectedPluginId).toBe("demo-plugin");
483514expect(clawHubCall.mode).toBe("install");
484515expect(clawHubCall.timeoutMs).toBe(300_000);
@@ -507,6 +538,19 @@ describe("ensureOnboardingPluginInstalled", () => {
507538});
508539509540it("passes npm specs and optional expected integrity to npm installs with progress", async () => {
541+const cfg: OpenClawConfig = {
542+security: {
543+installPolicy: {
544+enabled: true,
545+exec: {
546+source: "exec",
547+command: process.execPath,
548+args: ["-e", "process.exit(1)"],
549+allowInsecurePath: true,
550+},
551+},
552+},
553+};
510554const npmResolution = {
511555name: "@wecom/wecom-openclaw-plugin",
512556version: "1.2.3",
@@ -538,7 +582,7 @@ describe("ensureOnboardingPluginInstalled", () => {
538582const update = vi.fn();
539583540584const result = await ensureOnboardingPluginInstalled({
541-cfg: {},
585+ cfg,
542586entry: {
543587pluginId: "demo-plugin",
544588label: "WeCom",
@@ -559,6 +603,7 @@ describe("ensureOnboardingPluginInstalled", () => {
559603NpmSpecInstallCall,
560604];
561605expect(npmCall.spec).toBe("@wecom/wecom-openclaw-plugin@1.2.3");
606+expect(npmCall.config).toBe(cfg);
562607expect(npmCall.mode).toBe("update");
563608expect(npmCall.expectedPluginId).toBe("demo-plugin");
564609expect(npmCall.expectedIntegrity).toBe("sha512-wecom");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。