refactor(core): Make launcher auth easier to debug (#11768)

Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
Iván Ovejero
2024-11-19 09:32:19 +01:00
committed by GitHub
parent 6cd9b996af
commit 4880d1a92a
4 changed files with 30 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import { TaskRunnersConfig } from '@n8n/config';
import Container from 'typedi';
import { MissingAuthTokenError } from '@/runners/errors/missing-auth-token.error';
import { TaskRunnerModule } from '@/runners/task-runner-module';
import { DefaultTaskRunnerDisconnectAnalyzer } from '../../../src/runners/default-task-runner-disconnect-analyzer';
@@ -10,6 +11,7 @@ describe('TaskRunnerModule in external mode', () => {
const runnerConfig = Container.get(TaskRunnersConfig);
runnerConfig.mode = 'external';
runnerConfig.port = 0;
runnerConfig.authToken = 'test';
const module = Container.get(TaskRunnerModule);
afterEach(async () => {
@@ -24,6 +26,17 @@ describe('TaskRunnerModule in external mode', () => {
await expect(module.start()).rejects.toThrow('Task runner is disabled');
});
it('should throw if auth token is missing', async () => {
const runnerConfig = new TaskRunnersConfig();
runnerConfig.mode = 'external';
runnerConfig.enabled = true;
runnerConfig.authToken = '';
const module = new TaskRunnerModule(runnerConfig);
await expect(module.start()).rejects.toThrowError(MissingAuthTokenError);
});
it('should start the task runner', async () => {
runnerConfig.enabled = true;