|
@@ -48,6 +48,7 @@ describe "TokenAccessController", ->
|
|
|
@TokenAccessHandler.addReadAndWriteUserToProject = sinon.stub()
|
|
@TokenAccessHandler.addReadAndWriteUserToProject = sinon.stub()
|
|
|
.callsArgWith(2, null)
|
|
.callsArgWith(2, null)
|
|
|
@ProjectController.loadEditor = sinon.stub()
|
|
@ProjectController.loadEditor = sinon.stub()
|
|
|
|
|
+ @AuthenticationController._setRedirectInSession = sinon.stub()
|
|
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
|
|
|
|
|
|
it 'should try to find a project with this token', (done) ->
|
|
it 'should try to find a project with this token', (done) ->
|
|
@@ -159,6 +160,7 @@ describe "TokenAccessController", ->
|
|
|
.callsArgWith(2, null)
|
|
.callsArgWith(2, null)
|
|
|
@ProjectController.loadEditor = sinon.stub()
|
|
@ProjectController.loadEditor = sinon.stub()
|
|
|
@TokenAccessHandler.grantSessionTokenAccess = sinon.stub()
|
|
@TokenAccessHandler.grantSessionTokenAccess = sinon.stub()
|
|
|
|
|
+ @AuthenticationController._setRedirectInSession = sinon.stub()
|
|
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
|
|
|
|
|
|
it 'should not add the user to the project with read-write access', (done) ->
|
|
it 'should not add the user to the project with read-write access', (done) ->
|
|
@@ -176,6 +178,11 @@ describe "TokenAccessController", ->
|
|
|
expect(@ProjectController.loadEditor.calledWith(@req, @res, @next)).to.equal false
|
|
expect(@ProjectController.loadEditor.calledWith(@req, @res, @next)).to.equal false
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ it 'should set redirect in session', (done) ->
|
|
|
|
|
+ expect(@AuthenticationController._setRedirectInSession.callCount).to.equal 1
|
|
|
|
|
+ expect(@AuthenticationController._setRedirectInSession.calledWith(@req)).to.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
it 'should redirect to restricted page', (done) ->
|
|
it 'should redirect to restricted page', (done) ->
|
|
|
expect(@res.redirect.callCount).to.equal 1
|
|
expect(@res.redirect.callCount).to.equal 1
|
|
|
expect(@res.redirect.calledWith('/restricted')).to.equal true
|
|
expect(@res.redirect.calledWith('/restricted')).to.equal true
|