#68 Added some forgot password tests
parent
a3957264c0
commit
b06e72f40c
|
@ -246,6 +246,7 @@ module.exports = (app, passport) => {
|
||||||
app.route('/login/forgot')
|
app.route('/login/forgot')
|
||||||
|
|
||||||
// Check if user is already logged in
|
// Check if user is already logged in
|
||||||
|
// TODO: Write test for this situation
|
||||||
.all((req, res, next) => {
|
.all((req, res, next) => {
|
||||||
if (req.isAuthenticated()) loginCallback(req, res)
|
if (req.isAuthenticated()) loginCallback(req, res)
|
||||||
else next()
|
else next()
|
||||||
|
@ -264,6 +265,7 @@ module.exports = (app, passport) => {
|
||||||
// Check if somebody has that email
|
// Check if somebody has that email
|
||||||
User.findOne({'email': req.body.email})
|
User.findOne({'email': req.body.email})
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
|
|
||||||
// No user with that email
|
// No user with that email
|
||||||
if (!user) {
|
if (!user) {
|
||||||
// Don't let on that no such user exists, to prevent dictionary attacks
|
// Don't let on that no such user exists, to prevent dictionary attacks
|
||||||
|
|
29
test/auth.js
29
test/auth.js
|
@ -161,15 +161,32 @@ describe('Authentication', () => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Create test for forgetten password
|
it('Loads forgot password page', async () => {
|
||||||
// it('Forgets password', async () => {
|
let res = await request.get('/login/forgot')
|
||||||
|
chai.expect(res).html.to.have.status(200)
|
||||||
|
})
|
||||||
|
|
||||||
// })
|
// TODO: Test already-logged-in forgot password requests
|
||||||
|
|
||||||
// TODO: Create test for changing forgetten password
|
// TODO: Test invalid and fuzzed forgot password requests
|
||||||
// it('Changes forgotten password', async () => {
|
|
||||||
|
|
||||||
// })
|
it('Sends valid forgot password request', async () => {
|
||||||
|
|
||||||
|
// Responds with 200
|
||||||
|
let res = await request.post('/login/forgot')
|
||||||
|
.type('form').send({
|
||||||
|
email: TEST_EMAIL,
|
||||||
|
})
|
||||||
|
chai.expect(res).html.to.have.status(200)
|
||||||
|
|
||||||
|
// Assert password was set
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
//it('Changes forgotten password', async () => {
|
||||||
|
// TODO: Create test for changing forgetten password
|
||||||
|
//})
|
||||||
|
|
||||||
// Finally log in successfully
|
// Finally log in successfully
|
||||||
after( () => {
|
after( () => {
|
||||||
|
|
Loading…
Reference in New Issue