mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05:00
Disable GA and Disqus in default CSP
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
5aeb7f4d0f
commit
52231f688d
2 changed files with 24 additions and 2 deletions
|
@ -22,8 +22,8 @@ module.exports = {
|
|||
directives: {
|
||||
},
|
||||
addDefaults: true,
|
||||
addDisqus: true,
|
||||
addGoogleAnalytics: true,
|
||||
addDisqus: false,
|
||||
addGoogleAnalytics: false,
|
||||
upgradeInsecureRequests: 'auto',
|
||||
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'))
|
||||
})
|
||||
|
||||
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 () {
|
||||
const testconfig = defaultConfig
|
||||
testconfig.csp.addDisqus = false
|
||||
|
@ -81,6 +90,19 @@ describe('Content security policies', function () {
|
|||
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 () {
|
||||
const testconfig = defaultConfig
|
||||
testconfig.dropbox.appKey = 'hedgedoc'
|
||||
|
|
Loading…
Reference in a new issue