diff --git a/packages/services/test/gateway/LocalGateway.spec.ts b/packages/services/test/gateway/LocalGateway.spec.ts index 9efb587f..a37978af 100644 --- a/packages/services/test/gateway/LocalGateway.spec.ts +++ b/packages/services/test/gateway/LocalGateway.spec.ts @@ -3,12 +3,14 @@ import { describe, expect, it } from 'vitest'; import InvalidTrustKey from '../../src/gateway/errors/InvalidTrustKey'; -import { LOCAL_GATEWAYS, REMOTE_WORKERS, VALUES } from './fixtures'; +import { LOCAL_GATEWAYS, REMOTE_WORKERS } from './fixtures'; const publicGateway = LOCAL_GATEWAYS.PUBLIC; const protectedGateway = LOCAL_GATEWAYS.PROTECTED; const emptyWorker = REMOTE_WORKERS.EMPTY; +const trustedWorker = REMOTE_WORKERS.TRUSTED; +const untrustedWorker = REMOTE_WORKERS.UNTRUSTED; describe('gateway/LocalGateway', () => { @@ -23,14 +25,14 @@ describe('gateway/LocalGateway', () => it('should add a worker with a valid trust key to a protected gateway', () => { - const promise = protectedGateway.addWorker(emptyWorker, VALUES.TRUST_KEY); + const promise = protectedGateway.addWorker(trustedWorker); expect(promise).resolves.toBeUndefined(); }); it('should not add a worker with an invalid trust key to a protected gateway', () => { - const promise = protectedGateway.addWorker(emptyWorker, 'INCORRECT_ACCESS_KEY'); + const promise = protectedGateway.addWorker(untrustedWorker); expect(promise).rejects.toEqual(new InvalidTrustKey()); }); diff --git a/packages/services/test/gateway/fixtures/localGateways.fixture.ts b/packages/services/test/gateway/fixtures/localGateways.fixture.ts index e171ab30..18fb3459 100644 --- a/packages/services/test/gateway/fixtures/localGateways.fixture.ts +++ b/packages/services/test/gateway/fixtures/localGateways.fixture.ts @@ -4,7 +4,7 @@ import LocalGateway from '../../../src/gateway/LocalGateway'; import { VALUES } from './values.fixture'; const url = VALUES.URL; -const trustKey = VALUES.TRUST_KEY; +const trustKey = VALUES.VALID_TRUST_KEY; const publicGateway = new LocalGateway({ url }); const protectedGateway = new LocalGateway({ url, trustKey}); diff --git a/packages/services/test/gateway/fixtures/remoteWorkers.fixture.ts b/packages/services/test/gateway/fixtures/remoteWorkers.fixture.ts index 1c0d1826..4a54b50f 100644 --- a/packages/services/test/gateway/fixtures/remoteWorkers.fixture.ts +++ b/packages/services/test/gateway/fixtures/remoteWorkers.fixture.ts @@ -26,6 +26,9 @@ const remote = REMOTES.DUMMY; const noProcedureNames = new Set(); const emptyWorker = new RemoteWorker({ url, procedureNames: noProcedureNames, remote }); +const trustedWorker = new RemoteWorker({ url, procedureNames: noProcedureNames, remote, trustKey: VALUES.VALID_TRUST_KEY }); +const untrustedWorker = new RemoteWorker({ url, procedureNames: noProcedureNames, remote, trustKey: VALUES.INVALID_TRUST_KEY }); + const firstProcedureNames = new Set(['first']); const firstWorker = new RemoteWorker({ url, procedureNames: firstProcedureNames, remote }); @@ -38,6 +41,8 @@ const unhealthyWorker = new UnhealthyWorker({ url, procedureNames: noProcedureNa export const REMOTE_WORKERS = { EMPTY: emptyWorker, + TRUSTED: trustedWorker, + UNTRUSTED: untrustedWorker, FIRST: firstWorker, SECOND: secondWorker, HEALTHY: healthyWorker, diff --git a/packages/services/test/gateway/fixtures/remotes.fixture.ts b/packages/services/test/gateway/fixtures/remotes.fixture.ts index 0ef87e97..91789d8f 100644 --- a/packages/services/test/gateway/fixtures/remotes.fixture.ts +++ b/packages/services/test/gateway/fixtures/remotes.fixture.ts @@ -39,6 +39,12 @@ class DummyRemote implements Remote throw new NotImplemented(); } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + removeWorker(workerUrl: string, trustKey?: string): Promise + { + throw new NotImplemented(); + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars async run(request: Request): Promise { diff --git a/packages/services/test/gateway/fixtures/values.fixture.ts b/packages/services/test/gateway/fixtures/values.fixture.ts index d292da82..13c42cb5 100644 --- a/packages/services/test/gateway/fixtures/values.fixture.ts +++ b/packages/services/test/gateway/fixtures/values.fixture.ts @@ -2,5 +2,6 @@ export const VALUES = { URL: 'http://localhost:80', - TRUST_KEY: 'MY_TRUSTED_ACCESS_KEY' + VALID_TRUST_KEY: 'MY_TRUSTED_ACCESS_KEY', + INVALID_TRUST_KEY: 'INCORRECT_ACCESS_KEY' };