mirror of
https://github.com/outline/outline.git
synced 2026-12-02 09:42:07 +03:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { ErrorEvent } from "@sentry/node";
|
|
import { scrubRequest } from "./sentry";
|
|
|
|
describe("scrubRequest", () => {
|
|
it("should filter sensitive query parameters and headers", () => {
|
|
const event: ErrorEvent = {
|
|
type: undefined,
|
|
request: {
|
|
url: "https://app.getoutline.com/auth/google.callback?code=secret&state=jwt&iss=google&access_token=abc&sig=xyz",
|
|
query_string:
|
|
"code=secret&state=jwt&iss=google&access_token=abc&sig=xyz",
|
|
headers: { authorization: "Bearer x", "user-agent": "test" },
|
|
},
|
|
};
|
|
|
|
scrubRequest(event);
|
|
|
|
const filtered =
|
|
"code=%5BFiltered%5D&state=%5BFiltered%5D&iss=google&access_token=%5BFiltered%5D&sig=%5BFiltered%5D";
|
|
expect(event.request).toEqual({
|
|
url: `https://app.getoutline.com/auth/google.callback?${filtered}`,
|
|
query_string: filtered,
|
|
headers: { "user-agent": "test" },
|
|
});
|
|
});
|
|
|
|
it("should leave requests without a query string unchanged", () => {
|
|
const event: ErrorEvent = {
|
|
type: undefined,
|
|
request: { url: "https://app.getoutline.com/api/documents.info" },
|
|
};
|
|
|
|
scrubRequest(event);
|
|
|
|
expect(event.request).toEqual({
|
|
url: "https://app.getoutline.com/api/documents.info",
|
|
});
|
|
});
|
|
});
|