redact.test.ts 470 B

123456789
  1. import { describe, expect, it } from "vitest";
  2. import { pretty, redact } from "@/lib/redact";
  3. describe("redaction", () => {
  4. it("redacts credential-like fields and bearer values", () => {
  5. expect(redact({ apiKey: "secret", nested: { authorization: "Bearer abc.def" }, safe: "ok" })).toEqual({ apiKey: "[REDACTED]", nested: { authorization: "[REDACTED]" }, safe: "ok" });
  6. expect(pretty("Authorization: Bearer abc.def")).toContain("Bearer [REDACTED]");
  7. });
  8. });