openclaw/src/gateway/server-runtime-config.test.ts
2026-01-27 18:22:01 +05:00

48 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import { resolveGatewayRuntimeConfig } from "./server-runtime-config.js";
describe("resolveGatewayRuntimeConfig", () => {
it("rejects weak auth when binding beyond loopback", async () => {
const cfg: MoltbotConfig = {
gateway: {
auth: {
mode: "token",
token: "short-token",
},
},
};
await expect(
resolveGatewayRuntimeConfig({
cfg,
port: 18789,
host: "0.0.0.0",
}),
).rejects.toThrow("weak shared secret");
});
it("allows custom auth minimum length", async () => {
const cfg: MoltbotConfig = {
gateway: {
auth: {
mode: "token",
token: "long-enough-token",
minLength: 10,
},
},
};
await expect(
resolveGatewayRuntimeConfig({
cfg,
port: 18789,
host: "0.0.0.0",
}),
).resolves.toMatchObject({
bindHost: "0.0.0.0",
});
});
});