-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test to double-check that blank password is not hashed (#754)
- Loading branch information
1 parent
50894bd
commit 2089f63
Showing
1 changed file
with
12 additions
and
4 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,7 @@ | ||
const appRoot = require('app-root-path'); | ||
const should = require('should'); | ||
// eslint-disable-next-line import/no-dynamic-require | ||
const { getOrNotFound } = require(appRoot + '/lib/util/promise'); | ||
const { testService } = require('../setup'); | ||
|
||
describe('api: /users', () => { | ||
|
@@ -91,14 +94,19 @@ describe('api: /users', () => { | |
.then(() => service.login({ email: '[email protected]', password: 'alongpassword' }, (asDavid) => | ||
asDavid.get('/v1/users/current').expect(200)))))); | ||
|
||
it('should not accept and hash blank passwords', testService((service) => | ||
it('should not accept and hash blank passwords', testService((service, { Users }) => | ||
service.login('alice', (asAlice) => | ||
asAlice.post('/v1/users') | ||
.send({ email: '[email protected]', password: '' }) | ||
.expect(200) // treats a blank password as no password provided | ||
.then(() => service.post('/v1/sessions') | ||
.send({ email: '[email protected]', password: '' }) | ||
.expect(400))))); | ||
.then(() => Promise.all([ | ||
service.post('/v1/sessions') | ||
.send({ email: '[email protected]', password: '' }) | ||
.expect(400), | ||
Users.getByEmail('[email protected]') | ||
.then(getOrNotFound) | ||
.then(({ password }) => { should.not.exist(password); }) | ||
]))))); | ||
|
||
it('should not accept a password that is too short', testService((service) => | ||
service.login('alice', (asAlice) => | ||
|