mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #7961 from overleaf/jpa-shorter-clsi-persistence
[web] lower clsi persistence duration GitOrigin-RevId: 72929de084c5c5aac5f2382ad91a7665e96742a8
This commit is contained in:
@@ -129,6 +129,12 @@ module.exports = function (backendGroup) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getTTLInSeconds(clsiServerId) {
|
||||||
|
return (clsiServerId || '').includes('-reg-')
|
||||||
|
? Settings.clsiCookie.ttlInSecondsRegular
|
||||||
|
: Settings.clsiCookie.ttlInSeconds
|
||||||
|
},
|
||||||
|
|
||||||
setServerId(
|
setServerId(
|
||||||
project_id,
|
project_id,
|
||||||
user_id,
|
user_id,
|
||||||
@@ -148,7 +154,7 @@ module.exports = function (backendGroup) {
|
|||||||
// We don't get a cookie back if it hasn't changed
|
// We don't get a cookie back if it hasn't changed
|
||||||
return rclient.expire(
|
return rclient.expire(
|
||||||
this.buildKey(project_id, user_id),
|
this.buildKey(project_id, user_id),
|
||||||
Settings.clsiCookie.ttl,
|
this._getTTLInSeconds(previous),
|
||||||
err => callback(err, undefined)
|
err => callback(err, undefined)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -178,7 +184,7 @@ module.exports = function (backendGroup) {
|
|||||||
}
|
}
|
||||||
rclient.setex(
|
rclient.setex(
|
||||||
this.buildKey(project_id, user_id),
|
this.buildKey(project_id, user_id),
|
||||||
Settings.clsiCookie.ttl,
|
this._getTTLInSeconds(serverId),
|
||||||
serverId,
|
serverId,
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ describe('ClsiCookieManager', function () {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
clsiCookie: {
|
clsiCookie: {
|
||||||
ttl: Math.random(),
|
ttlInSeconds: Math.random().toString(),
|
||||||
|
ttlInSecondsRegular: Math.random().toString(),
|
||||||
key: 'coooookie',
|
key: 'coooookie',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -172,7 +173,7 @@ describe('ClsiCookieManager', function () {
|
|||||||
this.redis.setex
|
this.redis.setex
|
||||||
.calledWith(
|
.calledWith(
|
||||||
`clsiserver:${this.project_id}:${this.user_id}`,
|
`clsiserver:${this.project_id}:${this.user_id}`,
|
||||||
this.settings.clsiCookie.ttl,
|
this.settings.clsiCookie.ttlInSeconds,
|
||||||
'clsi-8'
|
'clsi-8'
|
||||||
)
|
)
|
||||||
.should.equal(true)
|
.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) {
|
it('should return the server id', function (done) {
|
||||||
return this.ClsiCookieManager.setServerId(
|
return this.ClsiCookieManager.setServerId(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
@@ -260,7 +282,7 @@ describe('ClsiCookieManager', function () {
|
|||||||
this.redis_secondary.setex
|
this.redis_secondary.setex
|
||||||
.calledWith(
|
.calledWith(
|
||||||
`clsiserver:${this.project_id}:${this.user_id}`,
|
`clsiserver:${this.project_id}:${this.user_id}`,
|
||||||
this.settings.clsiCookie.ttl,
|
this.settings.clsiCookie.ttlInSeconds,
|
||||||
'clsi-8'
|
'clsi-8'
|
||||||
)
|
)
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user