This commit is contained in:
parent
31d637c8a7
commit
89c25c07b6
|
@ -1,6 +1,6 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
fdescribe('VnUser Sign-in()', () => {
|
||||
describe('VnUser Sign-in()', () => {
|
||||
const employeeId = 1;
|
||||
const unauthCtx = {
|
||||
req: {
|
||||
|
@ -76,24 +76,26 @@ fdescribe('VnUser Sign-in()', () => {
|
|||
|
||||
describe('when passExpired', () => {
|
||||
it('should throw a passExpired error', async() => {
|
||||
let error;
|
||||
const tx = await VnUser.beginTransaction({});
|
||||
const employee = await VnUser.findById(employeeId);
|
||||
const yesterday = Date.vnNew();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
let error;
|
||||
try {
|
||||
await employee.updateAttribute('passExpired', yesterday);
|
||||
const options = {transaction: tx};
|
||||
await employee.updateAttribute('passExpired', yesterday, options);
|
||||
|
||||
await VnUser.signin(unauthCtx, 'employee', 'nightmare');
|
||||
await VnUser.signin(unauthCtx, 'employee', 'nightmare', options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.message).toBe('Pass expired');
|
||||
|
||||
await employee.updateAttribute('passExpired', null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function getBrowser() {
|
|||
args,
|
||||
defaultViewport: null,
|
||||
headless: headless,
|
||||
slowMo: 1, // slow down by ms
|
||||
slowMo: 20, // slow down by ms
|
||||
// ignoreDefaultArgs: ['--disable-extensions'],
|
||||
// executablePath: '/usr/bin/google-chrome-stable',
|
||||
// executablePath: '/usr/bin/firefox-developer-edition',
|
||||
|
|
|
@ -16,6 +16,7 @@ describe('ChangePassword path', async() => {
|
|||
await browser.close();
|
||||
});
|
||||
|
||||
const badPassword = 'badpass';
|
||||
const oldPassword = 'nightmare';
|
||||
const newPassword = 'newPass.1234';
|
||||
describe('Bad login', async() => {
|
||||
|
@ -37,13 +38,22 @@ describe('ChangePassword path', async() => {
|
|||
expect(message.text).toContain('Invalid current password');
|
||||
|
||||
// Bad attempt: password not meet requirements
|
||||
message = await page.sendForm($.form, {
|
||||
oldPassword: oldPassword,
|
||||
newPassword: badPassword,
|
||||
repeatPassword: badPassword
|
||||
});
|
||||
|
||||
expect(message.text).toContain('Password does not meet requirements');
|
||||
|
||||
// Bad attempt: same password
|
||||
message = await page.sendForm($.form, {
|
||||
oldPassword: oldPassword,
|
||||
newPassword: oldPassword,
|
||||
repeatPassword: oldPassword
|
||||
});
|
||||
|
||||
expect(message.text).toContain('Password does not meet requirements');
|
||||
expect(message.text).toContain('You can not use the same password');
|
||||
|
||||
// Correct attempt: change password
|
||||
message = await page.sendForm($.form, {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Account Alias create and basic data path', () => {
|
||||
fdescribe('Account Alias create and basic data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@ export default class Controller {
|
|||
}
|
||||
|
||||
$onInit() {
|
||||
this.oldPassword = 'nightmare';
|
||||
this.repeatPassword = 'test.1234';
|
||||
this.newPassword = 'test.1234';
|
||||
this.verificationCode = '1234';
|
||||
if (!this.$state.params.id)
|
||||
this.$state.go('login');
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.setPassword = async function(id, newPassword) {
|
||||
await Self.app.models.VnUser.setPassword(id, newPassword);
|
||||
Self.setPassword = async function(id, newPassword, options) {
|
||||
await Self.app.models.VnUser.setPassword(id, newPassword, options);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,8 +8,18 @@ describe('Account setPassword()', () => {
|
|||
});
|
||||
|
||||
it('should update password when it passes requirements', async() => {
|
||||
let req = models.Account.setPassword(1, 'Very$ecurePa22.');
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
await expectAsync(req).toBeResolved();
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Account.setPassword(1, 'Very$ecurePa22.', options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue