From 1fd52e8fc886c7e8bb097b9714515cc252f17ea3 Mon Sep 17 00:00:00 2001 From: dojineko Date: Fri, 2 Feb 2018 11:51:16 +0900 Subject: [PATCH] add test case --- test/basic.ssr.csp.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/basic.ssr.csp.test.js b/test/basic.ssr.csp.test.js index 8eba5c194d..1ae4f359e6 100644 --- a/test/basic.ssr.csp.test.js +++ b/test/basic.ssr.csp.test.js @@ -101,3 +101,22 @@ test.serial('Contain Content-Security-Policy header, when csp.policies set', asy await nuxt.close() }) + +test.serial('Contain Content-Security-Policy header, when csp.policies.script-src is not set', async t => { + const cspOption = { + enabled: true, + policies: { + 'default-src': [`'none'`] + } + } + + const nuxt = await startCSPTestServer(t, cspOption) + const { headers } = await rp(url('/stateless'), { + resolveWithFullResponse: true + }) + + t.regex(headers['content-security-policy'], /default-src 'none'/) + t.regex(headers['content-security-policy'], /script-src 'self' 'sha256-.*'/) + + await nuxt.close() +})