mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Finish removing UserManagementHelper (no-changelog) (#8418)
This commit is contained in:
@@ -3,7 +3,6 @@ import { In } from 'typeorm';
|
||||
import type { IUser } from 'n8n-workflow';
|
||||
|
||||
import type { ListQuery } from '@/requests';
|
||||
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
@@ -16,10 +15,11 @@ import { getCredentialOwnerRole, getGlobalMemberRole, getGlobalOwnerRole } from
|
||||
import { createManyUsers, createUser, createUserShell } from './shared/db/users';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import Container from 'typedi';
|
||||
import { License } from '@/License';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
|
||||
const sharingSpy = jest.spyOn(UserManagementHelpers, 'isSharingEnabled').mockReturnValue(true);
|
||||
const sharingSpy = jest.spyOn(License.prototype, 'isSharingEnabled').mockReturnValue(true);
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['credentials'] });
|
||||
|
||||
let globalMemberRole: Role;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
import config from '@/config';
|
||||
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
|
||||
import type { ListQuery } from '@/requests';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import type { User } from '@db/entities/User';
|
||||
@@ -16,9 +15,10 @@ import { createManyUsers, createUser } from './shared/db/users';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import Container from 'typedi';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { License } from '@/License';
|
||||
|
||||
// mock that credentialsSharing is not enabled
|
||||
jest.spyOn(UserManagementHelpers, 'isSharingEnabled').mockReturnValue(false);
|
||||
jest.spyOn(License.prototype, 'isSharingEnabled').mockReturnValue(false);
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['credentials'] });
|
||||
|
||||
let globalOwnerRole: Role;
|
||||
|
||||
@@ -7,7 +7,6 @@ import type { Role } from '@db/entities/Role';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
|
||||
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
|
||||
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
|
||||
import { Push } from '@/push';
|
||||
import { WorkflowSharingService } from '@/workflows/workflowSharing.service';
|
||||
|
||||
@@ -25,6 +24,7 @@ import {
|
||||
} from '../shared/db/roles';
|
||||
import { createUser } from '../shared/db/users';
|
||||
import { createWorkflow, getWorkflowSharing, shareWorkflowWithUsers } from '../shared/db/workflows';
|
||||
import { License } from '@/License';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
|
||||
let globalMemberRole: Role;
|
||||
@@ -39,7 +39,7 @@ let saveCredential: SaveCredentialFunction;
|
||||
const activeWorkflowRunner = mockInstance(ActiveWorkflowRunner);
|
||||
mockInstance(Push);
|
||||
|
||||
const sharingSpy = jest.spyOn(UserManagementHelpers, 'isSharingEnabled').mockReturnValue(true);
|
||||
const sharingSpy = jest.spyOn(License.prototype, 'isSharingEnabled').mockReturnValue(true);
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['workflows'],
|
||||
enabledFeatures: ['feat:sharing'],
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { SuperAgentTest } from 'supertest';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { INode, IPinData } from 'n8n-workflow';
|
||||
|
||||
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { WorkflowRepository } from '@db/repositories/workflow.repository';
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
@@ -23,11 +22,12 @@ import { saveCredential } from '../shared/db/credentials';
|
||||
import { createOwner } from '../shared/db/users';
|
||||
import { createWorkflow } from '../shared/db/workflows';
|
||||
import { createTag } from '../shared/db/tags';
|
||||
import { License } from '@/License';
|
||||
|
||||
let owner: User;
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
|
||||
jest.spyOn(UserManagementHelpers, 'isSharingEnabled').mockReturnValue(false);
|
||||
jest.spyOn(License.prototype, 'isSharingEnabled').mockReturnValue(false);
|
||||
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['workflows'] });
|
||||
const license = testServer.license;
|
||||
@@ -640,7 +640,7 @@ describe('POST /workflows/run', () => {
|
||||
const enterpriseWorkflowService = Container.get(EnterpriseWorkflowService);
|
||||
const workflowRepository = Container.get(WorkflowRepository);
|
||||
|
||||
sharingSpy = jest.spyOn(UserManagementHelpers, 'isSharingEnabled');
|
||||
sharingSpy = jest.spyOn(License.prototype, 'isSharingEnabled');
|
||||
tamperingSpy = jest.spyOn(enterpriseWorkflowService, 'preventTampering');
|
||||
workflow = workflowRepository.create({ id: uuid() });
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ describe('ExecutionsController', () => {
|
||||
mock(),
|
||||
workflowSharingService,
|
||||
activeExecutionService,
|
||||
mock(),
|
||||
).getActive(req);
|
||||
|
||||
expect(activeExecutionService.findManyInQueueMode).toHaveBeenCalled();
|
||||
@@ -48,6 +49,7 @@ describe('ExecutionsController', () => {
|
||||
mock(),
|
||||
workflowSharingService,
|
||||
activeExecutionService,
|
||||
mock(),
|
||||
).getActive(req);
|
||||
|
||||
expect(activeExecutionService.findManyInQueueMode).not.toHaveBeenCalled();
|
||||
@@ -67,6 +69,7 @@ describe('ExecutionsController', () => {
|
||||
mock(),
|
||||
workflowSharingService,
|
||||
activeExecutionService,
|
||||
mock(),
|
||||
).stop(req);
|
||||
|
||||
await expect(promise).rejects.toThrow(NotFoundError);
|
||||
@@ -82,6 +85,7 @@ describe('ExecutionsController', () => {
|
||||
mock(),
|
||||
workflowSharingService,
|
||||
activeExecutionService,
|
||||
mock(),
|
||||
).stop(req);
|
||||
|
||||
expect(activeExecutionService.stop).toHaveBeenCalled();
|
||||
|
||||
@@ -17,8 +17,6 @@ import { UserService } from '@/services/user.service';
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
jest.mock('@/UserManagement/UserManagementHelper', () => ({ getWorkflowOwner: jest.fn() }));
|
||||
|
||||
describe('EventsService', () => {
|
||||
const dbType = config.getEnv('database.type');
|
||||
const fakeUser = mock<User>({ id: 'abcde-fghij' });
|
||||
|
||||
Reference in New Issue
Block a user