Add test that error messages are redacted

This commit is contained in:
Robert
2023-02-02 10:52:40 +00:00
parent 69b7e04ec0
commit 05d9f9b3a6

View File

@@ -445,6 +445,26 @@ describe("telemetry reporting", () => {
});
});
it("should redact error message contents", async () => {
jest.spyOn(Config, "newTelemetryEnabled").mockReturnValue(true);
await telemetryListener.initialize();
telemetryListener.sendError(
redactableError`test message with secret information: ${42} and more ${"secret"} parts`,
);
expect(sendTelemetryEventSpy).toHaveBeenCalledWith(
"error",
{
message:
"test message with secret information: [REDACTED] and more [REDACTED] parts",
isCanary,
stack: expect.any(String),
},
{},
);
});
async function enableTelemetry(section: string, value: boolean | undefined) {
await workspace
.getConfiguration(section)