Merge pull request #509 from sharelatex/ja-fix-clsi-cookie-cluster

Don't try to set the server id if it isn't returned in the response
This commit is contained in:
James Allen 2017-05-19 15:00:18 +01:00 committed by GitHub
commit 76b8fecde9
2 changed files with 8 additions and 1 deletions

View file

@ -44,6 +44,8 @@ module.exports = ClsiCookieManager =
if !clsiCookiesEnabled
return callback()
serverId = ClsiCookieManager._parseServerIdFromResponse(response)
if !serverId? # We don't get a cookie back if it hasn't changed
return callback()
if rclient_secondary?
@_setServerIdInRedis rclient_secondary, project_id, serverId
@_setServerIdInRedis rclient, project_id, serverId, (err) ->

View file

@ -105,13 +105,18 @@ describe "ClsiCookieManager", ->
serverId.should.equal "clsi-8"
done()
it "should not set the server id if clsiCookies are not enabled", (done)->
delete @settings.clsiCookie.key
@ClsiCookieManager = SandboxedModule.require modulePath, requires:@requires
@ClsiCookieManager.setServerId @project_id, @response, (err, serverId)=>
@redisMulti.exec.called.should.equal false
done()
it "should not set the server id there is no server id in the response", (done)->
@ClsiCookieManager._parseServerIdFromResponse = sinon.stub().returns(null)
@ClsiCookieManager.setServerId @project_id, @response, (err, serverId)=>
@redisMulti.exec.called.should.equal false
done()
it "should also set in the secondary if secondary redis is enabled", (done) ->
@redisSecondaryMulti =