mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Make tests in RegistrationTests not depend on previous run state
GitOrigin-RevId: 68bcf9530ec6f5831c67449f35d0f010e5104f78
This commit is contained in:
parent
7d253651ca
commit
6defe1a693
1 changed files with 220 additions and 218 deletions
|
@ -76,8 +76,9 @@ const tryLoginThroughRegistrationForm = function(
|
|||
})
|
||||
}
|
||||
|
||||
describe('Registration', function() {
|
||||
describe('LoginRateLimit', function() {
|
||||
before(function() {
|
||||
beforeEach(function() {
|
||||
this.user = new User()
|
||||
this.badEmail = 'bademail@example.com'
|
||||
return (this.badPassword = 'badpassword')
|
||||
|
@ -221,7 +222,7 @@ describe('CSRF protection', function() {
|
|||
})
|
||||
|
||||
describe('Register', function() {
|
||||
before(function() {
|
||||
beforeEach(function() {
|
||||
return (this.user = new User())
|
||||
})
|
||||
|
||||
|
@ -239,7 +240,7 @@ describe('Register', function() {
|
|||
})
|
||||
|
||||
describe('Register with bonus referal id', function() {
|
||||
before(function(done) {
|
||||
beforeEach(function(done) {
|
||||
this.user1 = new User()
|
||||
this.user2 = new User()
|
||||
return async.series(
|
||||
|
@ -266,7 +267,7 @@ describe('Register with bonus referal id', function() {
|
|||
})
|
||||
|
||||
describe('LoginViaRegistration', function() {
|
||||
before(function(done) {
|
||||
beforeEach(function(done) {
|
||||
this.timeout(60000)
|
||||
this.user1 = new User()
|
||||
this.user2 = new User()
|
||||
|
@ -298,31 +299,29 @@ describe('LoginViaRegistration', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('should have user1 login', function(done) {
|
||||
return this.user1.login(err => {
|
||||
expect(err != null).to.equal(false)
|
||||
return done()
|
||||
it('should have user1 login and create a project, which user2 cannot access', function(done) {
|
||||
let projectId
|
||||
async.series(
|
||||
[
|
||||
// user1 logs in and creates a project which only they can access
|
||||
cb => {
|
||||
this.user1.login(err => {
|
||||
expect(err).not.to.exist
|
||||
cb()
|
||||
})
|
||||
},
|
||||
cb => {
|
||||
this.user1.createProject('Private Project', (err, id) => {
|
||||
expect(err).not.to.exist
|
||||
projectId = id
|
||||
cb()
|
||||
})
|
||||
|
||||
it('should have user1 create a project', function(done) {
|
||||
return this.user1.createProject('Private Project', (err, project_id) => {
|
||||
expect(err != null).to.equal(false)
|
||||
this.project_id = project_id
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should ensure user1 can access their project', function(done) {
|
||||
return expectProjectAccess(this.user1, this.project_id, done)
|
||||
})
|
||||
|
||||
it('should ensure user2 cannot access the project', function(done) {
|
||||
return expectNoProjectAccess(this.user2, this.project_id, done)
|
||||
})
|
||||
|
||||
it('should prevent user2 from login/register with user1 email address', function(done) {
|
||||
return tryLoginThroughRegistrationForm(
|
||||
},
|
||||
cb => expectProjectAccess(this.user1, projectId, cb),
|
||||
cb => expectNoProjectAccess(this.user2, projectId, cb),
|
||||
// should prevent user2 from login/register with user1 email address
|
||||
cb => {
|
||||
tryLoginThroughRegistrationForm(
|
||||
this.user2,
|
||||
this.user1.email,
|
||||
'totally_not_the_right_password',
|
||||
|
@ -331,13 +330,16 @@ describe('LoginViaRegistration', function() {
|
|||
expect(body.message != null).to.equal(true)
|
||||
expect(body.message).to.have.all.keys('type', 'text')
|
||||
expect(body.message.type).to.equal('error')
|
||||
return done()
|
||||
cb()
|
||||
}
|
||||
)
|
||||
},
|
||||
// check user still can't access the project
|
||||
cb => expectNoProjectAccess(this.user2, projectId, done)
|
||||
],
|
||||
done
|
||||
)
|
||||
})
|
||||
|
||||
it('should still ensure user2 cannot access the project', function(done) {
|
||||
return expectNoProjectAccess(this.user2, this.project_id, done)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue