|
| 1 | +const appRoot = require('app-root-path'); |
1 | 2 | const should = require('should'); |
| 3 | +// eslint-disable-next-line import/no-dynamic-require |
| 4 | +const { getOrNotFound } = require(appRoot + '/lib/util/promise'); |
2 | 5 | const { testService } = require('../setup'); |
3 | 6 |
|
4 | 7 | describe('api: /users', () => { |
@@ -91,14 +94,19 @@ describe('api: /users', () => { |
91 | 94 | .then(() => service.login({ email: '[email protected]', password: 'alongpassword' }, (asDavid) => |
92 | 95 | asDavid.get('/v1/users/current').expect(200)))))); |
93 | 96 |
|
94 | | - it('should not accept and hash blank passwords', testService((service) => |
| 97 | + it('should not accept and hash blank passwords', testService((service, { Users }) => |
95 | 98 | service.login('alice', (asAlice) => |
96 | 99 | asAlice.post('/v1/users') |
97 | 100 | .send({ email: '[email protected]', password: '' }) |
98 | 101 | .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 | + ]))))); |
102 | 110 |
|
103 | 111 | it('should not accept a password that is too short', testService((service) => |
104 | 112 | service.login('alice', (asAlice) => |
|
0 commit comments