Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { redactConnectorPayload } from "./connector-safety.js";
|
|
|
|
describe("redactConnectorPayload", () => {
|
|
it("redacts secrets that JSON escapes in property names and values", () => {
|
|
const secret = 'api"key';
|
|
|
|
expect(
|
|
redactConnectorPayload(
|
|
{
|
|
[secret]: `prefix ${secret} suffix`,
|
|
nested: { value: secret },
|
|
},
|
|
[secret],
|
|
),
|
|
).toEqual({
|
|
"[redacted]": "prefix [redacted] suffix",
|
|
nested: { value: "[redacted]" },
|
|
});
|
|
});
|
|
|
|
it("falls back to an inert result when the payload is not JSON serializable", () => {
|
|
const circular: Record<string, unknown> = {};
|
|
circular.self = circular;
|
|
|
|
expect(redactConnectorPayload(circular, ["secret"])).toEqual({ ok: true });
|
|
});
|
|
|
|
it("redacts secrets represented by non-string JSON leaves", () => {
|
|
expect(
|
|
redactConnectorPayload({ number: 123, boolean: true, empty: null }, ["123", "true", "null"]),
|
|
).toEqual({ number: "[redacted]", boolean: "[redacted]", empty: "[redacted]" });
|
|
});
|
|
});
|