Disable GA and Disqus in default CSP
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
@@ -22,8 +22,8 @@ module.exports = {
|
|||||||
directives: {
|
directives: {
|
||||||
},
|
},
|
||||||
addDefaults: true,
|
addDefaults: true,
|
||||||
addDisqus: true,
|
addDisqus: false,
|
||||||
addGoogleAnalytics: true,
|
addGoogleAnalytics: false,
|
||||||
upgradeInsecureRequests: 'auto',
|
upgradeInsecureRequests: 'auto',
|
||||||
reportURI: undefined
|
reportURI: undefined
|
||||||
},
|
},
|
||||||
|
|||||||
22
test/csp.js
22
test/csp.js
@@ -68,6 +68,15 @@ describe('Content security policies', function () {
|
|||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Enable Google Analytics', function () {
|
||||||
|
const testconfig = defaultConfig
|
||||||
|
testconfig.csp.addGoogleAnalytics = true
|
||||||
|
mock('../lib/config', testconfig)
|
||||||
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
||||||
|
})
|
||||||
|
|
||||||
it('Disable Disqus', function () {
|
it('Disable Disqus', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addDisqus = false
|
testconfig.csp.addDisqus = false
|
||||||
@@ -81,6 +90,19 @@ describe('Content security policies', function () {
|
|||||||
assert(!csp.computeDirectives().fontSrc.includes('https://*.disquscdn.com'))
|
assert(!csp.computeDirectives().fontSrc.includes('https://*.disquscdn.com'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Enable Disqus', function () {
|
||||||
|
const testconfig = defaultConfig
|
||||||
|
testconfig.csp.addDisqus = true
|
||||||
|
mock('../lib/config', testconfig)
|
||||||
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('https://disqus.com'))
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('https://*.disqus.com'))
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('https://*.disquscdn.com'))
|
||||||
|
assert(csp.computeDirectives().styleSrc.includes('https://*.disquscdn.com'))
|
||||||
|
assert(csp.computeDirectives().fontSrc.includes('https://*.disquscdn.com'))
|
||||||
|
})
|
||||||
|
|
||||||
it('Include dropbox if configured', function () {
|
it('Include dropbox if configured', function () {
|
||||||
const testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.dropbox.appKey = 'hedgedoc'
|
testconfig.dropbox.appKey = 'hedgedoc'
|
||||||
|
|||||||
Reference in New Issue
Block a user