From 59dbe0f4c7cdcfa3217a3a779dc6ea6c84c49b03 Mon Sep 17 00:00:00 2001 From: Eric Camellini Date: Tue, 12 Nov 2024 17:07:36 +0100 Subject: [PATCH 1/2] Fixing TS errors in delegation routers (#1194) --- packages/delegation-process/src/app.ts | 2 +- .../src/routers/DelegationProducerRouter.ts | 5 ++--- packages/delegation-process/src/routers/DelegationRouter.ts | 5 ++--- .../src/{utilites => utilities}/errorMappers.ts | 0 4 files changed, 5 insertions(+), 7 deletions(-) rename packages/delegation-process/src/{utilites => utilities}/errorMappers.ts (100%) diff --git a/packages/delegation-process/src/app.ts b/packages/delegation-process/src/app.ts index 007a7b0706..f111eb52fa 100644 --- a/packages/delegation-process/src/app.ts +++ b/packages/delegation-process/src/app.ts @@ -11,7 +11,7 @@ import delegationProducerRouter from "./routers/DelegationProducerRouter.js"; import delegationRouter from "./routers/DelegationRouter.js"; import { config } from "./config/config.js"; -const serviceName = "delgation-process"; +const serviceName = "delegation-process"; const app = zodiosCtx.app(); diff --git a/packages/delegation-process/src/routers/DelegationProducerRouter.ts b/packages/delegation-process/src/routers/DelegationProducerRouter.ts index 8e1dd50659..be00ca4d70 100644 --- a/packages/delegation-process/src/routers/DelegationProducerRouter.ts +++ b/packages/delegation-process/src/routers/DelegationProducerRouter.ts @@ -1,4 +1,3 @@ -import { ZodiosEndpointDefinitions } from "@zodios/core"; import { ZodiosRouter } from "@zodios/express"; import { delegationApi } from "pagopa-interop-api-clients"; import { @@ -24,7 +23,7 @@ import { revokeDelegationErrorMapper, approveDelegationErrorMapper, rejectDelegationErrorMapper, -} from "../utilites/errorMappers.js"; +} from "../utilities/errorMappers.js"; const readModelService = readModelServiceBuilder( ReadModelRepository.init(config) @@ -52,7 +51,7 @@ const { ADMIN_ROLE } = userRoles; const delegationProducerRouter = ( ctx: ZodiosContext -): ZodiosRouter => { +): ZodiosRouter => { const delegationProducerRouter = ctx.router(delegationApi.producerApi.api, { validationErrorHandler: zodiosValidationErrorToApiProblem, }); diff --git a/packages/delegation-process/src/routers/DelegationRouter.ts b/packages/delegation-process/src/routers/DelegationRouter.ts index 99f603305a..372da10e0a 100644 --- a/packages/delegation-process/src/routers/DelegationRouter.ts +++ b/packages/delegation-process/src/routers/DelegationRouter.ts @@ -1,4 +1,3 @@ -import { ZodiosEndpointDefinitions } from "@zodios/core"; import { ZodiosRouter } from "@zodios/express"; import { delegationApi } from "pagopa-interop-api-clients"; import { @@ -19,7 +18,7 @@ import { delegationToApiDelegation, } from "../model/domain/apiConverter.js"; import { makeApiProblem } from "../model/domain/errors.js"; -import { getDelegationErrorMapper } from "../utilites/errorMappers.js"; +import { getDelegationErrorMapper } from "../utilities/errorMappers.js"; import { delegationServiceBuilder } from "../services/delegationService.js"; const readModelService = readModelServiceBuilder( @@ -33,7 +32,7 @@ const { ADMIN_ROLE, API_ROLE, SECURITY_ROLE, M2M_ROLE, SUPPORT_ROLE } = const delegationRouter = ( ctx: ZodiosContext -): ZodiosRouter => { +): ZodiosRouter => { const delegationRouter = ctx.router(delegationApi.delegationApi.api, { validationErrorHandler: zodiosValidationErrorToApiProblem, }); diff --git a/packages/delegation-process/src/utilites/errorMappers.ts b/packages/delegation-process/src/utilities/errorMappers.ts similarity index 100% rename from packages/delegation-process/src/utilites/errorMappers.ts rename to packages/delegation-process/src/utilities/errorMappers.ts From 717cdc56aa0e94e3eb43fd0b687765bc6ea71c37 Mon Sep 17 00:00:00 2001 From: Carmine Porricelli Date: Tue, 12 Nov 2024 17:45:58 +0100 Subject: [PATCH 2/2] Small fixes and refactors in `delegation-process` (#1195) --- .../src/routers/DelegationProducerRouter.ts | 9 +- .../src/routers/DelegationRouter.ts | 37 +++--- .../src/services/delegationProducerService.ts | 33 +++--- .../src/services/delegationService.ts | 50 +++++---- .../src/utilities/errorMappers.ts | 12 +- .../test/approveProducerDelegation.test.ts | 58 +++++----- .../test/getDelegationById.test.ts | 9 +- .../test/getDelegations.test.ts | 106 ++++++++++-------- .../test/rejectProducerDelegation.test.ts | 46 +++++--- 9 files changed, 209 insertions(+), 151 deletions(-) diff --git a/packages/delegation-process/src/routers/DelegationProducerRouter.ts b/packages/delegation-process/src/routers/DelegationProducerRouter.ts index be00ca4d70..f9fbe342b3 100644 --- a/packages/delegation-process/src/routers/DelegationProducerRouter.ts +++ b/packages/delegation-process/src/routers/DelegationProducerRouter.ts @@ -123,10 +123,8 @@ const delegationProducerRouter = ( try { await delegationProducerService.approveProducerDelegation( - ctx.authData.organizationId, unsafeBrandId(delegationId), - ctx.correlationId, - ctx.logger + ctx ); return res.status(204).send(); @@ -152,10 +150,9 @@ const delegationProducerRouter = ( try { await delegationProducerService.rejectProducerDelegation( - ctx.authData.organizationId, unsafeBrandId(delegationId), - ctx.correlationId, - rejectionReason + rejectionReason, + ctx ); return res.status(204).send(); diff --git a/packages/delegation-process/src/routers/DelegationRouter.ts b/packages/delegation-process/src/routers/DelegationRouter.ts index 372da10e0a..82aa33063b 100644 --- a/packages/delegation-process/src/routers/DelegationRouter.ts +++ b/packages/delegation-process/src/routers/DelegationRouter.ts @@ -18,7 +18,10 @@ import { delegationToApiDelegation, } from "../model/domain/apiConverter.js"; import { makeApiProblem } from "../model/domain/errors.js"; -import { getDelegationErrorMapper } from "../utilities/errorMappers.js"; +import { + getDelegationsErrorMapper, + getDelegationByIdErrorMapper, +} from "../utilities/errorMappers.js"; import { delegationServiceBuilder } from "../services/delegationService.js"; const readModelService = readModelServiceBuilder( @@ -60,17 +63,20 @@ const delegationRouter = ( } = req.query; try { - const delegations = await delegationService.getDelegations({ - delegateIds: delegateIds.map(unsafeBrandId), - delegatorIds: delegatorIds.map(unsafeBrandId), - delegationStates: delegationStates.map( - apiDelegationStateToDelegationState - ), - eserviceIds: eserviceIds.map(unsafeBrandId), - kind: kind && apiDelegationKindToDelegationKind(kind), - offset, - limit, - }); + const delegations = await delegationService.getDelegations( + { + delegateIds: delegateIds.map(unsafeBrandId), + delegatorIds: delegatorIds.map(unsafeBrandId), + delegationStates: delegationStates.map( + apiDelegationStateToDelegationState + ), + eserviceIds: eserviceIds.map(unsafeBrandId), + kind: kind && apiDelegationKindToDelegationKind(kind), + offset, + limit, + }, + ctx.logger + ); return res.status(200).send( delegationApi.Delegations.parse({ @@ -83,7 +89,7 @@ const delegationRouter = ( } catch (error) { const errorRes = makeApiProblem( error, - getDelegationErrorMapper, + getDelegationsErrorMapper, ctx.logger, ctx.correlationId ); @@ -107,7 +113,8 @@ const delegationRouter = ( try { const delegation = await delegationService.getDelegationById( - unsafeBrandId(delegationId) + unsafeBrandId(delegationId), + ctx.logger ); return res @@ -120,7 +127,7 @@ const delegationRouter = ( } catch (error) { const errorRes = makeApiProblem( error, - getDelegationErrorMapper, + getDelegationByIdErrorMapper, ctx.logger, ctx.correlationId ); diff --git a/packages/delegation-process/src/services/delegationProducerService.ts b/packages/delegation-process/src/services/delegationProducerService.ts index dc4ada7d38..f323a8de45 100644 --- a/packages/delegation-process/src/services/delegationProducerService.ts +++ b/packages/delegation-process/src/services/delegationProducerService.ts @@ -4,12 +4,10 @@ import { DB, eventRepository, FileManager, - Logger, PDFGenerator, WithLogger, } from "pagopa-interop-commons"; import { - CorrelationId, Delegation, DelegationId, delegationEventToBinaryDataV2, @@ -78,7 +76,7 @@ export function delegationProducerServiceBuilder( const eserviceId = unsafeBrandId(delegationSeed.eserviceId); logger.info( - `Creating a delegation for tenant:${delegationSeed.delegateId} by producer:${delegatorId}` + `Creating a delegation for tenant ${delegationSeed.delegateId} by producer ${delegatorId}` ); assertDelegatorIsNotDelegate(delegatorId, delegateId); @@ -126,7 +124,7 @@ export function delegationProducerServiceBuilder( ): Promise { const delegatorId = unsafeBrandId(authData.organizationId); logger.info( - `Revoking delegation:${delegationId} by producer:${delegatorId}` + `Revoking delegation ${delegationId} by producer ${delegatorId}` ); const currentDelegation = await retrieveDelegationById( @@ -180,25 +178,29 @@ export function delegationProducerServiceBuilder( return revokedDelegation; }, async approveProducerDelegation( - delegateId: TenantId, delegationId: DelegationId, - correlationId: CorrelationId, - logger: Logger + { logger, correlationId, authData }: WithLogger ): Promise { + const delegateId = unsafeBrandId(authData.organizationId); + + logger.info( + `Approving delegation ${delegationId} by delegate ${delegateId}` + ); + const { data: delegation, metadata } = await retrieveDelegationById( readModelService, delegationId ); + assertIsDelegate(delegation, delegateId); + assertIsState(delegationState.waitingForApproval, delegation); + const [delegator, delegate, eservice] = await Promise.all([ retrieveTenantById(delegation.delegatorId), retrieveTenantById(delegation.delegateId), retrieveEserviceById(delegation.eserviceId), ]); - assertIsDelegate(delegation, delegateId); - assertIsState(delegationState.waitingForApproval, delegation); - const activationContract = await contractBuilder.createActivationContract( { delegation, @@ -237,11 +239,16 @@ export function delegationProducerServiceBuilder( ); }, async rejectProducerDelegation( - delegateId: TenantId, delegationId: DelegationId, - correlationId: CorrelationId, - rejectionReason: string + rejectionReason: string, + { logger, correlationId, authData }: WithLogger ): Promise { + const delegateId = unsafeBrandId(authData.organizationId); + + logger.info( + `Rejecting delegation ${delegationId} by delegate ${delegateId}` + ); + const { data: delegation, metadata } = await retrieveDelegationById( readModelService, delegationId diff --git a/packages/delegation-process/src/services/delegationService.ts b/packages/delegation-process/src/services/delegationService.ts index c5dfda5677..0b55683fb4 100644 --- a/packages/delegation-process/src/services/delegationService.ts +++ b/packages/delegation-process/src/services/delegationService.ts @@ -7,6 +7,7 @@ import { TenantId, WithMetadata, } from "pagopa-interop-models"; +import { Logger } from "pagopa-interop-commons"; import { delegationNotFound } from "../model/domain/errors.js"; import { ReadModelService } from "./readModelService.js"; @@ -24,31 +25,42 @@ export const retrieveDelegationById = async ( // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export function delegationServiceBuilder(readModelService: ReadModelService) { return { - async getDelegationById(delegationId: DelegationId): Promise { + async getDelegationById( + delegationId: DelegationId, + logger: Logger + ): Promise { + logger.info(`Retrieving delegation by id ${delegationId}`); + const delegation = await retrieveDelegationById( readModelService, delegationId ); return delegation.data; }, - // eslint-disable-next-line max-params - async getDelegations({ - delegateIds, - delegatorIds, - delegationStates, - eserviceIds, - kind, - offset, - limit, - }: { - delegateIds: TenantId[]; - delegatorIds: TenantId[]; - delegationStates: DelegationState[]; - eserviceIds: EServiceId[]; - kind: DelegationKind | undefined; - offset: number; - limit: number; - }): Promise { + async getDelegations( + { + delegateIds, + delegatorIds, + delegationStates, + eserviceIds, + kind, + offset, + limit, + }: { + delegateIds: TenantId[]; + delegatorIds: TenantId[]; + delegationStates: DelegationState[]; + eserviceIds: EServiceId[]; + kind: DelegationKind | undefined; + offset: number; + limit: number; + }, + logger: Logger + ): Promise { + logger.info( + `Retrieving delegations with filters: delegateIds=${delegateIds}, delegatorIds=${delegatorIds}, delegationStates=${delegationStates}, eserviceIds=${eserviceIds}, kind=${kind}, offset=${offset}, limit=${limit}` + ); + return readModelService.getDelegations({ delegateIds, delegatorIds, diff --git a/packages/delegation-process/src/utilities/errorMappers.ts b/packages/delegation-process/src/utilities/errorMappers.ts index b009d21344..98e2a40d3a 100644 --- a/packages/delegation-process/src/utilities/errorMappers.ts +++ b/packages/delegation-process/src/utilities/errorMappers.ts @@ -14,7 +14,12 @@ const { HTTP_STATUS_UNAUTHORIZED, } = constants; -export const getDelegationByIdsrrorMapper = ( +export const getDelegationsErrorMapper = ( + error: ApiError +): number => + match(error.code).otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR); + +export const getDelegationByIdErrorMapper = ( error: ApiError ): number => match(error.code) @@ -36,11 +41,6 @@ export const createProducerDelegationErrorMapper = ( ) .otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR); -export const getDelegationErrorMapper = (error: ApiError): number => - match(error.code) - .with("delegationNotFound", () => HTTP_STATUS_NOT_FOUND) - .otherwise(() => HTTP_STATUS_INTERNAL_SERVER_ERROR); - export const revokeDelegationErrorMapper = ( error: ApiError ): number => diff --git a/packages/delegation-process/test/approveProducerDelegation.test.ts b/packages/delegation-process/test/approveProducerDelegation.test.ts index c88b48a689..dc1841a5ca 100644 --- a/packages/delegation-process/test/approveProducerDelegation.test.ts +++ b/packages/delegation-process/test/approveProducerDelegation.test.ts @@ -4,6 +4,7 @@ import { getMockDelegationProducer, getMockTenant, getMockEService, + getMockAuthData, } from "pagopa-interop-commons-test/index.js"; import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { @@ -73,12 +74,12 @@ describe("approve delegation", () => { const { version } = await readLastDelegationEvent(delegation.id); expect(version).toBe("0"); - await delegationProducerService.approveProducerDelegation( - delegate.id, - delegation.id, - generateId(), - genericLogger - ); + await delegationProducerService.approveProducerDelegation(delegation.id, { + authData: getMockAuthData(delegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }); const event = await readLastDelegationEvent(delegation.id); expect(event.version).toBe("1"); @@ -158,10 +159,13 @@ describe("approve delegation", () => { await expect( delegationProducerService.approveProducerDelegation( - delegateId, nonExistentDelegationId, - generateId(), - genericLogger + { + authData: getMockAuthData(delegateId), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + } ) ).rejects.toThrow(delegationNotFound(nonExistentDelegationId)); }); @@ -178,12 +182,12 @@ describe("approve delegation", () => { await addOneDelegation(delegation); await expect( - delegationProducerService.approveProducerDelegation( - wrongDelegate.id, - delegation.id, - generateId(), - genericLogger - ) + delegationProducerService.approveProducerDelegation(delegation.id, { + authData: getMockAuthData(wrongDelegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }) ).rejects.toThrow( operationRestrictedToDelegate(wrongDelegate.id, delegation.id) ); @@ -199,12 +203,12 @@ describe("approve delegation", () => { await addOneDelegation(delegation); await expect( - delegationProducerService.approveProducerDelegation( - delegate.id, - delegation.id, - generateId(), - genericLogger - ) + delegationProducerService.approveProducerDelegation(delegation.id, { + authData: getMockAuthData(delegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }) ).rejects.toThrow( incorrectState( delegation.id, @@ -225,12 +229,12 @@ describe("approve delegation", () => { const { version } = await readLastDelegationEvent(delegation.id); expect(version).toBe("0"); - await delegationProducerService.approveProducerDelegation( - delegate.id, - delegation.id, - unsafeBrandId("9999"), - genericLogger - ); + await delegationProducerService.approveProducerDelegation(delegation.id, { + authData: getMockAuthData(delegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }); const contracts = await fileManager.listFiles( config.s3Bucket, diff --git a/packages/delegation-process/test/getDelegationById.test.ts b/packages/delegation-process/test/getDelegationById.test.ts index 8cd65334d5..ddaf026c79 100644 --- a/packages/delegation-process/test/getDelegationById.test.ts +++ b/packages/delegation-process/test/getDelegationById.test.ts @@ -2,6 +2,7 @@ import { getMockDelegationProducer } from "pagopa-interop-commons-test/index.js"; import { DelegationId, generateId } from "pagopa-interop-models"; import { describe, expect, it } from "vitest"; +import { genericLogger } from "pagopa-interop-commons"; import { delegationNotFound } from "../src/model/domain/errors.js"; import { addOneDelegation, delegationService } from "./utils.js"; @@ -12,7 +13,8 @@ describe("get delegation by id", () => { await addOneDelegation(delegation); const expectedDelegation = await delegationService.getDelegationById( - delegation.id + delegation.id, + genericLogger ); expect(delegation).toEqual(expectedDelegation); @@ -24,7 +26,10 @@ describe("get delegation by id", () => { await addOneDelegation(delegation); const notFoundId = generateId(); - const expectedDelegation = delegationService.getDelegationById(notFoundId); + const expectedDelegation = delegationService.getDelegationById( + notFoundId, + genericLogger + ); await expect(expectedDelegation).rejects.toThrow( delegationNotFound(notFoundId) diff --git a/packages/delegation-process/test/getDelegations.test.ts b/packages/delegation-process/test/getDelegations.test.ts index 37a9b7a836..e7ba0c8381 100644 --- a/packages/delegation-process/test/getDelegations.test.ts +++ b/packages/delegation-process/test/getDelegations.test.ts @@ -1,6 +1,7 @@ /* eslint-disable functional/no-let */ import { getMockDelegationProducer } from "pagopa-interop-commons-test/index.js"; import { describe, expect, it } from "vitest"; +import { genericLogger } from "pagopa-interop-commons"; import { addOneDelegation, delegationService } from "./utils.js"; describe("get delegations", () => { @@ -10,59 +11,74 @@ describe("get delegations", () => { await addOneDelegation(delegation1); await addOneDelegation(delegation2); - const res1 = await delegationService.getDelegations({ - delegateIds: [], - delegatorIds: [], - delegationStates: ["Active"], - eserviceIds: [], - kind: "DelegatedProducer", - offset: 0, - limit: 50, - }); + const res1 = await delegationService.getDelegations( + { + delegateIds: [], + delegatorIds: [], + delegationStates: ["Active"], + eserviceIds: [], + kind: "DelegatedProducer", + offset: 0, + limit: 50, + }, + genericLogger + ); expect(res1).toEqual([delegation1]); - const res2 = await delegationService.getDelegations({ - delegateIds: [delegation2.delegateId], - delegatorIds: [], - delegationStates: [], - eserviceIds: [], - kind: "DelegatedProducer", - offset: 0, - limit: 50, - }); + const res2 = await delegationService.getDelegations( + { + delegateIds: [delegation2.delegateId], + delegatorIds: [], + delegationStates: [], + eserviceIds: [], + kind: "DelegatedProducer", + offset: 0, + limit: 50, + }, + genericLogger + ); expect(res2).toEqual([delegation2]); - const res3 = await delegationService.getDelegations({ - delegateIds: [], - delegatorIds: [], - delegationStates: ["Revoked"], - eserviceIds: [], - kind: "DelegatedProducer", - offset: 0, - limit: 50, - }); + const res3 = await delegationService.getDelegations( + { + delegateIds: [], + delegatorIds: [], + delegationStates: ["Revoked"], + eserviceIds: [], + kind: "DelegatedProducer", + offset: 0, + limit: 50, + }, + genericLogger + ); expect(res3).toEqual([]); - const res4 = await delegationService.getDelegations({ - delegateIds: [], - delegatorIds: [], - delegationStates: ["Active"], - eserviceIds: [], - kind: undefined, - offset: 0, - limit: 50, - }); + const res4 = await delegationService.getDelegations( + { + delegateIds: [], + delegatorIds: [], + delegationStates: ["Active"], + eserviceIds: [], + kind: undefined, + offset: 0, + limit: 50, + }, + genericLogger + ); expect(res4).toEqual([delegation1]); - const res5 = await delegationService.getDelegations({ - delegateIds: [], - delegatorIds: [], - delegationStates: ["Active"], - eserviceIds: [delegation1.eserviceId], - kind: "DelegatedProducer", - offset: 0, - limit: 50, - }); + const res5 = await delegationService.getDelegations( + { + delegateIds: [], + delegatorIds: [], + delegationStates: ["Active"], + eserviceIds: [delegation1.eserviceId], + kind: "DelegatedProducer", + offset: 0, + limit: 50, + }, + genericLogger + ); expect(res5).toEqual([delegation1]); }); }); diff --git a/packages/delegation-process/test/rejectProducerDelegation.test.ts b/packages/delegation-process/test/rejectProducerDelegation.test.ts index bcc1bbe7ea..f24401386d 100644 --- a/packages/delegation-process/test/rejectProducerDelegation.test.ts +++ b/packages/delegation-process/test/rejectProducerDelegation.test.ts @@ -1,6 +1,7 @@ /* eslint-disable functional/no-let */ import { decodeProtobufPayload, + getMockAuthData, getMockDelegationProducer, getMockTenant, } from "pagopa-interop-commons-test/index.js"; @@ -13,6 +14,7 @@ import { unsafeBrandId, } from "pagopa-interop-models"; import { delegationState } from "pagopa-interop-models"; +import { genericLogger } from "pagopa-interop-commons"; import { delegationNotFound, operationRestrictedToDelegate, @@ -40,10 +42,14 @@ describe("reject delegation", () => { const rejectionReason = "I don't like computers, please send me a pigeon"; await delegationProducerService.rejectProducerDelegation( - delegate.id, delegation.id, - generateId(), - rejectionReason + rejectionReason, + { + authData: getMockAuthData(delegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + } ); const event = await readLastDelegationEvent(delegation.id); @@ -72,10 +78,14 @@ describe("reject delegation", () => { await expect( delegationProducerService.rejectProducerDelegation( - delegateId, nonExistentDelegationId, - generateId(), - "" + "", + { + authData: getMockAuthData(delegateId), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + } ) ).rejects.toThrow(delegationNotFound(nonExistentDelegationId)); }); @@ -90,12 +100,12 @@ describe("reject delegation", () => { await addOneDelegation(delegation); await expect( - delegationProducerService.rejectProducerDelegation( - wrongDelegate.id, - delegation.id, - generateId(), - "" - ) + delegationProducerService.rejectProducerDelegation(delegation.id, "", { + authData: getMockAuthData(wrongDelegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }) ).rejects.toThrow( operationRestrictedToDelegate(wrongDelegate.id, delegation.id) ); @@ -110,12 +120,12 @@ describe("reject delegation", () => { await addOneDelegation(delegation); await expect( - delegationProducerService.rejectProducerDelegation( - delegate.id, - delegation.id, - generateId(), - "" - ) + delegationProducerService.rejectProducerDelegation(delegation.id, "", { + authData: getMockAuthData(delegate.id), + serviceName: "", + correlationId: generateId(), + logger: genericLogger, + }) ).rejects.toThrow( incorrectState( delegation.id,