From 676073976175c22eed34afcdcbc2ba8ebbc5a2ca Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 8 Aug 2021 18:19:37 +0200 Subject: [PATCH] Fix CSP tests by filtering out empty array fields In 25f5fd2a the `media-src`, `child-src` and `connect-src` settings were removed, as they are filled with the `default-src` automatically. This caused a bug in the test code, as it now tried to access a nonexistent field of `unextendedCSP`. This commit adds a filter that removes the empty array field before converting to a string. Signed-off-by: David Mehren --- test/csp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/csp.js b/test/csp.js index 154120221..9257eed96 100644 --- a/test/csp.js +++ b/test/csp.js @@ -144,7 +144,7 @@ describe('Content security policies', function () { const variations = ['default', 'script', 'img', 'style', 'font', 'object', 'media', 'child', 'connect'] for (let i = 0; i < variations.length; i++) { - assert.strictEqual(csp.computeDirectives()[variations[i] + 'Src'].toString(), ['https://' + variations[i] + '.example.com'].concat(unextendedCSP[variations[i] + 'Src']).toString()) + assert.strictEqual(csp.computeDirectives()[variations[i] + 'Src'].toString(), ['https://' + variations[i] + '.example.com'].concat(unextendedCSP[variations[i] + 'Src']).filter(x => x != null).toString()) } })