forked from Lilly-Protocol/lily-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelmet-headers.test.ts
More file actions
39 lines (32 loc) · 1.5 KB
/
Copy pathhelmet-headers.test.ts
File metadata and controls
39 lines (32 loc) · 1.5 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
35
36
37
38
39
import { describe, it, expect } from "vitest";
import request from "supertest";
import { createApp } from "../src/app";
describe("Helmet security headers (issue #135)", () => {
const app = createApp();
it("should set X-Content-Type-Options: nosniff", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["x-content-type-options"]).toBe("nosniff");
});
it("should set Content-Security-Policy header", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["content-security-policy"]).toBeDefined();
expect(typeof res.headers["content-security-policy"]).toBe("string");
expect(res.headers["content-security-policy"].length).toBeGreaterThan(0);
});
it("should set X-Frame-Options header", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["x-frame-options"]).toBeDefined();
});
it("should set Referrer-Policy header", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["referrer-policy"]).toBeDefined();
});
it("should not include X-Powered-By header", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["x-powered-by"]).toBeUndefined();
});
it("should set Cross-Origin-Resource-Policy: cross-origin (intentional override)", async () => {
const res = await request(app).get("/api/v1/health");
expect(res.headers["cross-origin-resource-policy"]).toBe("cross-origin");
});
});