























@@ -70,6 +70,7 @@ type ApprovedPairingDevice = ApprovedPairingResult["device"];
7070const INTERNAL_PAIRING_SCOPES = ["operator.write", "operator.pairing"];
71717272function createApi(params?: {
73+config?: OpenClawPluginApi["config"];
7374runtime?: OpenClawPluginApi["runtime"];
7475pluginConfig?: Record<string, unknown>;
7576registerCommand?: (command: OpenClawPluginCommandDefinition) => void;
@@ -78,7 +79,7 @@ function createApi(params?: {
7879id: "device-pair",
7980name: "device-pair",
8081source: "test",
81-config: {
82+config: params?.config ?? {
8283gateway: {
8384auth: {
8485mode: "token",
@@ -96,6 +97,7 @@ function createApi(params?: {
9697}
97989899function registerPairCommand(params?: {
100+config?: OpenClawPluginApi["config"];
99101runtime?: OpenClawPluginApi["runtime"];
100102pluginConfig?: Record<string, unknown>;
101103}): OpenClawPluginCommandDefinition {
@@ -649,6 +651,36 @@ describe("device-pair /pair default setup code", () => {
649651expect(result).toEqual({ text: "Error: Configured publicUrl is invalid." });
650652});
651653654+it("rejects invalid gateway.remote.url before falling back to bind-derived setup urls", async () => {
655+const command = registerPairCommand({
656+config: {
657+gateway: {
658+bind: "custom",
659+customBindHost: "127.0.0.1",
660+remote: { url: "http://localhost:notaport" },
661+auth: {
662+mode: "token",
663+token: "gateway-token",
664+},
665+},
666+},
667+pluginConfig: {
668+publicUrl: undefined,
669+},
670+});
671+const result = await command.handler(
672+createCommandContext({
673+channel: "webchat",
674+args: "",
675+commandBody: "/pair",
676+gatewayClientScopes: ["operator.write", "operator.pairing"],
677+}),
678+);
679+680+expect(pluginApiMocks.issueDeviceBootstrapToken).not.toHaveBeenCalled();
681+expect(result).toEqual({ text: "Error: Configured gateway.remote.url is invalid." });
682+});
683+652684it.each([
653685"http://localhost:notaport",
654686"http:gateway.example.test",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。