Redact settings and remove old ones
This commit is contained in:
parent
45a6b1c115
commit
7fe7ad27aa
1 changed files with 31 additions and 9 deletions
23
frontend/sync-client/src/persistence/settings.test.ts
Normal file
23
frontend/sync-client/src/persistence/settings.test.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { Logger, LogLevel } from "../tracing/logger";
|
||||
import { Settings } from "./settings";
|
||||
|
||||
describe("Settings logging", () => {
|
||||
it("redacts tokens while loading and updating settings", async () => {
|
||||
const logger = new Logger();
|
||||
const settings = new Settings(
|
||||
logger,
|
||||
{ token: "loaded-secret" },
|
||||
async () => {}
|
||||
);
|
||||
await settings.setSettings({ token: "updated-secret" });
|
||||
|
||||
const messages = logger
|
||||
.getMessages(LogLevel.DEBUG)
|
||||
.map((entry) => entry.message)
|
||||
.join("\n");
|
||||
assert.doesNotMatch(messages, /loaded-secret|updated-secret/u);
|
||||
assert.match(messages, /\[REDACTED\]/u);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue