diff --git a/services/web/app/src/Features/Compile/ClsiCookieManager.js b/services/web/app/src/Features/Compile/ClsiCookieManager.js index bb4f9787a5..6ac08d48a6 100644 --- a/services/web/app/src/Features/Compile/ClsiCookieManager.js +++ b/services/web/app/src/Features/Compile/ClsiCookieManager.js @@ -129,6 +129,12 @@ module.exports = function (backendGroup) { ) }, + _getTTLInSeconds(clsiServerId) { + return (clsiServerId || '').includes('-reg-') + ? Settings.clsiCookie.ttlInSecondsRegular + : Settings.clsiCookie.ttlInSeconds + }, + setServerId( project_id, user_id, @@ -148,7 +154,7 @@ module.exports = function (backendGroup) { // We don't get a cookie back if it hasn't changed return rclient.expire( this.buildKey(project_id, user_id), - Settings.clsiCookie.ttl, + this._getTTLInSeconds(previous), err => callback(err, undefined) ) } @@ -178,7 +184,7 @@ module.exports = function (backendGroup) { } rclient.setex( this.buildKey(project_id, user_id), - Settings.clsiCookie.ttl, + this._getTTLInSeconds(serverId), serverId, callback ) diff --git a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js index aeeb4f762c..c2824139fc 100644 --- a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js @@ -45,7 +45,8 @@ describe('ClsiCookieManager', function () { }, }, clsiCookie: { - ttl: Math.random(), + ttlInSeconds: Math.random().toString(), + ttlInSecondsRegular: Math.random().toString(), key: 'coooookie', }, } @@ -172,7 +173,7 @@ describe('ClsiCookieManager', function () { this.redis.setex .calledWith( `clsiserver:${this.project_id}:${this.user_id}`, - this.settings.clsiCookie.ttl, + this.settings.clsiCookie.ttlInSeconds, 'clsi-8' ) .should.equal(true) @@ -181,6 +182,27 @@ describe('ClsiCookieManager', function () { ) }) + it('should set the server id with the regular ttl for reg instance', function (done) { + this.ClsiCookieManager._parseServerIdFromResponse = sinon + .stub() + .returns('clsi-reg-8') + this.ClsiCookieManager.setServerId( + this.project_id, + this.user_id, + 'standard', + this.response, + null, + err => { + expect(this.redis.setex).to.have.been.calledWith( + `clsiserver:${this.project_id}:${this.user_id}`, + this.settings.clsiCookie.ttlInSecondsRegular, + 'clsi-reg-8' + ) + done() + } + ) + }) + it('should return the server id', function (done) { return this.ClsiCookieManager.setServerId( this.project_id, @@ -260,7 +282,7 @@ describe('ClsiCookieManager', function () { this.redis_secondary.setex .calledWith( `clsiserver:${this.project_id}:${this.user_id}`, - this.settings.clsiCookie.ttl, + this.settings.clsiCookie.ttlInSeconds, 'clsi-8' ) .should.equal(true)