Node.js based forum software built for the modern web
test: added test for session id reroll on login
Julian Lama3a7ab3ae1c8
diff --git a/test/authentication.js b/test/authentication.jsindex 96c353ab61..627cc7462e 100644--- a/test/authentication.js+++ b/test/authentication.js@@ -224,6 +224,19 @@ describe('authentication', () => {});});+ it('should regenerate the session identifier on successful login', async () => {+ const login = util.promisify(helpers.loginUser);+ const logout = util.promisify(helpers.logoutUser);+ const matchRegexp = /express\.sid=s%3A(.+?);/;++ const sid = String(jar._jar.store.idx.localhost['/']['express.sid']).match(matchRegexp)[1];+ await logout(jar);+ const newJar = await login('regular', 'regularpwd');+ const newSid = String(newJar._jar.store.idx.localhost['/']['express.sid']).match(matchRegexp)[1];++ assert.notStrictEqual(newSid, sid);+ });+it('should revoke all sessions', (done) => {const socketAdmin = require('../src/socket.io/admin');db.sortedSetCard(`uid:${regularUid}:sessions`, (err, count) => {