34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { Logger } from "../logger";
|
|
|
|
describe("Logger Stripe secret redaction", () => {
|
|
it("redacts nested Stripe secret fields and values before formatting", () => {
|
|
const output = Logger.formatValue({
|
|
payParams: {
|
|
clientSecret: "pi_123_secret_card",
|
|
nested: {
|
|
customerSessionClientSecret: "cuss_123_secret_saved",
|
|
handoffToken: "one-time-checkout-token",
|
|
safe: "order-123",
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(output).toContain("order-123");
|
|
expect(output).not.toContain("secret_card");
|
|
expect(output).not.toContain("secret_saved");
|
|
expect(output).not.toContain("one-time-checkout-token");
|
|
expect(output.match(/\[REDACTED\]/g)?.length).toBeGreaterThanOrEqual(3);
|
|
});
|
|
|
|
it("redacts a secret embedded in a serialized response string", () => {
|
|
const output = Logger.formatValue(
|
|
JSON.stringify({ customerSessionClientSecret: "cuss_1_secret_value" }),
|
|
);
|
|
|
|
expect(output).not.toContain("secret_value");
|
|
expect(output).toContain("[REDACTED]");
|
|
});
|
|
});
|