forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity-headers.test.ts
More file actions
34 lines (27 loc) · 1.19 KB
/
Copy pathsecurity-headers.test.ts
File metadata and controls
34 lines (27 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import request from "supertest";
import { describe, expect, it } from "vitest";
import { createApp } from "../src/app";
describe("security headers (helmet)", () => {
const app = createApp();
it("sets strict-transport-security header", async () => {
const response = await request(app).get("/");
expect(response.headers["strict-transport-security"]).toBeDefined();
expect(response.headers["strict-transport-security"]).toContain("max-age=");
});
it("sets x-content-type-options to nosniff", async () => {
const response = await request(app).get("/");
expect(response.headers["x-content-type-options"]).toBe("nosniff");
});
it("sets x-frame-options to SAMEORIGIN", async () => {
const response = await request(app).get("/");
expect(response.headers["x-frame-options"]).toBe("SAMEORIGIN");
});
it("removes x-powered-by header", async () => {
const response = await request(app).get("/");
expect(response.headers["x-powered-by"]).toBeUndefined();
});
it("sets cross-origin-resource-policy to cross-origin", async () => {
const response = await request(app).get("/");
expect(response.headers["cross-origin-resource-policy"]).toBe("cross-origin");
});
});