ProjectInviteTests.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. const { expect } = require('chai')
  2. const Async = require('async')
  3. const User = require('./helpers/User')
  4. const settings = require('@overleaf/settings')
  5. const CollaboratorsEmailHandler = require('../../../app/src/Features/Collaborators/CollaboratorsEmailHandler')
  6. const CollaboratorsInviteHelper = require('../../../app/src/Features/Collaborators/CollaboratorsInviteHelper')
  7. const Features = require('../../../app/src/infrastructure/Features')
  8. const cheerio = require('cheerio')
  9. const sinon = require('sinon')
  10. let generateTokenSpy
  11. const createInvite = (sendingUser, projectId, email, callback) => {
  12. sendingUser.getCsrfToken(err => {
  13. if (err) {
  14. return callback(err)
  15. }
  16. sendingUser.request.post(
  17. {
  18. uri: `/project/${projectId}/invite`,
  19. json: {
  20. email,
  21. privileges: 'readAndWrite',
  22. },
  23. },
  24. (err, response, body) => {
  25. if (err) {
  26. return callback(err)
  27. }
  28. expect(response.statusCode).to.equal(200)
  29. expect(body.error).to.not.exist
  30. expect(body.invite).to.exist
  31. callback(null, body.invite)
  32. }
  33. )
  34. })
  35. }
  36. const createProject = (owner, projectName, callback) => {
  37. owner.createProject(projectName, (err, projectId) => {
  38. if (err) {
  39. throw err
  40. }
  41. const fakeProject = {
  42. _id: projectId,
  43. name: projectName,
  44. owner_ref: owner,
  45. }
  46. callback(err, projectId, fakeProject)
  47. })
  48. }
  49. const createProjectAndInvite = (owner, projectName, email, callback) => {
  50. createProject(owner, projectName, (err, projectId, project) => {
  51. if (err) {
  52. return callback(err)
  53. }
  54. createInvite(owner, projectId, email, (err, invite) => {
  55. if (err) {
  56. return callback(err)
  57. }
  58. // attach the token to the invite
  59. invite.token = generateTokenSpy.getCall(0).returnValue
  60. const link = CollaboratorsEmailHandler._buildInviteUrl(project, invite)
  61. callback(null, project, invite, link)
  62. })
  63. })
  64. }
  65. const revokeInvite = (sendingUser, projectId, inviteId, callback) => {
  66. sendingUser.getCsrfToken(err => {
  67. if (err) {
  68. return callback(err)
  69. }
  70. sendingUser.request.delete(
  71. {
  72. uri: `/project/${projectId}/invite/${inviteId}`,
  73. },
  74. err => {
  75. if (err) {
  76. return callback(err)
  77. }
  78. callback()
  79. }
  80. )
  81. })
  82. }
  83. // Actions
  84. const tryFollowInviteLink = (user, link, callback) => {
  85. user.request.get(
  86. {
  87. uri: link,
  88. baseUrl: null,
  89. },
  90. callback
  91. )
  92. }
  93. const tryAcceptInvite = (user, invite, projectId, callback) => {
  94. user.getCsrfToken(err => {
  95. if (err) {
  96. return callback(err)
  97. }
  98. user.request.post(
  99. {
  100. uri: `/project/${projectId}/invite/token/${invite.token}/accept`,
  101. json: {
  102. token: invite.token,
  103. },
  104. },
  105. callback
  106. )
  107. })
  108. }
  109. const tryFollowLoginLink = (user, loginLink, callback) => {
  110. user.getCsrfToken(error => {
  111. if (error != null) {
  112. return callback(error)
  113. }
  114. user.request.get(loginLink, callback)
  115. })
  116. }
  117. const tryLoginUser = (user, callback) => {
  118. user.getCsrfToken(error => {
  119. if (error != null) {
  120. return callback(error)
  121. }
  122. user.request.post(
  123. {
  124. url: '/login',
  125. json: {
  126. email: user.email,
  127. password: user.password,
  128. 'g-recaptcha-response': 'valid',
  129. },
  130. },
  131. callback
  132. )
  133. })
  134. }
  135. const tryGetInviteList = (user, projectId, callback) => {
  136. user.getCsrfToken(error => {
  137. if (error != null) {
  138. return callback(error)
  139. }
  140. user.request.get(
  141. {
  142. url: `/project/${projectId}/invites`,
  143. json: true,
  144. },
  145. callback
  146. )
  147. })
  148. }
  149. const tryJoinProject = (user, projectId, callback) => {
  150. return user.getCsrfToken(error => {
  151. if (error != null) {
  152. return callback(error)
  153. }
  154. user.request.post(
  155. {
  156. url: `/project/${projectId}/join`,
  157. auth: {
  158. user: settings.apis.web.user,
  159. pass: settings.apis.web.pass,
  160. sendImmediately: true,
  161. },
  162. json: { userId: user._id },
  163. jar: false,
  164. },
  165. callback
  166. )
  167. })
  168. }
  169. // Expectations
  170. const expectProjectAccess = (user, projectId, callback) => {
  171. // should have access to project
  172. user.openProject(projectId, err => {
  173. expect(err).not.to.exist
  174. callback()
  175. })
  176. }
  177. const expectNoProjectAccess = (user, projectId, callback) => {
  178. // should not have access to project page
  179. user.openProject(projectId, err => {
  180. expect(err).to.be.instanceof(Error)
  181. callback()
  182. })
  183. }
  184. const expectInvitePage = (user, link, callback) => {
  185. // view invite
  186. tryFollowInviteLink(user, link, (err, response, body) => {
  187. expect(err).not.to.exist
  188. expect(response.statusCode).to.equal(200)
  189. expect(body).to.match(/<title>Project Invite - .*<\/title>/)
  190. callback()
  191. })
  192. }
  193. const expectInvalidInvitePage = (user, link, callback) => {
  194. // view invalid invite
  195. tryFollowInviteLink(user, link, (err, response, body) => {
  196. expect(err).not.to.exist
  197. expect(response.statusCode).to.equal(404)
  198. expect(body).to.match(/<title>Invalid Invite - .*<\/title>/)
  199. callback()
  200. })
  201. }
  202. const expectInviteRedirectToRegister = (user, link, callback) => {
  203. // view invite, redirect to `/register`
  204. tryFollowInviteLink(user, link, (err, response) => {
  205. expect(err).not.to.exist
  206. expect(response.statusCode).to.equal(302)
  207. expect(response.headers.location).to.match(/^\/register.*$/)
  208. user.getSession((err, session) => {
  209. if (err) return callback(err)
  210. expect(session.sharedProjectData).deep.equals({
  211. project_name: PROJECT_NAME,
  212. user_first_name: OWNER_NAME,
  213. })
  214. callback()
  215. })
  216. })
  217. }
  218. const expectLoginPage = (user, callback) => {
  219. tryFollowLoginLink(user, '/login', (err, response, body) => {
  220. expect(err).not.to.exist
  221. expect(response.statusCode).to.equal(200)
  222. expect(body).to.match(/<title>(Login|Log in to Overleaf) - .*<\/title>/)
  223. callback()
  224. })
  225. }
  226. const expectLoginRedirectToInvite = (user, link, callback) => {
  227. tryLoginUser(user, (err, response) => {
  228. expect(err).not.to.exist
  229. expect(response.statusCode).to.equal(200)
  230. callback()
  231. })
  232. }
  233. const expectRegistrationRedirectToInvite = (user, link, callback) => {
  234. user.register((err, _user, response) => {
  235. expect(err).not.to.exist
  236. expect(response.statusCode).to.equal(200)
  237. if (response.body.redir === '/registration/try-premium') {
  238. user.request.get('/registration/onboarding', (err, response) => {
  239. if (err) return callback(err)
  240. expect(response.statusCode).to.equal(200)
  241. const dom = cheerio.load(response.body)
  242. const skipUrl = dom('meta[name="ol-skipUrl"]')[0].attribs.content
  243. expect(new URL(skipUrl, settings.siteUrl).href).to.equal(
  244. new URL(link, settings.siteUrl).href
  245. )
  246. callback()
  247. })
  248. } else {
  249. expect(response.body.redir).to.equal(link)
  250. callback()
  251. }
  252. })
  253. }
  254. const expectInviteRedirectToProject = (user, link, projectId, callback) => {
  255. // view invite, redirect straight to project
  256. tryFollowInviteLink(user, link, (err, response) => {
  257. expect(err).not.to.exist
  258. expect(response.statusCode).to.equal(302)
  259. expect(response.headers.location).to.equal(`/project/${projectId}`)
  260. callback()
  261. })
  262. }
  263. const expectAcceptInviteAndRedirect = (user, invite, projectId, callback) => {
  264. // should accept the invite and redirect to project
  265. tryAcceptInvite(user, invite, projectId, (err, response) => {
  266. expect(err).not.to.exist
  267. expect(response.statusCode).to.equal(302)
  268. expect(response.headers.location).to.equal(`/project/${projectId}`)
  269. callback()
  270. })
  271. }
  272. const expectInviteListCount = (user, projectId, count, callback) => {
  273. tryGetInviteList(user, projectId, (err, response, body) => {
  274. expect(err).not.to.exist
  275. expect(response.statusCode).to.equal(200)
  276. expect(body).to.have.all.keys(['invites'])
  277. expect(body.invites.length).to.equal(count)
  278. callback()
  279. })
  280. }
  281. const expectInvitesInJoinProjectCount = (user, projectId, count, callback) => {
  282. tryJoinProject(user, projectId, (err, response, body) => {
  283. expect(err).not.to.exist
  284. expect(response.statusCode).to.equal(200)
  285. expect(body.project).to.contain.keys(['invites'])
  286. expect(body.project.invites.length).to.equal(count)
  287. callback()
  288. })
  289. }
  290. const PROJECT_NAME = 'project name for sharing test'
  291. const OWNER_NAME = 'sending user name'
  292. describe('ProjectInviteTests', function () {
  293. beforeEach(function (done) {
  294. this.sendingUser = new User()
  295. this.user = new User()
  296. this.site_admin = new User({ email: `admin+${Math.random()}@example.com` })
  297. this.email = `smoketestuser+${Math.random()}@example.com`
  298. generateTokenSpy = sinon.spy(CollaboratorsInviteHelper, 'generateToken')
  299. Async.series(
  300. [
  301. cb => this.sendingUser.login(cb),
  302. cb => this.sendingUser.setFeatures({ collaborators: 10 }, cb),
  303. cb =>
  304. this.sendingUser.mongoUpdate(
  305. {
  306. $set: { first_name: OWNER_NAME },
  307. },
  308. cb
  309. ),
  310. cb =>
  311. this.sendingUser.setFeaturesOverride(
  312. {
  313. note: 'ProjectInviteTests acceptance tests',
  314. features: { collaborators: 10 },
  315. },
  316. cb
  317. ),
  318. ],
  319. done
  320. )
  321. })
  322. afterEach(function () {
  323. generateTokenSpy.restore()
  324. })
  325. describe('creating invites', function () {
  326. describe('creating two invites', function () {
  327. beforeEach(function (done) {
  328. createProject(
  329. this.sendingUser,
  330. PROJECT_NAME,
  331. (err, projectId, project) => {
  332. expect(err).not.to.exist
  333. this.projectId = projectId
  334. this.fakeProject = project
  335. done()
  336. }
  337. )
  338. })
  339. it('should allow the project owner to create and remove invites', function (done) {
  340. Async.series(
  341. [
  342. cb => expectProjectAccess(this.sendingUser, this.projectId, cb),
  343. cb =>
  344. expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
  345. // create invite, check invite list count
  346. cb => {
  347. createInvite(
  348. this.sendingUser,
  349. this.projectId,
  350. this.email,
  351. (err, invite) => {
  352. if (err) {
  353. return cb(err)
  354. }
  355. this.invite = invite
  356. cb()
  357. }
  358. )
  359. },
  360. cb =>
  361. expectInviteListCount(this.sendingUser, this.projectId, 1, cb),
  362. cb =>
  363. revokeInvite(
  364. this.sendingUser,
  365. this.projectId,
  366. this.invite._id,
  367. cb
  368. ),
  369. cb =>
  370. expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
  371. // and a second time
  372. cb => {
  373. createInvite(
  374. this.sendingUser,
  375. this.projectId,
  376. this.email,
  377. (err, invite) => {
  378. if (err) {
  379. return cb(err)
  380. }
  381. this.invite = invite
  382. cb()
  383. }
  384. )
  385. },
  386. cb =>
  387. expectInviteListCount(this.sendingUser, this.projectId, 1, cb),
  388. // check the joinProject view
  389. cb =>
  390. expectInvitesInJoinProjectCount(
  391. this.sendingUser,
  392. this.projectId,
  393. 1,
  394. cb
  395. ),
  396. // revoke invite
  397. cb =>
  398. revokeInvite(
  399. this.sendingUser,
  400. this.projectId,
  401. this.invite._id,
  402. cb
  403. ),
  404. cb =>
  405. expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
  406. cb =>
  407. expectInvitesInJoinProjectCount(
  408. this.sendingUser,
  409. this.projectId,
  410. 0,
  411. cb
  412. ),
  413. ],
  414. done
  415. )
  416. })
  417. it('should allow the project owner to create many invites at once', function (done) {
  418. Async.series(
  419. [
  420. cb => expectProjectAccess(this.sendingUser, this.projectId, cb),
  421. cb =>
  422. expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
  423. // create first invite
  424. cb => {
  425. createInvite(
  426. this.sendingUser,
  427. this.projectId,
  428. this.email,
  429. (err, invite) => {
  430. if (err) {
  431. return cb(err)
  432. }
  433. this.inviteOne = invite
  434. cb()
  435. }
  436. )
  437. },
  438. cb =>
  439. expectInviteListCount(this.sendingUser, this.projectId, 1, cb),
  440. // and a second
  441. cb => {
  442. createInvite(
  443. this.sendingUser,
  444. this.projectId,
  445. this.email,
  446. (err, invite) => {
  447. if (err) {
  448. return cb(err)
  449. }
  450. this.inviteTwo = invite
  451. cb()
  452. }
  453. )
  454. },
  455. // should have two
  456. cb =>
  457. expectInviteListCount(this.sendingUser, this.projectId, 2, cb),
  458. cb =>
  459. expectInvitesInJoinProjectCount(
  460. this.sendingUser,
  461. this.projectId,
  462. 2,
  463. cb
  464. ),
  465. // revoke first
  466. cb =>
  467. revokeInvite(
  468. this.sendingUser,
  469. this.projectId,
  470. this.inviteOne._id,
  471. cb
  472. ),
  473. cb =>
  474. expectInviteListCount(this.sendingUser, this.projectId, 1, cb),
  475. // revoke second
  476. cb =>
  477. revokeInvite(
  478. this.sendingUser,
  479. this.projectId,
  480. this.inviteTwo._id,
  481. cb
  482. ),
  483. cb =>
  484. expectInviteListCount(this.sendingUser, this.projectId, 0, cb),
  485. ],
  486. done
  487. )
  488. })
  489. })
  490. })
  491. describe('clicking the invite link', function () {
  492. beforeEach(function (done) {
  493. createProjectAndInvite(
  494. this.sendingUser,
  495. PROJECT_NAME,
  496. this.email,
  497. (err, project, invite, link) => {
  498. expect(err).not.to.exist
  499. this.projectId = project._id
  500. this.fakeProject = project
  501. this.invite = invite
  502. this.link = link
  503. done()
  504. }
  505. )
  506. })
  507. describe('user is logged in already', function () {
  508. beforeEach(function (done) {
  509. this.user.login(done)
  510. })
  511. describe('user is already a member of the project', function () {
  512. beforeEach(function (done) {
  513. Async.series(
  514. [
  515. cb => expectInvitePage(this.user, this.link, cb),
  516. cb =>
  517. expectAcceptInviteAndRedirect(
  518. this.user,
  519. this.invite,
  520. this.projectId,
  521. cb
  522. ),
  523. cb => expectProjectAccess(this.user, this.projectId, cb),
  524. ],
  525. done
  526. )
  527. })
  528. describe('when user clicks on the invite a second time', function () {
  529. it('should just redirect to the project page', function (done) {
  530. Async.series(
  531. [
  532. cb => expectProjectAccess(this.user, this.projectId, cb),
  533. cb =>
  534. expectInviteRedirectToProject(
  535. this.user,
  536. this.link,
  537. this.projectId,
  538. cb
  539. ),
  540. cb => expectProjectAccess(this.user, this.projectId, cb),
  541. ],
  542. done
  543. )
  544. })
  545. describe('when the user recieves another invite to the same project', function () {
  546. it('should redirect to the project page', function (done) {
  547. Async.series(
  548. [
  549. cb => {
  550. createInvite(
  551. this.sendingUser,
  552. this.projectId,
  553. this.email,
  554. (err, invite) => {
  555. if (err) {
  556. throw err
  557. }
  558. this.secondInvite = invite
  559. const token = generateTokenSpy.getCall(1).returnValue
  560. this.secondLink =
  561. CollaboratorsEmailHandler._buildInviteUrl(
  562. this.fakeProject,
  563. { ...invite, token }
  564. )
  565. cb()
  566. }
  567. )
  568. },
  569. cb =>
  570. expectInviteRedirectToProject(
  571. this.user,
  572. this.secondLink,
  573. this.projectId,
  574. cb
  575. ),
  576. cb => expectProjectAccess(this.user, this.projectId, cb),
  577. cb =>
  578. revokeInvite(
  579. this.sendingUser,
  580. this.projectId,
  581. this.secondInvite._id,
  582. cb
  583. ),
  584. ],
  585. done
  586. )
  587. })
  588. })
  589. })
  590. })
  591. describe('user is not a member of the project', function () {
  592. it('should not grant access if the user does not accept the invite', function (done) {
  593. Async.series(
  594. [
  595. cb => expectInvitePage(this.user, this.link, cb),
  596. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  597. ],
  598. done
  599. )
  600. })
  601. it('should render the invalid-invite page if the token is invalid', function (done) {
  602. Async.series(
  603. [
  604. cb => {
  605. const link = this.link.replace(
  606. this.invite.token,
  607. 'not_a_real_token'
  608. )
  609. expectInvalidInvitePage(this.user, link, cb)
  610. },
  611. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  612. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  613. ],
  614. done
  615. )
  616. })
  617. it('should allow the user to accept the invite and access the project', function (done) {
  618. Async.series(
  619. [
  620. cb => expectInvitePage(this.user, this.link, cb),
  621. cb =>
  622. expectAcceptInviteAndRedirect(
  623. this.user,
  624. this.invite,
  625. this.projectId,
  626. cb
  627. ),
  628. cb => expectProjectAccess(this.user, this.projectId, cb),
  629. ],
  630. done
  631. )
  632. })
  633. })
  634. })
  635. describe('user is not logged in initially', function () {
  636. describe('registration prompt workflow with valid token', function () {
  637. before(function () {
  638. if (!Features.hasFeature('registration')) {
  639. this.skip()
  640. }
  641. })
  642. it('should redirect to the register page', function (done) {
  643. expectInviteRedirectToRegister(this.user, this.link, done)
  644. })
  645. it('should allow user to accept the invite if the user registers a new account', function (done) {
  646. Async.series(
  647. [
  648. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  649. cb =>
  650. expectRegistrationRedirectToInvite(this.user, this.link, cb),
  651. cb => expectInvitePage(this.user, this.link, cb),
  652. cb =>
  653. expectAcceptInviteAndRedirect(
  654. this.user,
  655. this.invite,
  656. this.projectId,
  657. cb
  658. ),
  659. cb => expectProjectAccess(this.user, this.projectId, cb),
  660. ],
  661. done
  662. )
  663. })
  664. })
  665. describe('registration prompt workflow with non-valid token', function () {
  666. before(function () {
  667. if (!Features.hasFeature('registration')) {
  668. this.skip()
  669. }
  670. })
  671. it('should redirect to the register page', function (done) {
  672. Async.series(
  673. [
  674. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  675. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  676. ],
  677. done
  678. )
  679. })
  680. it('should display invalid-invite right away', function (done) {
  681. const badLink = this.link.replace(
  682. this.invite.token,
  683. 'not_a_real_token'
  684. )
  685. Async.series(
  686. [
  687. cb => expectInvalidInvitePage(this.user, badLink, cb),
  688. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  689. ],
  690. done
  691. )
  692. })
  693. })
  694. describe('login workflow with valid token', function () {
  695. beforeEach(function (done) {
  696. this.user.ensureUserExists(done)
  697. })
  698. it('should redirect to the register page', function (done) {
  699. Async.series(
  700. [
  701. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  702. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  703. ],
  704. done
  705. )
  706. })
  707. it('should allow the user to login to view the invite', function (done) {
  708. Async.series(
  709. [
  710. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  711. cb => expectLoginPage(this.user, cb),
  712. cb => expectLoginRedirectToInvite(this.user, this.link, cb),
  713. cb => expectInvitePage(this.user, this.link, cb),
  714. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  715. ],
  716. done
  717. )
  718. })
  719. it('should allow user to accept the invite if the user logs in', function (done) {
  720. Async.series(
  721. [
  722. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  723. cb => expectLoginPage(this.user, cb),
  724. cb => expectLoginRedirectToInvite(this.user, this.link, cb),
  725. cb => expectInvitePage(this.user, this.link, cb),
  726. cb =>
  727. expectAcceptInviteAndRedirect(
  728. this.user,
  729. this.invite,
  730. this.projectId,
  731. cb
  732. ),
  733. cb => expectProjectAccess(this.user, this.projectId, cb),
  734. ],
  735. done
  736. )
  737. })
  738. })
  739. describe('login workflow with non-valid token', function () {
  740. it('should redirect to the register page', function (done) {
  741. Async.series(
  742. [
  743. cb => expectInviteRedirectToRegister(this.user, this.link, cb),
  744. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  745. ],
  746. done
  747. )
  748. })
  749. it('should show the invalid-invite page right away', function (done) {
  750. const badLink = this.link.replace(
  751. this.invite.token,
  752. 'not_a_real_token'
  753. )
  754. Async.series(
  755. [
  756. cb => expectInvalidInvitePage(this.user, badLink, cb),
  757. cb => expectNoProjectAccess(this.user, this.projectId, cb),
  758. ],
  759. done
  760. )
  761. })
  762. })
  763. })
  764. })
  765. })