mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-06 23:44:36 +00:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { redactJsonValue, redactUrl } from "../src/core/bug-report.ts";
|
|
|
|
describe("bug report redaction", () => {
|
|
it("removes URL credentials and secret query parameters", () => {
|
|
expect(redactUrl("https://user:pass@proxy.example.com:8080/")).toBe("https://proxy.example.com:8080/");
|
|
expect(redactUrl("git:https://pat@github.com/org/repo")).toBe("git:https://github.com/org/repo");
|
|
expect(redactUrl("https://api.example/v1?api-key=abc&model=x")).toBe(
|
|
"https://api.example/v1?api-key=%3Credacted%3E&model=x",
|
|
);
|
|
});
|
|
|
|
it("redacts nested secret values without hiding token counts", () => {
|
|
expect(
|
|
redactJsonValue({
|
|
apiKey: "sk-123",
|
|
headers: { Authorization: "Bearer x", "X-Trace": "1" },
|
|
compaction: { reserveTokens: 16_384, keepRecentTokens: 20_000 },
|
|
baseUrl: "https://me:secret@example.com/",
|
|
}),
|
|
).toEqual({
|
|
apiKey: "<redacted>",
|
|
headers: { Authorization: "<redacted>", "X-Trace": "1" },
|
|
compaction: { reserveTokens: 16_384, keepRecentTokens: 20_000 },
|
|
baseUrl: "https://example.com/",
|
|
});
|
|
});
|
|
});
|