fix(gateway): honor insecure ws override for remote hostnames

This commit is contained in:
Vignesh Natarajan
2026-03-05 17:04:26 -08:00
parent c260e207b2
commit d86a12eb62
6 changed files with 73 additions and 1 deletions

View File

@@ -132,6 +132,27 @@ describe("promptRemoteGatewayConfig", () => {
expect(next.gateway?.remote?.token).toBeUndefined();
});
it("allows ws:// hostname remote URLs when OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1", async () => {
process.env.OPENCLAW_ALLOW_INSECURE_PRIVATE_WS = "1";
const text: WizardPrompter["text"] = vi.fn(async (params) => {
if (params.message === "Gateway WebSocket URL") {
expect(params.validate?.("ws://openclaw-gateway.ai:18789")).toBeUndefined();
expect(params.validate?.("ws://1.1.1.1:18789")).toContain("Use wss://");
return "ws://openclaw-gateway.ai:18789";
}
return "";
}) as WizardPrompter["text"];
const { next } = await runRemotePrompt({
text,
confirm: false,
selectResponses: { "Gateway auth": "off" },
});
expect(next.gateway?.mode).toBe("remote");
expect(next.gateway?.remote?.url).toBe("ws://openclaw-gateway.ai:18789");
});
it("supports storing remote auth as an external env secret ref", async () => {
process.env.OPENCLAW_GATEWAY_TOKEN = "remote-token-value";
const text: WizardPrompter["text"] = vi.fn(async (params) => {