|
@@ -431,6 +431,19 @@ describe "TokenAccessController", ->
|
|
|
expect(@next.callCount).to.equal 1
|
|
expect(@next.callCount).to.equal 1
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ describe 'when project does not exist on v1', ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
|
|
|
|
+ exists: false
|
|
|
|
|
+ exported: false
|
|
|
|
|
+ })
|
|
|
|
|
+ @TokenAccessController.readAndWriteToken @req, @res, @next
|
|
|
|
|
+
|
|
|
|
|
+ it 'should call next with a not-found error', (done) ->
|
|
|
|
|
+ expect(@next.callCount).to.equal 1
|
|
|
|
|
+ expect(@next.calledWith(new Errors.NotFoundError())).to.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
describe 'when token access is off, but user has higher access anyway', ->
|
|
describe 'when token access is off, but user has higher access anyway', ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@req = new MockRequest()
|
|
@req = new MockRequest()
|
|
@@ -1152,6 +1165,19 @@ describe "TokenAccessController", ->
|
|
|
)).to.equal true
|
|
)).to.equal true
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ describe 'when project does not exist on v1', ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
|
|
|
|
+ exists: false,
|
|
|
|
|
+ exported: false
|
|
|
|
|
+ })
|
|
|
|
|
+ @TokenAccessController.readOnlyToken @req, @res, @next
|
|
|
|
|
+
|
|
|
|
|
+ it 'should call next with not found error', (done) ->
|
|
|
|
|
+ expect(@next.callCount).to.equal 1
|
|
|
|
|
+ expect(@next.calledWith(new Errors.NotFoundError())).to.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
describe 'anonymous user', ->
|
|
describe 'anonymous user', ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@AuthenticationController.getLoggedInUserId = sinon.stub().returns(null)
|
|
@AuthenticationController.getLoggedInUserId = sinon.stub().returns(null)
|