mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:17:40 +00:00
refactor(gateway): unify control-ui and plugin webhook routing
This commit is contained in:
@@ -2,6 +2,8 @@ import { createServer, type RequestListener } from "node:http";
|
||||
import type { AddressInfo } from "node:net";
|
||||
import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { createEmptyPluginRegistry } from "../../../src/plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../../../src/plugins/runtime.js";
|
||||
import {
|
||||
clearZaloWebhookSecurityStateForTest,
|
||||
getZaloWebhookRateLimitStateSizeForTest,
|
||||
@@ -95,6 +97,28 @@ function createPairingAuthCore(params?: { storeAllowFrom?: string[]; pairingCrea
|
||||
describe("handleZaloWebhookRequest", () => {
|
||||
afterEach(() => {
|
||||
clearZaloWebhookSecurityStateForTest();
|
||||
setActivePluginRegistry(createEmptyPluginRegistry());
|
||||
});
|
||||
|
||||
it("registers and unregisters plugin HTTP route at path boundaries", () => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
setActivePluginRegistry(registry);
|
||||
const unregisterA = registerTarget({ path: "/hook" });
|
||||
const unregisterB = registerTarget({ path: "/hook" });
|
||||
|
||||
expect(registry.httpRoutes).toHaveLength(1);
|
||||
expect(registry.httpRoutes[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
pluginId: "zalo",
|
||||
path: "/hook",
|
||||
source: "zalo-webhook",
|
||||
}),
|
||||
);
|
||||
|
||||
unregisterA();
|
||||
expect(registry.httpRoutes).toHaveLength(1);
|
||||
unregisterB();
|
||||
expect(registry.httpRoutes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("returns 400 for non-object payloads", async () => {
|
||||
|
||||
Reference in New Issue
Block a user