strengthen the test of password-reset just a little
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('DELETE social registration', () => {
|
||||
let user;
|
||||
let endpoint = '/user/auth/social/facebook';
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
await user.update({ 'auth.facebook.id': 'some-fb-id' });
|
||||
expect(user.auth.local.username).to.not.be.empty;
|
||||
expect(user.auth.facebook).to.not.be.empty;
|
||||
});
|
||||
context('of NOT-FACEBOOK', () => {
|
||||
it('is not supported', async () => {
|
||||
expect(user.del('/user/auth/social/SOME-OTHER-NETWORK')).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyFbSupported'),
|
||||
});
|
||||
});
|
||||
});
|
||||
context('of facebook', () => {
|
||||
it('fails if local registration does not exist for this user', async () => {
|
||||
await user.update({ 'auth.local': { ok: true } });
|
||||
expect(user.del(endpoint)).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'NotAuthorized',
|
||||
message: t('cantDetachFb'),
|
||||
});
|
||||
});
|
||||
it('succeeds', async () => {
|
||||
let response = await user.del(endpoint);
|
||||
expect(response).to.eql({});
|
||||
await user.sync();
|
||||
expect(user.auth.facebook).to.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12,10 +12,13 @@ describe('POST /user/reset-password', async () => {
|
||||
});
|
||||
|
||||
it('resets password', async () => {
|
||||
let previousPassword = user.auth.local.hashed_password;
|
||||
let response = await user.post(endpoint, {
|
||||
email: user.auth.local.email,
|
||||
});
|
||||
expect(response).to.eql({ message: t('passwordReset') });
|
||||
await user.sync();
|
||||
expect(user.auth.local.hashed_password).to.not.eql(previousPassword);
|
||||
});
|
||||
|
||||
it('same message on error as on success', async () => {
|
||||
|
||||
Reference in New Issue
Block a user