This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#624-update-main-contributors
- Loading branch information
Showing
22 changed files
with
6,697 additions
and
3,602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:8.9.0 | ||
FROM node:8.11.1 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,18 +52,35 @@ describe('Auth', () => { | |
res.body.message.should.be.equal(errorCodes.errorCodes.duplicateUid.code); | ||
}); | ||
|
||
it('should pass', async () => { | ||
const registerUser = { uid: '5468907', | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
role: 'student', | ||
password: 'test1234', | ||
email: '[email protected]'}; | ||
|
||
const res = await chai.request(app) | ||
.post(`${BASE_URL}/register`) | ||
.send(registerUser) | ||
.catch(err => err.response); | ||
|
||
res.status.should.be.equal(204); | ||
}); | ||
|
||
|
||
it('should pass and enroll into course', async () => { | ||
const registerUser: IUser = new User(); | ||
registerUser.uid = '5468907'; | ||
registerUser.profile.firstName = 'firstName'; | ||
registerUser.profile.lastName = 'lastName'; | ||
registerUser.role = 'student'; | ||
registerUser.password = 'test1234'; | ||
registerUser.email = '[email protected]'; | ||
const registerUser = { uid: '5468907', | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
role: 'student', | ||
password: 'test1234', | ||
email: '[email protected]'}; | ||
|
||
const whitelistUser = await WhitelistUser.create({ | ||
uid: registerUser.uid, | ||
firstName: registerUser.profile.firstName, | ||
lastName: registerUser.profile.lastName | ||
firstName: registerUser.firstName, | ||
lastName: registerUser.lastName | ||
}); | ||
const noElemCourse = await Course.create({ | ||
name: 'Test Course 1', | ||
|
@@ -75,29 +92,24 @@ describe('Auth', () => { | |
enrollType: 'whitelist', | ||
whitelist: [whitelistUser] | ||
}); | ||
return new Promise((resolve, reject) => { | ||
chai.request(app) | ||
const res = await chai.request(app) | ||
.post(`${BASE_URL}/register`) | ||
.send(registerUser) | ||
.end(async (err, res) => { | ||
res.status.should.be.equal(204); | ||
// Get updated Course. | ||
const resultNoElemCourse = await Course.findById(noElemCourse._id) | ||
.populate('whitelist') | ||
.populate('students'); | ||
const resultElemCourse = await Course.findById(elemCourse._id) | ||
.populate('whitelist') | ||
.populate('students'); | ||
resultNoElemCourse.whitelist.length.should.be.equal(0); | ||
resultNoElemCourse.students.length.should.be.equal(0); | ||
resultElemCourse.whitelist.length.should.be.equal(1); | ||
resultElemCourse.students.length.should.be.equal(1); | ||
resultElemCourse.whitelist[0].uid.should.be.equal(resultElemCourse.students[0].uid); | ||
resultElemCourse.whitelist[0].firstName.should.be.equal(resultElemCourse.students[0].profile.firstName.toLowerCase()); | ||
resultElemCourse.whitelist[0].lastName.should.be.equal(resultElemCourse.students[0].profile.lastName.toLowerCase()); | ||
resolve(); | ||
}); | ||
}); | ||
.catch(err => err.response); | ||
|
||
res.status.should.be.equal(204); | ||
// Get updated Course. | ||
const resultNoElemCourse = await Course.findById(noElemCourse._id) | ||
.populate('whitelist') | ||
.populate('students'); | ||
const resultElemCourse = await Course.findById(elemCourse._id) | ||
.populate('whitelist') | ||
.populate('students'); | ||
resultNoElemCourse.whitelist.length.should.be.equal(0); | ||
resultNoElemCourse.students.length.should.be.equal(0); | ||
resultElemCourse.whitelist.length.should.be.equal(1); | ||
resultElemCourse.students.length.should.be.equal(1); | ||
resultElemCourse.whitelist[0].uid.should.be.equal(resultElemCourse.students[0].uid); | ||
}); | ||
|
||
it('should fail (registration as admin)', async () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,22 +254,6 @@ describe('User', () => { | |
res.body.email.should.be.equal('[email protected]'); | ||
}); | ||
|
||
it('should fail with missing password', async () => { | ||
const student = await FixtureUtils.getRandomStudent(); | ||
const updatedUser = student; | ||
updatedUser.password = '1234test'; | ||
|
||
const res = await chai.request(app) | ||
.put(`${BASE_URL}/${student._id}`) | ||
.set('Authorization', `JWT ${JwtUtils.generateToken(student)}`) | ||
.send(updatedUser) | ||
.catch(err => err.response); | ||
|
||
res.status.should.be.equal(400); | ||
res.body.name.should.be.equal('BadRequestError'); | ||
res.body.message.should.be.equal('Invalid Current Password!'); | ||
}); | ||
|
||
it('should update user data', async () => { | ||
const student = await FixtureUtils.getRandomStudent(); | ||
const updatedUser = student; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ build/test/**/*.js | |
--reporter spec | ||
--require test/mocha.env.js | ||
--timeout 10000 | ||
--exit |
Oops, something went wrong.