Files
openclaw/extensions/bluebubbles/src/channel.status.test.ts
James Reagan dac72889e5 fix(bluebubbles): localhost probe respects private-network opt-out (#59373)
* honor localhost private-network policy

* drop flaky monitor private-network test

* align mocks and imports

* preserve account private-network overrides

* keep default account config

* strip stale private-network aliases

* fix(bluebubbles): remove unused channel imports

* fix: add changelog for bluebubbles private-network opt-out landing (#59373) (thanks @jpreagan)

---------

Co-authored-by: Shadow <hi@shadowing.dev>
2026-04-07 11:29:21 -05:00

81 lines
2.2 KiB
TypeScript

import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "./runtime-api.js";
const probeBlueBubblesMock = vi.hoisted(() => vi.fn());
const cfg: OpenClawConfig = {};
vi.mock("./channel.runtime.js", () => ({
blueBubblesChannelRuntime: {
probeBlueBubbles: probeBlueBubblesMock,
},
}));
vi.mock("../../../src/channels/plugins/bundled.js", () => ({
bundledChannelPlugins: [],
bundledChannelSetupPlugins: [],
}));
let bluebubblesPlugin: typeof import("./channel.js").bluebubblesPlugin;
describe("bluebubblesPlugin.status.probeAccount", () => {
beforeAll(async () => {
({ bluebubblesPlugin } = await import("./channel.js"));
});
beforeEach(() => {
probeBlueBubblesMock.mockReset();
probeBlueBubblesMock.mockResolvedValue({ ok: true, status: 200 });
});
it("auto-enables private-network probes for loopback server URLs", async () => {
await bluebubblesPlugin.status?.probeAccount?.({
cfg,
account: {
accountId: "default",
enabled: true,
configured: true,
config: {
serverUrl: "http://localhost:1234",
password: "test-password",
},
baseUrl: "http://localhost:1234",
},
timeoutMs: 5000,
});
expect(probeBlueBubblesMock).toHaveBeenCalledWith({
baseUrl: "http://localhost:1234",
password: "test-password",
timeoutMs: 5000,
allowPrivateNetwork: true,
});
});
it("respects an explicit private-network opt-out for loopback server URLs", async () => {
await bluebubblesPlugin.status?.probeAccount?.({
cfg,
account: {
accountId: "default",
enabled: true,
configured: true,
config: {
serverUrl: "http://localhost:1234",
password: "test-password",
network: {
dangerouslyAllowPrivateNetwork: false,
},
},
baseUrl: "http://localhost:1234",
},
timeoutMs: 5000,
});
expect(probeBlueBubblesMock).toHaveBeenCalledWith({
baseUrl: "http://localhost:1234",
password: "test-password",
timeoutMs: 5000,
allowPrivateNetwork: false,
});
});
});