mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
## Summary Restore workflow ID during execution creation removed by [this PR](https://github.com/n8n-io/n8n/pull/8002/files#diff-c8cbb62ca9ab2ae45e5f565cd8c63fff6475809a6241ea0b90acc575615224af). The missing workflow ID, and more generally the fact that `workflow.id` is optional when it should not be, causes `PermissionChecker.check` to misreport a credential as inaccessible when it should be accessible. More generally, start reporting ID-less workflows so we can root them out and prevent this at type level. ## Related tickets and issues https://n8nio.slack.com/archives/C035KBDA917/p1702539465555529
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import Container from 'typedi';
|
|
import { ExecutionRepository } from '@db/repositories/execution.repository';
|
|
import { ExecutionDataRepository } from '@db/repositories/executionData.repository';
|
|
import * as testDb from '../../shared/testDb';
|
|
import { createWorkflow } from '../../shared/db/workflows';
|
|
|
|
describe('ExecutionRepository', () => {
|
|
beforeAll(async () => {
|
|
await testDb.init();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
await testDb.truncate(['Workflow', 'Execution']);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await testDb.terminate();
|
|
});
|
|
|
|
describe('createNewExecution', () => {
|
|
it('should save execution data', async () => {
|
|
const executionRepo = Container.get(ExecutionRepository);
|
|
const workflow = await createWorkflow();
|
|
const executionId = await executionRepo.createNewExecution({
|
|
workflowId: workflow.id,
|
|
data: {
|
|
resultData: {},
|
|
},
|
|
workflowData: workflow,
|
|
mode: 'manual',
|
|
startedAt: new Date(),
|
|
status: 'new',
|
|
finished: false,
|
|
});
|
|
|
|
expect(executionId).toBeDefined();
|
|
|
|
const executionEntity = await executionRepo.findOneBy({ id: executionId });
|
|
expect(executionEntity?.id).toEqual(executionId);
|
|
expect(executionEntity?.workflowId).toEqual(workflow.id);
|
|
expect(executionEntity?.status).toEqual('new');
|
|
|
|
const executionDataRepo = Container.get(ExecutionDataRepository);
|
|
const executionData = await executionDataRepo.findOneBy({ executionId });
|
|
expect(executionData?.workflowData).toEqual({
|
|
id: workflow.id,
|
|
connections: workflow.connections,
|
|
nodes: workflow.nodes,
|
|
name: workflow.name,
|
|
});
|
|
expect(executionData?.data).toEqual('[{"resultData":"1"},{}]');
|
|
});
|
|
});
|
|
});
|