diff --git a/packages/delegation-process/test/.eslintrc.json b/packages/delegation-process/test/.eslintrc.json index 6135a5ce08..9346af31d5 100644 --- a/packages/delegation-process/test/.eslintrc.json +++ b/packages/delegation-process/test/.eslintrc.json @@ -2,6 +2,7 @@ "extends": ["../../../.eslintrc.cjs"], "rules": { "functional/immutable-data": "off", - "sonarjs/no-identical-functions": "off" + "sonarjs/no-identical-functions": "off", + "@typescript-eslint/no-non-null-assertion": "off" } } diff --git a/packages/delegation-process/test/approveProducerDelegation.test.ts b/packages/delegation-process/test/approveProducerDelegation.test.ts index 69199af69a..1605edf592 100644 --- a/packages/delegation-process/test/approveProducerDelegation.test.ts +++ b/packages/delegation-process/test/approveProducerDelegation.test.ts @@ -4,7 +4,7 @@ import { getMockDelegation, getMockTenant, getMockEService, - getMockAuthData, + getRandomAuthData, } from "pagopa-interop-commons-test/index.js"; import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { @@ -63,6 +63,7 @@ describe("approve producer delegation", () => { it("should approve delegation if validations succeed", async () => { const delegationId = generateId(); + const authData = getRandomAuthData(delegate.id); const delegation = getMockDelegation({ kind: delegationKind.delegatedProducer, @@ -77,7 +78,7 @@ describe("approve producer delegation", () => { expect(version).toBe("0"); await delegationProducerService.approveProducerDelegation(delegation.id, { - authData: getMockAuthData(delegate.id), + authData, serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -107,7 +108,7 @@ describe("approve producer delegation", () => { stamps: { ...delegation.stamps, activation: { - who: delegate.id, + who: authData.userId, when: currentExecutionTime, }, }, @@ -163,7 +164,7 @@ describe("approve producer delegation", () => { delegationProducerService.approveProducerDelegation( nonExistentDelegationId, { - authData: getMockAuthData(delegateId), + authData: getRandomAuthData(delegateId), serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -186,7 +187,7 @@ describe("approve producer delegation", () => { await expect( delegationProducerService.approveProducerDelegation(delegation.id, { - authData: getMockAuthData(wrongDelegate.id), + authData: getRandomAuthData(wrongDelegate.id), serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -208,7 +209,7 @@ describe("approve producer delegation", () => { await expect( delegationProducerService.approveProducerDelegation(delegation.id, { - authData: getMockAuthData(delegate.id), + authData: getRandomAuthData(delegate.id), serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -235,7 +236,7 @@ describe("approve producer delegation", () => { expect(version).toBe("0"); await delegationProducerService.approveProducerDelegation(delegation.id, { - authData: getMockAuthData(delegate.id), + authData: getRandomAuthData(delegate.id), serviceName: "", correlationId: generateId(), logger: genericLogger, diff --git a/packages/delegation-process/test/createProducerDelegation.test.ts b/packages/delegation-process/test/createProducerDelegation.test.ts index 1463fba985..f3e42b73c5 100644 --- a/packages/delegation-process/test/createProducerDelegation.test.ts +++ b/packages/delegation-process/test/createProducerDelegation.test.ts @@ -137,7 +137,7 @@ describe("create producer delegation", () => { submittedAt: currentExecutionTime, stamps: { submission: { - who: delegatorId, + who: authData.userId, when: currentExecutionTime, }, }, @@ -216,7 +216,7 @@ describe("create producer delegation", () => { submittedAt: currentExecutionTime, stamps: { submission: { - who: delegatorId, + who: authData.userId, when: currentExecutionTime, }, }, diff --git a/packages/delegation-process/test/rejectProducerDelegation.test.ts b/packages/delegation-process/test/rejectProducerDelegation.test.ts index cf5afe2063..9fd50cbd59 100644 --- a/packages/delegation-process/test/rejectProducerDelegation.test.ts +++ b/packages/delegation-process/test/rejectProducerDelegation.test.ts @@ -1,9 +1,9 @@ /* eslint-disable functional/no-let */ import { decodeProtobufPayload, - getMockAuthData, getMockDelegation, getMockTenant, + getRandomAuthData, } from "pagopa-interop-commons-test/index.js"; import { describe, expect, it, vi } from "vitest"; import { @@ -34,6 +34,7 @@ describe("reject producer delegation", () => { vi.setSystemTime(currentExecutionTime); const delegate = getMockTenant(); + const authData = getRandomAuthData(delegate.id); const delegation = getMockDelegation({ kind: delegationKind.delegatedProducer, state: "WaitingForApproval", @@ -47,7 +48,7 @@ describe("reject producer delegation", () => { delegation.id, rejectionReason, { - authData: getMockAuthData(delegate.id), + authData, serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -67,7 +68,7 @@ describe("reject producer delegation", () => { rejectionReason, stamps: { ...delegation.stamps, - rejection: { who: delegate.id, when: currentExecutionTime }, + rejection: { who: authData.userId, when: currentExecutionTime }, }, }); expect(actualDelegation).toEqual(expectedDelegation); @@ -83,7 +84,7 @@ describe("reject producer delegation", () => { nonExistentDelegationId, "", { - authData: getMockAuthData(delegateId), + authData: getRandomAuthData(delegateId), serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -104,7 +105,7 @@ describe("reject producer delegation", () => { await expect( delegationProducerService.rejectProducerDelegation(delegation.id, "", { - authData: getMockAuthData(wrongDelegate.id), + authData: getRandomAuthData(wrongDelegate.id), serviceName: "", correlationId: generateId(), logger: genericLogger, @@ -125,7 +126,7 @@ describe("reject producer delegation", () => { await expect( delegationProducerService.rejectProducerDelegation(delegation.id, "", { - authData: getMockAuthData(delegate.id), + authData: getRandomAuthData(delegate.id), serviceName: "", correlationId: generateId(), logger: genericLogger, diff --git a/packages/delegation-process/test/revokeProducerDelegation.test.ts b/packages/delegation-process/test/revokeProducerDelegation.test.ts index ffc5c3c287..1130cc07c3 100644 --- a/packages/delegation-process/test/revokeProducerDelegation.test.ts +++ b/packages/delegation-process/test/revokeProducerDelegation.test.ts @@ -18,6 +18,7 @@ import { unsafeBrandId, DelegationContractId, delegationKind, + UserId, } from "pagopa-interop-models"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import { @@ -51,7 +52,7 @@ type DelegationStateSeed = }; stamps: { rejection: { - who: TenantId; + who: UserId; when: Date; }; }; @@ -63,7 +64,7 @@ type DelegationStateSeed = }; stamps: { revocation: { - who: TenantId; + who: UserId; when: Date; }; }; @@ -83,7 +84,7 @@ const getNotRevocableStateSeeds = (): DelegationStateSeed[] => { }, stamps: { rejection: { - who: generateId(), + who: generateId(), when: rejectionOrRevokeDate, }, }, @@ -95,7 +96,7 @@ const getNotRevocableStateSeeds = (): DelegationStateSeed[] => { }, stamps: { revocation: { - who: generateId(), + who: generateId(), when: rejectionOrRevokeDate, }, }, @@ -149,11 +150,11 @@ describe("revoke producer delegation", () => { submittedAt: delegationCreationDate, stamps: { submission: { - who: delegatorId, + who: generateId(), when: delegationCreationDate, }, activation: { - who: delegateId, + who: generateId(), when: delegationActivationDate, }, }, @@ -186,15 +187,15 @@ describe("revoke producer delegation", () => { revokedAt: currentExecutionTime, stamps: { submission: { - who: delegatorId, + who: existentDelegation.stamps.submission.who, when: delegationCreationDate, }, activation: { - who: delegateId, + who: existentDelegation.stamps.activation!.who, when: delegationActivationDate, }, revocation: { - who: delegatorId, + who: authData.userId, when: currentExecutionTime, }, }, @@ -297,11 +298,11 @@ describe("revoke producer delegation", () => { submittedAt: delegationCreationDate, stamps: { submission: { - who: delegatorId, + who: generateId(), when: delegationCreationDate, }, approval: { - who: delegateId, + who: generateId(), when: delegationApprovalDate, }, }, @@ -345,11 +346,11 @@ describe("revoke producer delegation", () => { submittedAt: delegationCreationDate, stamps: { submission: { - who: delegatorId, + who: generateId(), when: delegationCreationDate, }, activation: { - who: delegateId, + who: generateId(), when: delegationActivationDate, }, ...notRevocableDelegationState.stamps,