Files
openclaw/src/channels/account-snapshot-fields.test.ts
Vincent Koc f0202264d0 Gateway: scrub credentials from endpoint snapshots (#46799)
* Gateway: scrub credentials from endpoint snapshots

* Gateway: scrub raw endpoint credentials in snapshots

* Gateway: preserve config redaction round-trips

* Gateway: restore redacted endpoint URLs on apply
2026-03-15 10:28:15 -07:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { projectSafeChannelAccountSnapshotFields } from "./account-snapshot-fields.js";
describe("projectSafeChannelAccountSnapshotFields", () => {
it("omits webhook and public-key style fields from generic snapshots", () => {
const snapshot = projectSafeChannelAccountSnapshotFields({
name: "Primary",
tokenSource: "config",
tokenStatus: "configured_unavailable",
signingSecretSource: "config", // pragma: allowlist secret
signingSecretStatus: "configured_unavailable", // pragma: allowlist secret
webhookUrl: "https://example.com/webhook",
webhookPath: "/webhook",
audienceType: "project-number",
audience: "1234567890",
publicKey: "pk_live_123",
});
expect(snapshot).toEqual({
name: "Primary",
tokenSource: "config",
tokenStatus: "configured_unavailable",
signingSecretSource: "config", // pragma: allowlist secret
signingSecretStatus: "configured_unavailable", // pragma: allowlist secret
});
});
it("strips embedded credentials from baseUrl fields", () => {
const snapshot = projectSafeChannelAccountSnapshotFields({
baseUrl: "https://bob:secret@chat.example.test",
});
expect(snapshot).toEqual({
baseUrl: "https://chat.example.test/",
});
});
});