|
2 | 2 | import { installedPluginRoot } from "openclaw/plugin-sdk/test-fixtures"; |
3 | 3 | import { describe, expect, it, vi } from "vitest"; |
4 | 4 | import { PLUGIN_INSTALL_ERROR_CODE } from "../plugins/install.js"; |
| 5 | +import { |
| 6 | + resolveCatalogOfficialExternalInstallPlan, |
| 7 | + resolveCatalogOfficialExternalNpmPackageTrust, |
| 8 | +} from "../plugins/official-external-install-trust.js"; |
5 | 9 | import { |
6 | 10 | resolveBundledInstallPlanForCatalogEntry, |
7 | 11 | resolveBundledInstallPlanBeforeNpm, |
8 | 12 | resolveBundledInstallPlanForNpmFailure, |
9 | | - resolveOfficialExternalInstallPlanBeforeNpm, |
10 | | - resolveOfficialExternalNpmPackageTrust, |
11 | 13 | } from "./plugin-install-plan.js"; |
12 | 14 |
|
13 | 15 | describe("plugin install plan helpers", () => { |
@@ -70,81 +72,39 @@ describe("plugin install plan helpers", () => { |
70 | 72 | }); |
71 | 73 |
|
72 | 74 | it("resolves exact official external plugin ids before npm fallback", () => { |
73 | | - const findOfficialExternalPlugin = vi.fn().mockReturnValue({ |
74 | | - pluginId: "brave", |
75 | | - npmSpec: "@openclaw/brave-plugin", |
76 | | - expectedIntegrity: "sha512-brave", |
77 | | - }); |
| 75 | + const result = resolveCatalogOfficialExternalInstallPlan("wecom-openclaw-plugin"); |
78 | 76 |
|
79 | | - const result = resolveOfficialExternalInstallPlanBeforeNpm({ |
80 | | - rawSpec: "brave", |
81 | | - findOfficialExternalPlugin, |
82 | | - }); |
83 | | - |
84 | | - expect(findOfficialExternalPlugin).toHaveBeenCalledWith("brave"); |
85 | 77 | expect(result).toEqual({ |
86 | | - pluginId: "brave", |
87 | | - npmSpec: "@openclaw/brave-plugin", |
88 | | - expectedIntegrity: "sha512-brave", |
| 78 | + pluginId: "wecom-openclaw-plugin", |
| 79 | + npmSpec: "@wecom/[email protected]", |
| 80 | + expectedIntegrity: |
| 81 | + "sha512-TCkP9as00WfEhgFWG8YL/rcmaWGIshAki2HQh83nTRccGfVBCoGjrEboTTqq3yDmK9koWTV11zi8u8A4dNtvug==", |
89 | 82 | }); |
90 | 83 | }); |
91 | 84 |
|
92 | 85 | it("skips official external plan for explicit npm selectors", () => { |
93 | | - const findOfficialExternalPlugin = vi.fn(); |
94 | | - |
| 86 | + expect(resolveCatalogOfficialExternalInstallPlan("wecom-openclaw-plugin@beta")).toBeNull(); |
95 | 87 | expect( |
96 | | - resolveOfficialExternalInstallPlanBeforeNpm({ |
97 | | - rawSpec: "brave@beta", |
98 | | - findOfficialExternalPlugin, |
99 | | - }), |
| 88 | + resolveCatalogOfficialExternalInstallPlan("@wecom/[email protected]"), |
100 | 89 | ).toBeNull(); |
101 | | - expect( |
102 | | - resolveOfficialExternalInstallPlanBeforeNpm({ |
103 | | - rawSpec: "@openclaw/brave-plugin", |
104 | | - findOfficialExternalPlugin, |
105 | | - }), |
106 | | - ).toBeNull(); |
107 | | - expect(findOfficialExternalPlugin).not.toHaveBeenCalled(); |
108 | | - }); |
109 | | - |
110 | | - it("skips official external plan without an npm install spec", () => { |
111 | | - const result = resolveOfficialExternalInstallPlanBeforeNpm({ |
112 | | - rawSpec: "brave", |
113 | | - findOfficialExternalPlugin: vi.fn().mockReturnValue({ |
114 | | - pluginId: "brave", |
115 | | - }), |
116 | | - }); |
117 | | - |
118 | | - expect(result).toBeNull(); |
119 | 90 | }); |
120 | 91 |
|
121 | 92 | it("trusts exact official external npm packages without remapping the spec", () => { |
122 | | - const findOfficialExternalPackage = vi.fn().mockReturnValue({ |
123 | | - pluginId: "discord", |
124 | | - npmSpec: "@openclaw/discord", |
125 | | - }); |
| 93 | + const result = resolveCatalogOfficialExternalNpmPackageTrust( |
| 94 | + |
| 95 | + ); |
126 | 96 |
|
127 | | - const result = resolveOfficialExternalNpmPackageTrust({ |
128 | | - npmSpec: "@openclaw/discord", |
129 | | - findOfficialExternalPackage, |
130 | | - }); |
131 | | - |
132 | | - expect(findOfficialExternalPackage).toHaveBeenCalledWith("@openclaw/discord"); |
133 | 97 | expect(result).toEqual({ |
134 | | - pluginId: "discord", |
| 98 | + pluginId: "wecom-openclaw-plugin", |
| 99 | + expectedIntegrity: |
| 100 | + "sha512-TCkP9as00WfEhgFWG8YL/rcmaWGIshAki2HQh83nTRccGfVBCoGjrEboTTqq3yDmK9koWTV11zi8u8A4dNtvug==", |
135 | 101 | trustedSourceLinkedOfficialInstall: true, |
136 | 102 | }); |
137 | 103 | }); |
138 | 104 |
|
139 | 105 | it("does not trust npm package names outside the official external catalog", () => { |
140 | | - const findOfficialExternalPackage = vi.fn(); |
141 | | - |
142 | | - const result = resolveOfficialExternalNpmPackageTrust({ |
143 | | - npmSpec: "brave", |
144 | | - findOfficialExternalPackage, |
145 | | - }); |
| 106 | + const result = resolveCatalogOfficialExternalNpmPackageTrust("@acme/[email protected]"); |
146 | 107 |
|
147 | | - expect(findOfficialExternalPackage).toHaveBeenCalledWith("brave"); |
148 | 108 | expect(result).toBeNull(); |
149 | 109 | }); |
150 | 110 |
|
|
0 commit comments