Skip to content

Commit

Permalink
Merge pull request #122 from Sphereon-Opensource/fix/ESSIFI-189
Browse files Browse the repository at this point in the history
fix: fixed putting the wrong name values in SubmissionRequirementsMatch
  • Loading branch information
sksadjad authored Jul 4, 2023
2 parents 618e1bf + 5001358 commit 32e30c9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/evaluation/evaluationClientWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,12 @@ export class EvaluationClientWrapper {
const srm: Partial<SubmissionRequirementMatch> = { rule: sr.rule, from: [], vc_path: [] };
if (sr?.from) {
srm.from?.push(sr.from);
// updating the srm.name everytime and since we have only one, we're sending the last one
for (const m of marked) {
const inDesc = jp.query(pd, m.input_descriptor_path)[0];
const inDesc: InputDescriptorV2 = jp.query(pd, m.input_descriptor_path)[0];
if (inDesc.group && inDesc.group.indexOf(sr.from) === -1) {
continue;
}
srm.name = inDesc.name || inDesc.id;
if (m.payload.group.includes(sr.from)) {
if (srm.vc_path?.indexOf(m.verifiable_credential_path) === -1) {
Expand Down
67 changes: 67 additions & 0 deletions test/thirdParty/Animo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,73 @@ describe('evaluate animo tests', () => {
const result = pex.evaluateCredentials(pdModified, vcs);
expect(result.areRequiredCredentialsPresent).toEqual(Status.ERROR);
});

it('should have valid name in matches from SelectResults', function () {
const pd: IPresentationDefinition = {
id: '022c2664-68cc-45cc-b291-789ce8b599eb',
name: 'Presentation Definition',
purpose: 'We want to know your name and e-mail address (will not be stored)',
input_descriptors: [
{
id: 'c2834d0e-3c95-4721-b21a-40e3d7ea2549',
purpose: 'To access this portal your DBC Conference 2023 attendance proof is required.',
group: ['A'],
schema: [
{
uri: 'DBCConferenceAttendee',
required: true,
},
],
constraints: {
fields: [
{
path: ['$.credentialSubject.event.name', '$.vc.credentialSubject.event.name'],
filter: {
type: 'string',
pattern: 'DBC Conference 2023',
},
},
],
},
},
{
id: 'c2834d0e-3c95-4721-b21a-40e3d7ea25434',
purpose: 'To access this portal you need to show your JFF Plugfest OpenBadge credential.',
group: ['B'],
schema: [
{
uri: 'OpenBadgeCredential',
required: true,
},
],
},
],
submission_requirements: [
{
rule: 'pick',
count: 1,
from: 'A',
},
{
rule: 'pick',
count: 1,
from: 'B',
},
],
};
const vcs = [
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDprZXk6ekRuYWVlY3Vacjg2OXZTNTl4R1BSTmRTTnFEVHBvc2pTWlVqQ1E3c1RoUkExeDRDNyN6RG5hZWVjdVpyODY5dlM1OXhHUFJOZFNOcURUcG9zalNaVWpDUTdzVGhSQTF4NEM3In0.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiREJDQ29uZmVyZW5jZUF0dGVuZGVlIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImZpcnN0TmFtZSI6IkphbiIsImxhc3ROYW1lIjoiUmlldHZlbGQiLCJlbWFpbCI6ImphbkBhbmltby5pZCIsImV2ZW50Ijp7Im5hbWUiOiJEQkMgQ29uZmVyZW5jZSAyMDIzIiwiZGF0ZSI6IjIwMjMtMDYtMjYifX19LCJpc3MiOiJkaWQ6a2V5OnpEbmFlZWN1WnI4Njl2UzU5eEdQUk5kU05xRFRwb3NqU1pVakNRN3NUaFJBMXg0QzciLCJzdWIiOiJkaWQ6andrOmV5SmpjbllpT2lKUUxUSTFOaUlzSW10MGVTSTZJa1ZESWl3aWVDSTZJbUZqWWtsUmFYVk5jek5wT0Y5MWMzcEZha295ZEhCVWRGSk5ORVZWTTNsNk9URlFTRFpEWkVneVZqQWlMQ0o1SWpvaVgwdGplVXhxT1haWFRYQjBibTFMZEcwME5rZHhSSG80ZDJZM05FazFURXRuY213eVIzcElNMjVUUlNKOSIsI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JbHBoYVRoNlNHWXdUVU5MY0dkTE9IbHhkMVZoTjA5ak5XSlBhV3h0UWpRMGRFUnlZamRPVVRCMlowa2lmUSIsImFjaGlldmVtZW50Ijp7ImNyaXRlcmlhIjp7Im5hcnJhdGl2ZSI6IlRoZSBjb2hvcnQgb2YgdGhlIEpGRiBQbHVnZmVzdCAyIGluIEF1Z3VzdC1Ob3ZlbWJlciBvZiAyMDIyIGNvbGxhYm9yYXRlZCB0byBwdXNoIGludGVyb3BlcmFiaWxpdHkgb2YgVkNzIGluIGVkdWNhdGlvbiBmb3J3YXJkLiIsInR5cGUiOiJDcml0ZXJpYSJ9LCJkZXNjcmlwdGlvbiI6IlRoaXMgd2FsbGV0IGNhbiBkaXNwbGF5IHRoaXMgT3BlbiBCYWRnZSAzLjAiLCJpZCI6IjAiLCJpbWFnZSI6eyJpZCI6Imh0dHBzOi8vdzNjLWNjZy5naXRodWIuaW8vdmMtZWQvcGx1Z2Zlc3QtMi0yMDIyL2ltYWdlcy9KRkYtVkMtRURVLVBMVUdGRVNUMi1iYWRnZS1pbWFnZS5wbmciLCJ0eXBlIjoiSW1hZ2UifSwibmFtZSI6Ik91ciBXYWxsZXQgUGFzc2VkIEpGRiBQbHVnZmVzdCAjMiAyMDIyIiwidHlwZSI6IkFjaGlldmVtZW50In0sInR5cGUiOiJBY2hpZXZlbWVudFN1YmplY3QifSwibmFtZSI6IkFjaGlldmVtZW50IENyZWRlbnRpYWwifSwianRpIjoidXJuOnV1aWQ6YjA3MzZhMDMtMGJlYy00NmE2LTkxZGEtMzJhZTVkZmJmMTU2In0.M7m5_E1hcCp13x4zWqZA6dASMh9sfNB9sr8Dwtm40vdQtPFyJ5PFESzPLhfv0kzyFAe3f_KMqZIbU7VKpsKACw',
];
const pex: PEX = new PEX();
const result = pex.selectFrom(pd, vcs);
expect(result.areRequiredCredentialsPresent).toEqual(Status.INFO);
expect(result.matches?.length).toEqual(2);
expect(new Set(result.matches?.map((value) => value.name)).size).toEqual(2);
expect(result.matches?.map((value) => value.name).indexOf('c2834d0e-3c95-4721-b21a-40e3d7ea2549')).toBeGreaterThanOrEqual(0);
expect(result.matches?.map((value) => value.name).indexOf('c2834d0e-3c95-4721-b21a-40e3d7ea25434')).toBeGreaterThanOrEqual(0);
});

const vcs: W3CVerifiableCredential[] = [
{
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
Expand Down
4 changes: 2 additions & 2 deletions test/thirdParty/Gataca.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('evaluate gataca tests', () => {
rule: 'all',
from: ['mandatory'],
vc_path: ['$.verifiableCredential[0]'],
name: 'transcriptOfRecordsCredential',
name: 'emailCredential',
},
{
rule: 'pick',
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('evaluate gataca tests', () => {
rule: 'all',
from: ['mandatory'],
vc_path: ['$.verifiableCredential[0]'],
name: 'transcriptOfRecordsCredential',
name: 'emailCredential',
},
{
rule: 'pick',
Expand Down

0 comments on commit 32e30c9

Please sign in to comment.