forked from Lilly-Protocol/lily-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity-headers.test.ts
More file actions
23 lines (19 loc) · 842 Bytes
/
Copy pathsecurity-headers.test.ts
File metadata and controls
23 lines (19 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import nextConfig from "../../next.config";
describe("Next.js security headers", () => {
it("applies the security policy to every route", async () => {
const rules = await nextConfig.headers?.();
expect(rules).toHaveLength(1);
expect(rules?.[0]?.source).toBe("/:path*");
const headers = Object.fromEntries(
(rules?.[0]?.headers ?? []).map(({ key, value }) => [key, value]),
);
expect(headers).toMatchObject({
"Content-Security-Policy": expect.stringContaining("default-src 'self'"),
"Referrer-Policy": "strict-origin-when-cross-origin",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
});
expect(headers["Content-Security-Policy"]).toContain("frame-ancestors 'none'");
expect(headers["Content-Security-Policy"]).toContain("object-src 'none'");
});
});