UNPKG

alagarr

Version:

Alagarr is a request-response helper library that removes the boilerplate from your Node.js serverless functions and helps make your code portable.

32 lines (31 loc) 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const requests_1 = require("../../../test/fixtures/requests"); const csp_1 = __importDefault(require("./csp")); const mockRequest = Object.assign({}, requests_1.get); const mockOptions = { cspPolicies: { foo: 'bar', 'frame-ancestors': "'none'", }, }; describe('Response CSP headers', () => { test('are set correctly', () => { const { headers } = csp_1.default({ body: 'foobar', headers: { 'content-type': 'text/plain', }, statusCode: 200, }, mockRequest, mockOptions); expect(headers['referrer-policy']).toBeTruthy(); expect(headers['x-content-type-options']).toBeTruthy(); expect(headers['x-xss-protection']).toBeTruthy(); expect(headers['x-frame-options']).toBeTruthy(); expect(headers['content-security-policy']).toBeTruthy(); expect(headers['content-security-policy'].includes('foo bar;')).toBe(true); }); });