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"
|
CollaboratorsEmailHandler = require "../../../app/js/Features/Collaborators/CollaboratorsEmailHandler"
|
||||||
|
|
||||||
|
|
||||||
createInvite = (projectId, sendingUser, email, callback=(err, invite)->) ->
|
createInvite = (sendingUser, projectId, email, callback=(err, invite)->) ->
|
||||||
sendingUser.getCsrfToken (err) ->
|
sendingUser.getCsrfToken (err) ->
|
||||||
return callback(err) if err
|
return callback(err) if err
|
||||||
sendingUser.request.post {
|
sendingUser.request.post {
|
||||||
|
@ -16,8 +16,16 @@ createInvite = (projectId, sendingUser, email, callback=(err, invite)->) ->
|
||||||
privileges: 'readAndWrite'
|
privileges: 'readAndWrite'
|
||||||
}, (err, response, body) ->
|
}, (err, response, body) ->
|
||||||
return callback(err) if err
|
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
|
# Actions
|
||||||
tryFollowInviteLink = (user, link, callback=(err, response, body)->) ->
|
tryFollowInviteLink = (user, link, callback=(err, response, body)->) ->
|
||||||
|
@ -115,11 +123,16 @@ describe "ProjectInviteTests", ->
|
||||||
beforeEach (done) ->
|
beforeEach (done) ->
|
||||||
@invite = null
|
@invite = null
|
||||||
@link = null
|
@link = null
|
||||||
createInvite @projectId, @sendingUser, @email, (err, invite) =>
|
createInvite @sendingUser, @projectId, @email, (err, invite) =>
|
||||||
@invite = invite
|
@invite = invite
|
||||||
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
|
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
|
||||||
done()
|
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) ->
|
it 'should not grant access if the user does not accept the invite', (done) ->
|
||||||
Async.series(
|
Async.series(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue