mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-23 12:49:09 +00:00
ci(core): Reduce memory usage in tests (part-1) (no-changelog) (#7654)
This commit is contained in:
committed by
GitHub
parent
6a53c2a375
commit
0346b211a7
@@ -9,6 +9,7 @@ import { UserService } from '@/services/user.service';
|
||||
import { randomDigit, randomString, randomValidPassword, uniqueId } from '../shared/random';
|
||||
import * as testDb from '../shared/testDb';
|
||||
import * as utils from '../shared/utils';
|
||||
import { createUser, createUserWithMfaEnabled } from '../shared/db/users';
|
||||
|
||||
jest.mock('@/telemetry');
|
||||
|
||||
@@ -22,7 +23,7 @@ const testServer = utils.setupTestServer({
|
||||
beforeEach(async () => {
|
||||
await testDb.truncate(['User']);
|
||||
|
||||
owner = await testDb.createUser({ globalRole: globalOwnerRole });
|
||||
owner = await createUser({ globalRole: globalOwnerRole });
|
||||
|
||||
config.set('userManagement.disabled', false);
|
||||
});
|
||||
@@ -174,7 +175,7 @@ describe('Enable MFA setup', () => {
|
||||
|
||||
describe('Disable MFA setup', () => {
|
||||
test('POST /disable should disable login with MFA', async () => {
|
||||
const { user } = await testDb.createUserWithMfaEnabled();
|
||||
const { user } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authAgentFor(user).delete('/mfa/disable');
|
||||
|
||||
@@ -193,7 +194,7 @@ describe('Disable MFA setup', () => {
|
||||
|
||||
describe('Change password with MFA enabled', () => {
|
||||
test('PATCH /me/password should fail due to missing MFA token', async () => {
|
||||
const { user, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const newPassword = randomPassword();
|
||||
|
||||
@@ -206,7 +207,7 @@ describe('Change password with MFA enabled', () => {
|
||||
});
|
||||
|
||||
test('POST /change-password should fail due to missing MFA token', async () => {
|
||||
await testDb.createUserWithMfaEnabled();
|
||||
await createUserWithMfaEnabled();
|
||||
|
||||
const newPassword = randomValidPassword();
|
||||
|
||||
@@ -220,7 +221,7 @@ describe('Change password with MFA enabled', () => {
|
||||
});
|
||||
|
||||
test('POST /change-password should fail due to invalid MFA token', async () => {
|
||||
await testDb.createUserWithMfaEnabled();
|
||||
await createUserWithMfaEnabled();
|
||||
|
||||
const newPassword = randomValidPassword();
|
||||
|
||||
@@ -236,7 +237,7 @@ describe('Change password with MFA enabled', () => {
|
||||
});
|
||||
|
||||
test('POST /change-password should update password', async () => {
|
||||
const { user, rawSecret } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawSecret } = await createUserWithMfaEnabled();
|
||||
|
||||
const newPassword = randomValidPassword();
|
||||
|
||||
@@ -272,7 +273,7 @@ describe('Login', () => {
|
||||
test('POST /login with email/password should succeed when mfa is disabled', async () => {
|
||||
const password = randomPassword();
|
||||
|
||||
const user = await testDb.createUser({ password });
|
||||
const user = await createUser({ password });
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -303,7 +304,7 @@ describe('Login', () => {
|
||||
});
|
||||
|
||||
test('POST /login with email/password should fail when mfa is enabled', async () => {
|
||||
const { user, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -314,7 +315,7 @@ describe('Login', () => {
|
||||
|
||||
describe('Login with MFA token', () => {
|
||||
test('POST /login should fail due to invalid MFA token', async () => {
|
||||
const { user, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -324,7 +325,7 @@ describe('Login', () => {
|
||||
});
|
||||
|
||||
test('POST /login should fail due two MFA step needed', async () => {
|
||||
const { user, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -335,7 +336,7 @@ describe('Login', () => {
|
||||
});
|
||||
|
||||
test('POST /login should succeed with MFA token', async () => {
|
||||
const { user, rawSecret, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawSecret, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const token = new TOTPService().generateTOTP(rawSecret);
|
||||
|
||||
@@ -352,7 +353,7 @@ describe('Login', () => {
|
||||
|
||||
describe('Login with recovery code', () => {
|
||||
test('POST /login should fail due to invalid MFA recovery code', async () => {
|
||||
const { user, rawPassword } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -362,7 +363,7 @@ describe('Login', () => {
|
||||
});
|
||||
|
||||
test('POST /login should succeed with MFA recovery code', async () => {
|
||||
const { user, rawPassword, rawRecoveryCodes } = await testDb.createUserWithMfaEnabled();
|
||||
const { user, rawPassword, rawRecoveryCodes } = await createUserWithMfaEnabled();
|
||||
|
||||
const response = await testServer.authlessAgent
|
||||
.post('/login')
|
||||
@@ -385,7 +386,7 @@ describe('Login', () => {
|
||||
});
|
||||
|
||||
test('POST /login with MFA recovery code should update hasRecoveryCodesLeft property', async () => {
|
||||
const { user, rawPassword, rawRecoveryCodes } = await testDb.createUserWithMfaEnabled({
|
||||
const { user, rawPassword, rawRecoveryCodes } = await createUserWithMfaEnabled({
|
||||
numberOfRecoveryCodes: 1,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user