mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Decouple community packages from security audit (#17818)
This commit is contained in:
@@ -7,6 +7,7 @@ import { v4 as uuid } from 'uuid';
|
||||
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
||||
import { NodeTypes } from '@/node-types';
|
||||
import { OFFICIAL_RISKY_NODE_TYPES, NODES_REPORT } from '@/security-audit/constants';
|
||||
import { PackagesRepository } from '@/security-audit/security-audit.repository';
|
||||
import { SecurityAuditService } from '@/security-audit/security-audit.service';
|
||||
import { toReportTitle } from '@/security-audit/utils';
|
||||
import { CommunityPackagesService } from '@/community-packages/community-packages.service';
|
||||
@@ -18,6 +19,7 @@ nodesAndCredentials.getCustomDirectories.mockReturnValue([]);
|
||||
mockInstance(NodeTypes);
|
||||
const communityPackagesService = mockInstance(CommunityPackagesService);
|
||||
Container.set(CommunityPackagesService, communityPackagesService);
|
||||
const packagesRepository = mockInstance(PackagesRepository);
|
||||
|
||||
let securityAuditService: SecurityAuditService;
|
||||
|
||||
@@ -37,7 +39,7 @@ afterAll(async () => {
|
||||
});
|
||||
|
||||
test('should report risky official nodes', async () => {
|
||||
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
|
||||
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
|
||||
const map = [...OFFICIAL_RISKY_NODE_TYPES].reduce<{ [nodeType: string]: string }>((acc, cur) => {
|
||||
return (acc[cur] = uuid()), acc;
|
||||
}, {});
|
||||
@@ -82,7 +84,7 @@ test('should report risky official nodes', async () => {
|
||||
});
|
||||
|
||||
test('should not report non-risky official nodes', async () => {
|
||||
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
|
||||
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
|
||||
await saveManualTriggerWorkflow();
|
||||
|
||||
const testAudit = await securityAuditService.run(['nodes']);
|
||||
@@ -99,7 +101,7 @@ test('should not report non-risky official nodes', async () => {
|
||||
});
|
||||
|
||||
test('should report community nodes', async () => {
|
||||
communityPackagesService.getAllInstalledPackages.mockResolvedValue(MOCK_PACKAGE);
|
||||
packagesRepository.find.mockResolvedValue(MOCK_PACKAGE);
|
||||
|
||||
const testAudit = await securityAuditService.run(['nodes']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user