From 4904e7f486f4a52e12c17643cf63bc744857fdce Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 5 Mar 2021 08:43:28 +0000 Subject: [PATCH] session: check session_id is present in response --- .../backend/specs/api/httpRouteSessionCreation.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tests/backend/specs/api/httpRouteSessionCreation.js b/src/tests/backend/specs/api/httpRouteSessionCreation.js index db2bd7e7a..c07beb138 100644 --- a/src/tests/backend/specs/api/httpRouteSessionCreation.js +++ b/src/tests/backend/specs/api/httpRouteSessionCreation.js @@ -25,13 +25,16 @@ describe(__filename, function () { if (settings.dbType !== 'dirty') this.skip; this.timeout(100); - for (const endpoint of shouldNotCreateExpressSession) { it(endpoint, async function () { const previousCount = store.length(); await agent.get(endpoint) .expect(200) - .expect(() => { + .expect((res) => { + const hasExpressSessionCookie = + res.headers['set-cookie'][0].indexOf('express_sid'); + assert(hasExpressSessionCookie === -1); + console.error(res); const newCount = store.length(); assert(newCount === previousCount); }) @@ -48,7 +51,11 @@ describe(__filename, function () { it(endpoint, async function () { await agent.get(endpoint) .expect(200) - .expect(() => { + .expect((res) => { + console.error(res.headers['set-cookie']); + const hasExpressSessionCookie = + res.headers['set-cookie'][0].indexOf('express_sid'); + assert(hasExpressSessionCookie !== -1); const newCount = store.length(); console.log(newCount); assert(newCount > previousCount);