Skip to content
Snippets Groups Projects
Commit fdf120f1 authored by Sigmund, Dominik's avatar Sigmund, Dominik
Browse files

Merge branch 'develop' into 'main'

Fix tests

See merge request !4
parents ee9dc0fa 67ae9cfa
No related branches found
No related tags found
1 merge request!4Fix tests
Pipeline #8288 passed
......@@ -8,8 +8,9 @@ Sets Headers to a very save style. may be overriden by config.
## Usage
`const security = require('@libs/security')`
`app.use(security(options))`
`const Security = require('@libs/security')`
`const security = new Security(options)`
`app.use(security.setHeaders)`
## Options
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":92,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":92,"startTime":1687945969152,"success":false,"testResults":[{"numFailingTests":0,"numPassingTests":92,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1687945969512,"runtime":338,"slow":false,"start":1687945969174},"testFilePath":"/Users/dominiksigmund/Code/libs/security/index.test.js","failureMessage":null,"testResults":[{"ancestorTitles":["Unit Tests","Header: Cache-Control"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: Cache-Control should set \"no-cache, no-store, must-revalidate\" if not defined","status":"passed","title":"should set \"no-cache, no-store, must-revalidate\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Cache-Control"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Cache-Control should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Cache-Control"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Cache-Control should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: Pragma"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Pragma should set \"no-cache\" if not defined","status":"passed","title":"should set \"no-cache\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Pragma"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Pragma should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Pragma"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: Pragma should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: Expires"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expires should set \"0\" if not defined","status":"passed","title":"should set \"0\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Expires"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expires should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Expires"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expires should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: Content-Security-Policy"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: Content-Security-Policy should set \"default-src 'self'; frame-ancestors 'none'\" if not defined","status":"passed","title":"should set \"default-src 'self'; frame-ancestors 'none'\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Content-Security-Policy"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Content-Security-Policy should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Content-Security-Policy"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Content-Security-Policy should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-XSS-Protection"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: X-XSS-Protection should set \"1; mode=block\" if not defined","status":"passed","title":"should set \"1; mode=block\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-XSS-Protection"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-XSS-Protection should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-XSS-Protection"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-XSS-Protection should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-DNS-Prefetch-Control"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: X-DNS-Prefetch-Control should set \"off\" if not defined","status":"passed","title":"should set \"off\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-DNS-Prefetch-Control"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-DNS-Prefetch-Control should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-DNS-Prefetch-Control"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-DNS-Prefetch-Control should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: Expect-CT"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expect-CT should set \"enforce; max-age=30; report-uri=\"/_report\"\" if not defined","status":"passed","title":"should set \"enforce; max-age=30; report-uri=\"/_report\"\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Expect-CT"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expect-CT should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Expect-CT"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Expect-CT should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-Frame-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Frame-Options should set \"deny\" if not defined","status":"passed","title":"should set \"deny\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-Frame-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Frame-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-Frame-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Frame-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-Powered-By"],"duration":4,"failureMessages":[],"fullName":"Unit Tests Header: X-Powered-By should remove Header if not defined","status":"passed","title":"should remove Header if not defined"},{"ancestorTitles":["Unit Tests","Header: X-Powered-By"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Powered-By should not remove Header if set to false","status":"passed","title":"should not remove Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Strict-Transport-Security"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Strict-Transport-Security should set \"max-age=30\" if not defined","status":"passed","title":"should set \"max-age=30\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Strict-Transport-Security"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Strict-Transport-Security should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Strict-Transport-Security"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: Strict-Transport-Security should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-Download-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Download-Options should set \"noopen\" if not defined","status":"passed","title":"should set \"noopen\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-Download-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Download-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-Download-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Download-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-Content-Type-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Content-Type-Options should set \"nosniff\" if not defined","status":"passed","title":"should set \"nosniff\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-Content-Type-Options"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: X-Content-Type-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-Content-Type-Options"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Content-Type-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Permitted-Cross-Domain-Policies should set \"none\" if not defined","status":"passed","title":"should set \"none\" if not defined"},{"ancestorTitles":["Unit Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Permitted-Cross-Domain-Policies should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: X-Permitted-Cross-Domain-Policies should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Header: Referrer-Policy"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Header: Referrer-Policy should set \"no-referrer\" if not defined","status":"passed","title":"should set \"no-referrer\" if not defined"},{"ancestorTitles":["Unit Tests","Header: Referrer-Policy"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Referrer-Policy should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Unit Tests","Header: Referrer-Policy"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Header: Referrer-Policy should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Unit Tests","Allowed Methods"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Allowed Methods should only allow GET, POST, PUT, DELETE on default","status":"passed","title":"should only allow GET, POST, PUT, DELETE on default"},{"ancestorTitles":["Unit Tests","Allowed Methods"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Allowed Methods should allow given Methods","status":"passed","title":"should allow given Methods"},{"ancestorTitles":["Unit Tests","Defined Routes"],"duration":1,"failureMessages":[],"fullName":"Unit Tests Defined Routes should allow all routes by default","status":"passed","title":"should allow all routes by default"},{"ancestorTitles":["Unit Tests","Defined Routes"],"duration":0,"failureMessages":[],"fullName":"Unit Tests Defined Routes should only allow defined routes if set to true","status":"passed","title":"should only allow defined routes if set to true"},{"ancestorTitles":["Integration Tests","Header: Cache-Control"],"duration":14,"failureMessages":[],"fullName":"Integration Tests Header: Cache-Control should set \"no-cache, no-store, must-revalidate\" if not defined","status":"passed","title":"should set \"no-cache, no-store, must-revalidate\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Cache-Control"],"duration":2,"failureMessages":[],"fullName":"Integration Tests Header: Cache-Control should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Cache-Control"],"duration":4,"failureMessages":[],"fullName":"Integration Tests Header: Cache-Control should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: Pragma"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Pragma should set \"no-cache\" if not defined","status":"passed","title":"should set \"no-cache\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Pragma"],"duration":2,"failureMessages":[],"fullName":"Integration Tests Header: Pragma should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Pragma"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Pragma should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: Expires"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expires should set \"0\" if not defined","status":"passed","title":"should set \"0\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Expires"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expires should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Expires"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expires should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: Content-Security-Policy"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Content-Security-Policy should set \"default-src 'self'; frame-ancestors 'none'\" if not defined","status":"passed","title":"should set \"default-src 'self'; frame-ancestors 'none'\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Content-Security-Policy"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Content-Security-Policy should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Content-Security-Policy"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Content-Security-Policy should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-XSS-Protection"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-XSS-Protection should set \"1; mode=block\" if not defined","status":"passed","title":"should set \"1; mode=block\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-XSS-Protection"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-XSS-Protection should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-XSS-Protection"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-XSS-Protection should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-DNS-Prefetch-Control"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-DNS-Prefetch-Control should set \"off\" if not defined","status":"passed","title":"should set \"off\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-DNS-Prefetch-Control"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-DNS-Prefetch-Control should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-DNS-Prefetch-Control"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-DNS-Prefetch-Control should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: Expect-CT"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expect-CT should set \"enforce; max-age=30; report-uri=\"/_report\"\" if not defined","status":"passed","title":"should set \"enforce; max-age=30; report-uri=\"/_report\"\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Expect-CT"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expect-CT should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Expect-CT"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Expect-CT should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-Frame-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Frame-Options should set \"deny\" if not defined","status":"passed","title":"should set \"deny\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-Frame-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Frame-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-Frame-Options"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: X-Frame-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-Powered-By"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Powered-By should remove Header if not defined","status":"passed","title":"should remove Header if not defined"},{"ancestorTitles":["Integration Tests","Header: X-Powered-By"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Powered-By should not remove Header if set to false","status":"passed","title":"should not remove Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Strict-Transport-Security"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Strict-Transport-Security should set \"max-age=30\" if not defined","status":"passed","title":"should set \"max-age=30\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Strict-Transport-Security"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Strict-Transport-Security should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Strict-Transport-Security"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: Strict-Transport-Security should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-Download-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Download-Options should set \"noopen\" if not defined","status":"passed","title":"should set \"noopen\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-Download-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Download-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-Download-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Download-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-Content-Type-Options"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Content-Type-Options should set \"nosniff\" if not defined","status":"passed","title":"should set \"nosniff\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-Content-Type-Options"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: X-Content-Type-Options should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-Content-Type-Options"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: X-Content-Type-Options should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Permitted-Cross-Domain-Policies should set \"none\" if not defined","status":"passed","title":"should set \"none\" if not defined"},{"ancestorTitles":["Integration Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: X-Permitted-Cross-Domain-Policies should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: X-Permitted-Cross-Domain-Policies"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: X-Permitted-Cross-Domain-Policies should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Header: Referrer-Policy"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Referrer-Policy should set \"no-referrer\" if not defined","status":"passed","title":"should set \"no-referrer\" if not defined"},{"ancestorTitles":["Integration Tests","Header: Referrer-Policy"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Header: Referrer-Policy should not set Header if set to false","status":"passed","title":"should not set Header if set to false"},{"ancestorTitles":["Integration Tests","Header: Referrer-Policy"],"duration":0,"failureMessages":[],"fullName":"Integration Tests Header: Referrer-Policy should set given values","status":"passed","title":"should set given values"},{"ancestorTitles":["Integration Tests","Allowed Methods"],"duration":8,"failureMessages":[],"fullName":"Integration Tests Allowed Methods should only allow GET, POST, PUT, DELETE on default","status":"passed","title":"should only allow GET, POST, PUT, DELETE on default"},{"ancestorTitles":["Integration Tests","Allowed Methods"],"duration":2,"failureMessages":[],"fullName":"Integration Tests Allowed Methods should allow given Methods","status":"passed","title":"should allow given Methods"},{"ancestorTitles":["Integration Tests","Defined Routes"],"duration":2,"failureMessages":[],"fullName":"Integration Tests Defined Routes should allow all routes by default","status":"passed","title":"should allow all routes by default"},{"ancestorTitles":["Integration Tests","Defined Routes"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Defined Routes should only allow defined routes if set to true","status":"passed","title":"should only allow defined routes if set to true"},{"ancestorTitles":["Integration Tests","Defined Routes"],"duration":1,"failureMessages":[],"fullName":"Integration Tests Defined Routes should not allow any routes if set to true but no routes given","status":"passed","title":"should not allow any routes if set to true but no routes given"},{"ancestorTitles":["Integration Tests","Defined Routes"],"duration":2,"failureMessages":[],"fullName":"Integration Tests Defined Routes should allow regex route if set","status":"passed","title":"should allow regex route if set"}]}],"config":{"bail":0,"changedFilesWithAncestor":false,"ci":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"/Users/dominiksigmund/Code/libs/security/docs/coverage","coverageProvider":"babel","coverageReporters":["json","lcov","text","clover","html"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":11,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"openHandlesTimeout":1000,"passWithNoTests":false,"projects":[],"reporters":[["default",{}],["/Users/dominiksigmund/Code/libs/security/node_modules/jest-html-reporters/index.js",{"publicPath":"./docs","filename":"test-report.html","pageTitle":"Module :: Security :: Test Results"}]],"rootDir":"/Users/dominiksigmund/Code/libs/security","runTestsByPath":false,"seed":-1569411671,"skipFilter":false,"snapshotFormat":{"escapeString":false,"printBasicPrototype":false},"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/opt/homebrew/lib/node_modules/jest/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true,"workerThreads":false,"coverageLinkPath":"coverage/lcov-report/index.html"},"endTime":1687945969518,"_reporterOptions":{"publicPath":"./docs","filename":"test-report.html","expand":false,"pageTitle":"Module :: Security :: Test Results","hideIcon":false,"testCommand":"","openReport":false,"failureMessageOnly":0,"enableMergeData":false,"dataMergeLevel":1,"inlineSource":false,"urlForTestFiles":"","darkTheme":false,"includeConsoleLog":false},"logInfoMapping":{},"attachInfos":{}})
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -2,16 +2,17 @@ const express = require('express')
const fs = require('fs')
const http = require('http')
const https = require('https')
const security = require('../../index')
const Security = require('../../index')
const security = Security({
onlyDefinedRoutes: true,
definedRoutes: ['/', 'REGEX:\\/id\\/\\d{1,}']
})
const app = express()
app.use(security({
onlyDefinedRoutes: true,
definedRoutes: ['/', 'REGEX:\\/id\\/\\d{1,}']
}))
app.use(security.setHeaders)
app.get('/', function (req, res) {
res.send('Hello World!')
......
const express = require('express')
const security = require('../../index')
const app = express()
app.use(security({
const Security = require('../../index')
const security = Security({
CacheControl: 'public, max-age=9999999999',
Pragma: false,
Expires: 'Wed, 21 Oct 2090 07:28:00 GMT',
......@@ -19,7 +16,11 @@ app.use(security({
ReferrerPolicy: 'unsafe-url',
allowedMethods: ['HEAD', 'GET', 'OPTIONS'],
onlyDefinedRoutes: false
}))
})
const app = express()
app.use(security.setHeaders)
app.get('/', function (req, res) {
res.send('Hello World!')
......
......@@ -4,5 +4,5 @@ export = Security;
declare class Security {
constructor();
setHeaders(req: express.Request, res: express.Response, next: express.NextFunctiont): void;
setHeaders(): void;
}
......@@ -3,9 +3,11 @@ module.exports = function(options = {}) {
let security = {}
security.options = options
security.setHeaders = function(req, res, next) {
if(!this.options) options = {}
else options = this.options
if(!security.options) options = {}
else options = security.options
if (typeof options.CacheControl === 'undefined') {
options.CacheControl = 'no-cache, no-store, must-revalidate'
......
......@@ -62,7 +62,7 @@ describe('Unit Tests', () => {
describe('Header: X-Powered-By', () => {
it('should remove Header if not defined', (done) => {
let sec = security()
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._headers['X-Powered-By']).toBeUndefined()
done()
})
......@@ -71,7 +71,7 @@ describe('Unit Tests', () => {
let options = {}
options.XPoweredBy = false
let sec = security(options)
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._headers['X-Powered-By']).toBeDefined()
done()
})
......@@ -87,10 +87,10 @@ describe('Unit Tests', () => {
it('should only allow GET, POST, PUT, DELETE on default', (done) => {
let sec = security()
mockReq._setMethod('GET')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(200)
mockReq._setMethod('HEAD')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(405)
done()
})
......@@ -101,10 +101,10 @@ describe('Unit Tests', () => {
allowedMethods: ['POST']
})
mockReq._setMethod('POST')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(200)
mockReq._setMethod('GET')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(405)
done()
})
......@@ -115,10 +115,10 @@ describe('Unit Tests', () => {
it('should allow all routes by default', (done) => {
let sec = security()
mockReq._setUrl('/')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(200)
mockReq._setUrl('/test')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(200)
done()
})
......@@ -130,10 +130,10 @@ describe('Unit Tests', () => {
definedRoutes: ['/']
})
mockReq._setUrl('/')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(200)
mockReq._setUrl('/test')
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._status).toBe(405)
done()
})
......@@ -290,7 +290,7 @@ function headerUnitTest (header, headerOption, defaultValue) {
describe('Header: ' + header, () => {
it('should set "' + defaultValue + '" if not defined', (done) => {
let sec = security()
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._headers[header]).toBe(defaultValue)
done()
})
......@@ -299,7 +299,7 @@ function headerUnitTest (header, headerOption, defaultValue) {
let options = {}
options[headerOption] = false
let sec = security(options)
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._headers[header]).toBeUndefined()
done()
})
......@@ -308,7 +308,7 @@ function headerUnitTest (header, headerOption, defaultValue) {
let options = {}
options[headerOption] = 'somevalue'
let sec = security(options)
sec(mockReq, mockRes, () => {
sec.setHeaders(mockReq, mockRes, () => {
expect(mockRes._headers[header]).toBe('somevalue')
done()
})
......@@ -355,7 +355,8 @@ function headerIntegrationTest (header, headerOption, defaultValue) {
}
function startUpServer(options) {
app = express()
app.use(security(options))
let sec = security(options)
app.use(sec.setHeaders)
app.get('/', function (req, res) {
res.send('Hello World!')
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment