mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 21:11:14 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
/** Tests plugin CLI node Gateway runtime timeout and invocation behavior. */
|
|
import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { createPluginCliGatewayNodesRuntime } from "./cli-gateway-nodes-runtime.js";
|
|
import { withPluginRuntimePluginScope } from "./runtime/gateway-request-scope.js";
|
|
|
|
const callGatewayMock = vi.fn();
|
|
|
|
vi.mock("../gateway/call.js", () => ({
|
|
callGateway: (opts: unknown) => callGatewayMock(opts),
|
|
}));
|
|
|
|
describe("createPluginCliGatewayNodesRuntime", () => {
|
|
beforeEach(() => {
|
|
callGatewayMock.mockReset();
|
|
callGatewayMock.mockResolvedValue({});
|
|
});
|
|
|
|
it("caps oversized node invoke gateway timeouts", async () => {
|
|
const nodes = createPluginCliGatewayNodesRuntime();
|
|
|
|
await nodes.invoke({
|
|
nodeId: "node-1",
|
|
command: "system.run",
|
|
timeoutMs: Number.MAX_SAFE_INTEGER,
|
|
});
|
|
|
|
expect(callGatewayMock).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
method: "node.invoke",
|
|
timeoutMs: MAX_TIMER_TIMEOUT_MS,
|
|
params: expect.objectContaining({
|
|
timeoutMs: Number.MAX_SAFE_INTEGER,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("forwards requested node invoke scopes for bundled plugin CLI runtime", async () => {
|
|
const nodes = createPluginCliGatewayNodesRuntime();
|
|
|
|
await withPluginRuntimePluginScope({ pluginId: "google-meet", pluginOrigin: "bundled" }, () =>
|
|
nodes.invoke({
|
|
nodeId: "node-1",
|
|
command: "browser.proxy",
|
|
scopes: ["operator.admin"],
|
|
}),
|
|
);
|
|
|
|
expect(callGatewayMock).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
method: "node.invoke",
|
|
scopes: ["operator.admin"],
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("drops requested node invoke scopes for third-party plugin CLI runtime", async () => {
|
|
const nodes = createPluginCliGatewayNodesRuntime();
|
|
|
|
await withPluginRuntimePluginScope({ pluginId: "third-party", pluginOrigin: "global" }, () =>
|
|
nodes.invoke({
|
|
nodeId: "node-1",
|
|
command: "browser.proxy",
|
|
scopes: ["operator.admin"],
|
|
}),
|
|
);
|
|
|
|
expect(callGatewayMock).toHaveBeenCalledWith(
|
|
expect.not.objectContaining({
|
|
scopes: expect.anything(),
|
|
}),
|
|
);
|
|
});
|
|
});
|