mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Begin testing UserSessionsManager
.
This commit is contained in:
parent
5a1af9a5f3
commit
a869c99c60
2 changed files with 49 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
||||||
Settings = require('settings-sharelatex')
|
Settings = require('settings-sharelatex')
|
||||||
redis = require('redis-sharelatex')
|
redis = require('redis-sharelatex')
|
||||||
rclient = redis.createClient(Settings.redis.web)
|
|
||||||
logger = require("logger-sharelatex")
|
logger = require("logger-sharelatex")
|
||||||
Async = require('async')
|
Async = require('async')
|
||||||
|
|
||||||
|
rclient = redis.createClient(Settings.redis.web)
|
||||||
|
|
||||||
module.exports = UserSessionsManager =
|
module.exports = UserSessionsManager =
|
||||||
|
|
||||||
_sessionSetKey: (user) ->
|
_sessionSetKey: (user) ->
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
sinon = require('sinon')
|
||||||
|
chai = require('chai')
|
||||||
|
should = chai.should()
|
||||||
|
expect = chai.expect
|
||||||
|
modulePath = "../../../../app/js/Features/User/UserSessionsManager.js"
|
||||||
|
SandboxedModule = require('sandboxed-module')
|
||||||
|
|
||||||
|
describe 'UserSessionsManager', ->
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
@user =
|
||||||
|
_id: "abcd"
|
||||||
|
email: "user@example.com"
|
||||||
|
@sessionId = 'some_session_id'
|
||||||
|
@rclient =
|
||||||
|
multi: () => @rclient
|
||||||
|
exec: sinon.stub()
|
||||||
|
get: sinon.stub().returns(@rclient)
|
||||||
|
sadd: sinon.stub().returns(@rclient)
|
||||||
|
srem: sinon.stub().returns(@rclient)
|
||||||
|
smembers: sinon.stub().returns(@rclient)
|
||||||
|
expire: sinon.stub().returns(@rclient)
|
||||||
|
@redis =
|
||||||
|
createClient: () -> @rclient
|
||||||
|
@logger =
|
||||||
|
err: sinon.stub()
|
||||||
|
error: sinon.stub()
|
||||||
|
log: sinon.stub()
|
||||||
|
@settings =
|
||||||
|
redis:
|
||||||
|
web: {}
|
||||||
|
@UserSessionsManager = SandboxedModule.require modulePath, requires:
|
||||||
|
"redis-sharelatex": @redis
|
||||||
|
"logger-sharelatex": @logger
|
||||||
|
"settings-sharelatex": @settings
|
||||||
|
|
||||||
|
describe '_sessionSetKey', ->
|
||||||
|
|
||||||
|
it 'should build the correct key', ->
|
||||||
|
result = @UserSessionsManager._sessionSetKey(@user)
|
||||||
|
result.should.equal 'UserSessions:abcd'
|
||||||
|
|
||||||
|
describe '_sessionKey', ->
|
||||||
|
|
||||||
|
it 'should build the correct key', ->
|
||||||
|
result = @UserSessionsManager._sessionKey(@sessionId)
|
||||||
|
result.should.equal 'sess:some_session_id'
|
Loading…
Reference in a new issue