mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Revoke invite after each test
This commit is contained in:
parent
e7c1f7f0fc
commit
39fc611964
1 changed files with 16 additions and 3 deletions
|
@ -6,7 +6,7 @@ settings = require "settings-sharelatex"
|
|||
CollaboratorsEmailHandler = require "../../../app/js/Features/Collaborators/CollaboratorsEmailHandler"
|
||||
|
||||
|
||||
createInvite = (projectId, sendingUser, email, callback=(err, invite)->) ->
|
||||
createInvite = (sendingUser, projectId, email, callback=(err, invite)->) ->
|
||||
sendingUser.getCsrfToken (err) ->
|
||||
return callback(err) if err
|
||||
sendingUser.request.post {
|
||||
|
@ -16,8 +16,16 @@ createInvite = (projectId, sendingUser, email, callback=(err, invite)->) ->
|
|||
privileges: 'readAndWrite'
|
||||
}, (err, response, body) ->
|
||||
return callback(err) if err
|
||||
callback(err, body.invite)
|
||||
callback(null, body.invite)
|
||||
|
||||
revokeInvite = (sendingUser, projectId, inviteId, callback=(err)->) ->
|
||||
sendingUser.getCsrfToken (err) ->
|
||||
return callback(err) if err
|
||||
sendingUser.request.delete {
|
||||
url: "/project/#{projectId}/invite/#{inviteId}",
|
||||
}, (err, response, body) ->
|
||||
return callback(err) if err
|
||||
callback(null)
|
||||
|
||||
# Actions
|
||||
tryFollowInviteLink = (user, link, callback=(err, response, body)->) ->
|
||||
|
@ -115,11 +123,16 @@ describe "ProjectInviteTests", ->
|
|||
beforeEach (done) ->
|
||||
@invite = null
|
||||
@link = null
|
||||
createInvite @projectId, @sendingUser, @email, (err, invite) =>
|
||||
createInvite @sendingUser, @projectId, @email, (err, invite) =>
|
||||
@invite = invite
|
||||
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
|
||||
done()
|
||||
|
||||
afterEach (done) ->
|
||||
revokeInvite @sendingUser, @projectId, @invite._id, (err) =>
|
||||
throw err if err
|
||||
done()
|
||||
|
||||
it 'should not grant access if the user does not accept the invite', (done) ->
|
||||
Async.series(
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue