-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6828 from uktrade/revert/content-policy
Revert "Merge pull request #6760 from uktrade/fix/content-security-po…
- Loading branch information
Showing
27 changed files
with
418 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ reports | |
.idea/ | ||
*.env | ||
!*.sample.env | ||
!tests.env | ||
npm*.log | ||
yarn-error.log | ||
yarn.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,4 @@ services: | |
MOCK_SSO_TOKEN: 123 | ||
MOCK_SSO_EMAIL_USER_ID: [email protected] | ||
MOCK_SSO_USERNAME: [email protected] | ||
logging: | ||
driver: none | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
const headers = require('../headers') | ||
|
||
const NONCE = 'DUMMY-NONCE' | ||
describe('headers middleware', () => { | ||
context('when the resource is not an asset', () => { | ||
it('should set headers', () => { | ||
const reqMock = { url: '/' } | ||
const resMock = { set: sinon.spy() } | ||
const nextMock = sinon.spy() | ||
|
||
const nonceGenerator = () => NONCE | ||
headers(reqMock, resMock, nextMock) | ||
|
||
describe('headers middleware', () => { | ||
it('should set headers', () => { | ||
const reqMock = { url: '/' } | ||
const resMock = { set: sinon.spy() } | ||
const nextMock = sinon.spy() | ||
|
||
headers(reqMock, resMock, nextMock, { | ||
nonceGenerator, | ||
mode: 'production', | ||
}) | ||
expect(resMock.set.args).to.be.deep.equal([ | ||
['Cache-Control', 'no-cache, no-store, must-revalidate, private'], | ||
['Pragma', 'no-cache'], | ||
['X-Frame-Options', 'DENY'], | ||
['X-Content-Type-Options', 'nosniff'], | ||
['X-XSS-Protection', '1; mode=block'], | ||
['Strict-Transport-Security', 'max-age=15552000'], | ||
]) | ||
|
||
expect(Object.fromEntries(resMock.set.args)).to.be.deep.equal({ | ||
'Content-Security-Policy': [ | ||
`default-src 'self' 'nonce-${NONCE}'`, | ||
`frame-ancestors 'none'`, | ||
`script-src 'self' 'nonce-${NONCE}' https://*.googletagmanager.com`, | ||
`img-src 'self' https://*.google-analytics.com https://*.googletagmanager.com`, | ||
`connect-src 'self' https://*.google-analytics.com https://*.googletagmanager.com https://*.analytics.google.com`, | ||
].join(';'), | ||
'Cache-Control': 'no-cache, no-store', | ||
Pragma: 'no-cache', | ||
'X-Frame-Options': 'DENY', | ||
'X-Content-Type-Options': 'nosniff', | ||
'Strict-Transport-Security': 'max-age=15552000', | ||
expect(nextMock).to.be.called | ||
}) | ||
}) | ||
|
||
expect(nextMock).to.be.called | ||
context('when the resource is an asset', () => { | ||
it('should not set the headers', () => { | ||
const reqMock = { url: '/javascripts/foo.js' } | ||
const resMock = { set: sinon.spy() } | ||
const nextMock = sinon.spy() | ||
|
||
headers(reqMock, resMock, nextMock) | ||
|
||
expect(resMock.set).not.to.be.called | ||
|
||
expect(nextMock).to.be.called | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.