import test from "node:test";
import assert from "node:assert/strict";
import { redact, trunc } from "../lib/log.js";
test("redact masks Bearer tokens", () => {
    const input = "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.payload.signature";
    assert.match(redact(input), /Bearer <REDACTED>/);
    assert.doesNotMatch(redact(input), /eyJhbGciOiJIUzI1NiJ9/);
});
test("redact masks access_token query strings", () => {
    const input = "https://login.microsoftonline.com/cb?access_token=abc123_secret&state=xyz";
    const out = redact(input);
    assert.match(out, /access_token=<REDACTED>/);
    assert.doesNotMatch(out, /abc123_secret/);
    // Other query params survive.
    assert.match(out, /state=xyz/);
});
test("redact is a no-op on safe text", () => {
    assert.equal(redact("user logged in account=abc count=5"), "user logged in account=abc count=5");
});
test("redact handles multiple Bearer tokens in one string", () => {
    const input = "first Bearer aaaaa second Bearer bbbbb";
    const out = redact(input);
    assert.match(out, /first Bearer <REDACTED> second Bearer <REDACTED>/);
});
test("trunc preserves short values verbatim", () => {
    assert.equal(trunc("short", 10), "short");
});
test("trunc shortens long values with ellipsis", () => {
    assert.equal(trunc("abcdefghijklmnop", 10), "abcdefghi…");
});
//# sourceMappingURL=log.test.js.map