feat: Add custom data to public API execution endpoints (#9705)

This commit is contained in:
Val
2024-06-17 12:38:10 +01:00
committed by GitHub
parent d615711728
commit a1046607bf
4 changed files with 59 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ import {
} from '../shared/db/workflows';
import {
createErrorExecution,
createExecution,
createManyExecutions,
createSuccessfulExecution,
createWaitingExecution,
@@ -125,6 +126,49 @@ describe('GET /executions/:id', () => {
expect(response.statusCode).toBe(200);
});
test('member should not be able to fetch custom data when includeData is not set', async () => {
const workflow = await createWorkflow({}, user1);
const execution = await createExecution(
{
finished: true,
status: 'success',
metadata: [
{ key: 'test1', value: 'value1' },
{ key: 'test2', value: 'value2' },
],
},
workflow,
);
const response = await authUser1Agent.get(`/executions/${execution.id}`);
expect(response.statusCode).toBe(200);
expect(response.body.customData).toBeUndefined();
});
test('member should be able to fetch custom data when includeData=true', async () => {
const workflow = await createWorkflow({}, user1);
const execution = await createExecution(
{
finished: true,
status: 'success',
metadata: [
{ key: 'test1', value: 'value1' },
{ key: 'test2', value: 'value2' },
],
},
workflow,
);
const response = await authUser1Agent.get(`/executions/${execution.id}?includeData=true`);
expect(response.statusCode).toBe(200);
expect(response.body.customData).toEqual({
test1: 'value1',
test2: 'value2',
});
});
test('member should not get an execution of another user without the workflow being shared', async () => {
const workflow = await createWorkflow({}, owner);