refactor(core): Post-release refactorings of Public API (#3495)

*  Post-release refactorings

* 🧪 Add `--forceExit`

* 🛠 typing refactor (#3486)

* 🐛 Fix middleware arguments

* 👕 Fix lint

*  Restore commented out block

Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
This commit is contained in:
Iván Ovejero
2022-06-14 18:32:19 +02:00
committed by GitHub
parent 2ebcf4bb91
commit b8e3bcc052
19 changed files with 307 additions and 343 deletions

View File

@@ -1,7 +1,7 @@
import express = require('express');
import express from 'express';
import { ActiveWorkflowRunner } from '../../../src';
import config = require('../../../config');
import config from '../../../config';
import { Role } from '../../../src/databases/entities/Role';
import { randomApiKey } from '../shared/random';
@@ -11,11 +11,8 @@ import * as testDb from '../shared/testDb';
let app: express.Application;
let testDbName = '';
let globalOwnerRole: Role;
let workflowRunner: ActiveWorkflowRunner.ActiveWorkflowRunner;
jest.mock('../../../src/telemetry');
beforeAll(async () => {
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
const initResult = await testDb.init();
@@ -25,21 +22,29 @@ beforeAll(async () => {
utils.initTestTelemetry();
utils.initTestLogger();
// initializing binary manager leave some async operations open
// TODO mockup binary data mannager to avoid error
await utils.initBinaryManager();
await utils.initNodeTypes();
workflowRunner = await utils.initActiveWorkflowRunner();
});
beforeEach(async () => {
// do not combine calls - shared tables must be cleared first and separately
await testDb.truncate(['SharedCredentials', 'SharedWorkflow'], testDbName);
await testDb.truncate(['User', 'Workflow', 'Credentials', 'Execution', 'Settings'], testDbName);
await testDb.truncate(
[
'SharedCredentials',
'SharedWorkflow',
'User',
'Workflow',
'Credentials',
'Execution',
'Settings',
],
testDbName,
);
config.set('userManagement.disabled', false);
config.set('userManagement.isInstanceOwnerSetUp', true);
config.set('userManagement.emails.mode', 'smtp');
});
afterEach(async () => {
@@ -50,7 +55,7 @@ afterAll(async () => {
await testDb.terminate(testDbName);
});
test.skip('GET /executions/:executionId should fail due to missing API Key', async () => {
test('GET /executions/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -65,7 +70,7 @@ test.skip('GET /executions/:executionId should fail due to missing API Key', asy
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions/:executionId should fail due to invalid API Key', async () => {
test('GET /executions/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -81,7 +86,7 @@ test.skip('GET /executions/:executionId should fail due to invalid API Key', asy
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions/:executionId should get an execution', async () => {
test('GET /executions/:id should get an execution', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -93,7 +98,7 @@ test.skip('GET /executions/:executionId should get an execution', async () => {
const workflow = await testDb.createWorkflow({}, owner);
const execution = await testDb.createSuccessfullExecution(workflow);
const execution = await testDb.createSuccessfulExecution(workflow);
const response = await authOwnerAgent.get(`/executions/${execution.id}`);
@@ -122,7 +127,7 @@ test.skip('GET /executions/:executionId should get an execution', async () => {
expect(waitTill).toBeNull();
});
test.skip('DELETE /executions/:executionId should fail due to missing API Key', async () => {
test('DELETE /executions/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -137,7 +142,7 @@ test.skip('DELETE /executions/:executionId should fail due to missing API Key',
expect(response.statusCode).toBe(401);
});
test.skip('DELETE /executions/:executionId should fail due to invalid API Key', async () => {
test('DELETE /executions/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -153,7 +158,7 @@ test.skip('DELETE /executions/:executionId should fail due to invalid API Key',
expect(response.statusCode).toBe(401);
});
test.skip('DELETE /executions/:executionId should delete an execution', async () => {
test('DELETE /executions/:id should delete an execution', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -165,7 +170,7 @@ test.skip('DELETE /executions/:executionId should delete an execution', async ()
const workflow = await testDb.createWorkflow({}, owner);
const execution = await testDb.createSuccessfullExecution(workflow);
const execution = await testDb.createSuccessfulExecution(workflow);
const response = await authOwnerAgent.delete(`/executions/${execution.id}`);
@@ -194,7 +199,7 @@ test.skip('DELETE /executions/:executionId should delete an execution', async ()
expect(waitTill).toBeNull();
});
test.skip('GET /executions should fail due to missing API Key', async () => {
test('GET /executions should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -209,7 +214,7 @@ test.skip('GET /executions should fail due to missing API Key', async () => {
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions should fail due to invalid API Key', async () => {
test('GET /executions should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -225,7 +230,7 @@ test.skip('GET /executions should fail due to invalid API Key', async () => {
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions should retrieve all successfull executions', async () => {
test('GET /executions should retrieve all successfull executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -237,7 +242,7 @@ test.skip('GET /executions should retrieve all successfull executions', async ()
const workflow = await testDb.createWorkflow({}, owner);
const successfullExecution = await testDb.createSuccessfullExecution(workflow);
const successfullExecution = await testDb.createSuccessfulExecution(workflow);
await testDb.createErrorExecution(workflow);
@@ -272,7 +277,7 @@ test.skip('GET /executions should retrieve all successfull executions', async ()
expect(waitTill).toBeNull();
});
test.skip('GET /executions should retrieve all error executions', async () => {
test('GET /executions should retrieve all error executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -284,7 +289,7 @@ test.skip('GET /executions should retrieve all error executions', async () => {
const workflow = await testDb.createWorkflow({}, owner);
await testDb.createSuccessfullExecution(workflow);
await testDb.createSuccessfulExecution(workflow);
const errorExecution = await testDb.createErrorExecution(workflow);
@@ -319,7 +324,7 @@ test.skip('GET /executions should retrieve all error executions', async () => {
expect(waitTill).toBeNull();
});
test.skip('GET /executions should return all waiting executions', async () => {
test('GET /executions should return all waiting executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -331,7 +336,7 @@ test.skip('GET /executions should return all waiting executions', async () => {
const workflow = await testDb.createWorkflow({}, owner);
await testDb.createSuccessfullExecution(workflow);
await testDb.createSuccessfulExecution(workflow);
await testDb.createErrorExecution(workflow);
@@ -368,7 +373,7 @@ test.skip('GET /executions should return all waiting executions', async () => {
expect(new Date(waitTill).getTime()).toBeGreaterThan(Date.now() - 1000);
});
test.skip('GET /executions should retrieve all executions of specific workflow', async () => {
test('GET /executions should retrieve all executions of specific workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -384,10 +389,10 @@ test.skip('GET /executions should retrieve all executions of specific workflow',
2,
workflow,
// @ts-ignore
testDb.createSuccessfullExecution,
testDb.createSuccessfulExecution,
);
// @ts-ignore
await testDb.createManyExecutions(2, workflow2, testDb.createSuccessfullExecution);
await testDb.createManyExecutions(2, workflow2, testDb.createSuccessfulExecution);
const response = await authOwnerAgent.get(`/executions`).query({
workflowId: workflow.id.toString(),