From 62629413a767be3370eb0a3508ad4c3adfe474ba Mon Sep 17 00:00:00 2001 From: picklesrus Date: Mon, 3 Aug 2020 14:45:34 -0400 Subject: [PATCH] Revert "Make the cookie library set the SameSite cookie value to strict by default" --- src/lib/jar.js | 3 +-- test/unit/lib/jar.test.js | 53 --------------------------------------- 2 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 test/unit/lib/jar.test.js diff --git a/src/lib/jar.js b/src/lib/jar.js index 7947da579..afcc1b277 100644 --- a/src/lib/jar.js +++ b/src/lib/jar.js @@ -78,8 +78,7 @@ const Jar = { set: (name, value, opts) => { opts = opts || {}; defaults(opts, { - expires: new Date(new Date().setYear(new Date().getFullYear() + 1)), - sameSite: 'Strict' // cookie library requires this capitialization of sameSite + expires: new Date(new Date().setYear(new Date().getFullYear() + 1)) }); opts.path = '/'; const obj = cookie.serialize(name, value, opts); diff --git a/test/unit/lib/jar.test.js b/test/unit/lib/jar.test.js deleted file mode 100644 index e3c63b91f..000000000 --- a/test/unit/lib/jar.test.js +++ /dev/null @@ -1,53 +0,0 @@ -const jar = require('../../../src/lib/jar'); -const cookie = require('cookie'); - -jest.mock('cookie', () => ({serialize: jest.fn()})); -describe('unit test lib/jar.js', () => { - - test('simple set test with no opts', () => { - jar.set('name', 'value'); - expect(cookie.serialize).toHaveBeenCalled(); - expect(cookie.serialize).toHaveBeenCalledWith('name', 'value', - expect.objectContaining({ - path: '/', - sameSite: 'Strict', - expires: expect.anything() // not specifically matching the date because it is hard to mock - })); - }); - test('test with opts', () => { - jar.set('a', 'b', {option: 'one'}); - expect(cookie.serialize).toHaveBeenCalled(); - expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', - expect.objectContaining({ - option: 'one', - path: '/', - sameSite: 'Strict', - expires: expect.anything() // not specifically matching the date because it is hard to mock - })); - }); - test('expires opts overrides default', () => { - jar.set('a', 'b', { - option: 'one', - expires: 'someday' - }); - expect(cookie.serialize).toHaveBeenCalled(); - expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', - expect.objectContaining({ - option: 'one', - path: '/', - expires: 'someday' - })); - }); - test('sameSite opts overrides default', () => { - jar.set('a', 'b', { - option: 'one', - sameSite: 'override' - }); - expect(cookie.serialize).toHaveBeenCalled(); - expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', - expect.objectContaining({ - option: 'one', - sameSite: 'override' - })); - }); -});