Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIN-5889 activatePurposeVersion and updatePurpose delegation test #1344

Merged
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c9a39a8
feat: create purpose by delegate, add check on delegate
AsterITA Dec 19, 2024
2e7859c
fix getDelegation using correct params
AsterITA Dec 20, 2024
d27dff3
added check for delegate on activate and suspend, various fixes
AsterITA Dec 20, 2024
1b7a682
readded eslint on arrow function
AsterITA Dec 20, 2024
9ab6c3c
removed delegationId from input in createPurpose
AsterITA Dec 20, 2024
a5842a1
Merge branch 'feature/incaricato' into PIN-5816_createPurposeDelegation
AsterITA Jan 7, 2025
0ad08ef
applied suggestions from review
AsterITA Jan 7, 2025
3befcdc
fix tests
AsterITA Jan 7, 2025
e18bfd6
added missing tests
rGregnanin Jan 7, 2025
5832ff2
Merge branch 'PIN-5816_createPurposeDelegation' into PIN-5881-UpdateP…
rGregnanin Jan 7, 2025
e241b48
minor refactor on getOrganizationRole
AsterITA Jan 7, 2025
0716349
fix tests
rGregnanin Jan 7, 2025
a76e5d4
Merge branch 'PIN-5816_createPurposeDelegation' into PIN-5881-UpdateP…
rGregnanin Jan 7, 2025
dac1f7a
bump outbound, added delegationId in Purpose where missing
AsterITA Jan 8, 2025
33a06e2
Merge branch 'PIN-5816_createPurposeDelegation' into PIN-5881-UpdateP…
rGregnanin Jan 8, 2025
c6ebb08
added delegation test for activatePurposeVersion
rGregnanin Jan 8, 2025
b639a79
added test
rGregnanin Jan 9, 2025
340ecfa
added missing delegationIds
AsterITA Jan 9, 2025
7612687
added test
rGregnanin Jan 9, 2025
968e848
Merge branch 'PIN-5881-UpdatePurposeDelegtionTest' into PIN-5889-Acti…
rGregnanin Jan 10, 2025
9ab3407
added tests
rGregnanin Jan 10, 2025
21372de
fix name
rGregnanin Jan 10, 2025
19708d2
fix name
rGregnanin Jan 10, 2025
1d8c744
Merge branch 'PIN-5881-UpdatePurposeDelegtionTest' into PIN-5889-Acti…
rGregnanin Jan 10, 2025
93e0d58
added missing checks for delegate
AsterITA Jan 13, 2025
9c2e428
fix tests
AsterITA Jan 13, 2025
8a46dd7
Merge branch 'PIN-5816_createPurposeDelegation' into PIN-5881-UpdateP…
rGregnanin Jan 13, 2025
d86fb40
Merge branch 'feature/incaricato' into PIN-5881-UpdatePurposeDelegtio…
rGregnanin Jan 15, 2025
85a2205
WIP
rGregnanin Jan 15, 2025
1370f3d
fix
rGregnanin Jan 16, 2025
ad15dfa
fixed as suggested
rGregnanin Jan 16, 2025
25ea4d8
Merge branch 'PIN-5881-UpdatePurposeDelegtionTest' into PIN-5889-Acti…
rGregnanin Jan 16, 2025
89eacaa
fix
rGregnanin Jan 16, 2025
3981b46
fix state
rGregnanin Jan 16, 2025
6e9cb9e
Merge branch 'feature/incaricato' into PIN-5881-UpdatePurposeDelegtio…
rGregnanin Jan 17, 2025
ae440cb
Merge branch 'PIN-5881-UpdatePurposeDelegtionTest' into PIN-5889-Acti…
rGregnanin Jan 17, 2025
2c01183
Merge branch 'feature/incaricato' into PIN-5889-ActivatePurposeVersio…
rGregnanin Jan 17, 2025
43fea86
added tests
rGregnanin Jan 17, 2025
017a97b
fix
rGregnanin Jan 17, 2025
0f6a317
Merge branch 'feature/incaricato' into PIN-5889-ActivatePurposeVersio…
rGregnanin Jan 17, 2025
1c5f059
WIP
rGregnanin Jan 17, 2025
56401c1
fix
rGregnanin Jan 20, 2025
40f9698
refactor
rGregnanin Jan 20, 2025
18e0127
Merge branch 'feature/incaricato' into PIN-5889-ActivatePurposeVersio…
rGregnanin Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix state
rGregnanin committed Jan 16, 2025
commit 3981b469bcae33361abfb9881b10f2657ab2b82f
85 changes: 39 additions & 46 deletions packages/purpose-process/test/activatePurposeVersion.test.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after you update this with the latest changes you should also add the test with the vi.spyOn(pdfGenerator, "generate") to these new tests

Original file line number Diff line number Diff line change
@@ -1310,53 +1310,46 @@ describe("activatePurposeVersion", () => {
}
);

it.each([
purposeVersionState.active,
purposeVersionState.archived,
purposeVersionState.rejected,
])(
`should throw organizationNotAllowed when the requester is the Consumer but there is a Consumer Delegation`,
async (state) => {
const purposeVersion: PurposeVersion = {
...mockPurposeVersion,
state,
};
const purpose: Purpose = {
...mockPurpose,
versions: [purposeVersion],
delegationId: generateId<DelegationId>(),
};
it(`should throw organizationNotAllowed when the requester is the Consumer but there is a Consumer Delegation`, async () => {
const purposeVersion: PurposeVersion = {
...mockPurposeVersion,
state: purposeVersionState.draft,
};
const purpose: Purpose = {
...mockPurpose,
versions: [purposeVersion],
delegationId: generateId<DelegationId>(),
ecamellini marked this conversation as resolved.
Show resolved Hide resolved
};

const delegation = getMockDelegation({
id: purpose.delegationId,
kind: delegationKind.delegatedConsumer,
eserviceId: purpose.eserviceId,
delegatorId: purpose.consumerId,
delegateId: generateId<TenantId>(),
state: delegationState.active,
});
const delegation = getMockDelegation({
id: purpose.delegationId,
kind: delegationKind.delegatedConsumer,
eserviceId: purpose.eserviceId,
delegatorId: purpose.consumerId,
delegateId: generateId<TenantId>(),
state: delegationState.active,
});

await addOnePurpose(purpose);
await addOneEService(mockEService);
await addOneAgreement(mockAgreement);
await addOneTenant(mockConsumer);
await addOneTenant(mockProducer);
await addOneDelegation(delegation);
await addOnePurpose(purpose);
await addOneEService(mockEService);
await addOneAgreement(mockAgreement);
await addOneTenant(mockConsumer);
await addOneTenant(mockProducer);
await addOneDelegation(delegation);

expect(async () => {
await purposeService.activatePurposeVersion(
{
purposeId: mockPurpose.id,
versionId: mockPurposeVersion.id,
},
{
authData: getRandomAuthData(mockConsumer.id),
correlationId: generateId(),
logger: genericLogger,
serviceName: "",
}
);
}).rejects.toThrowError(organizationNotAllowed(mockConsumer.id));
}
);
expect(async () => {
await purposeService.activatePurposeVersion(
{
purposeId: mockPurpose.id,
versionId: mockPurposeVersion.id,
},
{
authData: getRandomAuthData(mockConsumer.id),
correlationId: generateId(),
logger: genericLogger,
serviceName: "",
}
);
}).rejects.toThrowError(organizationNotAllowed(mockConsumer.id));
});
});