Files
multica/packages/core/agents/openclaw-runtime-config.test.ts
Bohan Jiang 7d30ef1c67 fix: preserve openclaw gateway token mask (#4152)
Co-authored-by: J <j@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-06-15 17:46:35 +08:00

64 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
OPENCLAW_GATEWAY_TOKEN_MASK,
serializeOpenclawRuntimeConfig,
} from "./openclaw-runtime-config";
describe("serializeOpenclawRuntimeConfig", () => {
it("keeps the masked gateway token sentinel so the API can preserve the persisted token", () => {
expect(
serializeOpenclawRuntimeConfig({
mode: "gateway",
gateway: {
host: "gw.internal",
port: 18789,
token: OPENCLAW_GATEWAY_TOKEN_MASK,
tls: true,
},
}),
).toEqual({
mode: "gateway",
gateway: {
host: "gw.internal",
port: 18789,
token: OPENCLAW_GATEWAY_TOKEN_MASK,
tls: true,
},
});
});
it("omits an empty gateway token so users can clear a persisted token", () => {
expect(
serializeOpenclawRuntimeConfig({
mode: "gateway",
gateway: {
host: "gw.internal",
port: 18789,
},
}),
).toEqual({
mode: "gateway",
gateway: {
host: "gw.internal",
port: 18789,
},
});
});
it("passes through a real gateway token value", () => {
expect(
serializeOpenclawRuntimeConfig({
mode: "gateway",
gateway: {
token: "rotated-secret",
},
}),
).toEqual({
mode: "gateway",
gateway: {
token: "rotated-secret",
},
});
});
});