Skip to content

Commit

Permalink
Update test to double-check that blank password is not hashed (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-white authored Jan 30, 2023
1 parent 50894bd commit 2089f63
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/integration/api/users.js
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', () => {
Expand Down Expand Up @@ -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) =>
Expand Down

0 comments on commit 2089f63

Please sign in to comment.