fix: Correct change password on client

* Add additional checks on server to prevent 500
* Add tests for param checks
This commit is contained in:
Blade Barringer
2016-05-23 23:30:37 -05:00
parent 02d075e342
commit ac77ceb75f
3 changed files with 56 additions and 8 deletions

View File

@@ -50,4 +50,43 @@ describe('PUT /user/auth/update-password', async () => {
message: t('wrongPassword'),
});
});
it('returns an error when password is missing', async () => {
let body = {
newPassword,
confirmPassword: newPassword,
};
await expect(user.put(ENDPOINT, body)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
});
});
it('returns an error when newPassword is missing', async () => {
let body = {
password,
confirmPassword: newPassword,
};
await expect(user.put(ENDPOINT, body)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
});
});
it('returns an error when confirmPassword is missing', async () => {
let body = {
password,
newPassword,
};
await expect(user.put(ENDPOINT, body)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
});
});
});