Skip to content

Commit 2089f63

Browse files
Update test to double-check that blank password is not hashed (getodk#754)
1 parent 50894bd commit 2089f63

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/integration/api/users.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
const appRoot = require('app-root-path');
12
const should = require('should');
3+
// eslint-disable-next-line import/no-dynamic-require
4+
const { getOrNotFound } = require(appRoot + '/lib/util/promise');
25
const { testService } = require('../setup');
36

47
describe('api: /users', () => {
@@ -91,14 +94,19 @@ describe('api: /users', () => {
9194
.then(() => service.login({ email: '[email protected]', password: 'alongpassword' }, (asDavid) =>
9295
asDavid.get('/v1/users/current').expect(200))))));
9396

94-
it('should not accept and hash blank passwords', testService((service) =>
97+
it('should not accept and hash blank passwords', testService((service, { Users }) =>
9598
service.login('alice', (asAlice) =>
9699
asAlice.post('/v1/users')
97100
.send({ email: '[email protected]', password: '' })
98101
.expect(200) // treats a blank password as no password provided
99-
.then(() => service.post('/v1/sessions')
100-
.send({ email: '[email protected]', password: '' })
101-
.expect(400)))));
102+
.then(() => Promise.all([
103+
service.post('/v1/sessions')
104+
.send({ email: '[email protected]', password: '' })
105+
.expect(400),
106+
Users.getByEmail('[email protected]')
107+
.then(getOrNotFound)
108+
.then(({ password }) => { should.not.exist(password); })
109+
])))));
102110

103111
it('should not accept a password that is too short', testService((service) =>
104112
service.login('alice', (asAlice) =>

0 commit comments

Comments
 (0)