Skip to content

Commit

Permalink
Merge pull request #155 from TimoGlastra/cost-value-tests
Browse files Browse the repository at this point in the history
test: const value tests
  • Loading branch information
nklomp authored Apr 25, 2024
2 parents 5347e30 + 0fcfe01 commit c15fe2a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/PEX.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
WrappedW3CVerifiableCredential,
} from '@sphereon/ssi-types';

import { EvaluationResults, PEX, Validated } from '../lib';
import { EvaluationResults, PEX, PEXv2, Validated } from '../lib';
import { VerifiablePresentationResult } from '../lib/signing/types';
import { SSITypesBuilder } from '../lib/types';

Expand Down Expand Up @@ -198,6 +198,19 @@ describe('evaluate', () => {
expect(result).toEqual([{ message: 'ok', status: 'info', tag: 'root' }]);
});

it('correct handles presentation definition with const values in filter', () => {
const pdSchema: PresentationDefinitionV2 = getFileAsJson('./test/resources/pd_const_values.json').presentation_definition;
const result = PEXv2.validateDefinition(pdSchema);

expect(result).toEqual([
{
tag: 'root',
status: 'info',
message: 'ok',
},
]);
});

it('Evaluate presentationDefinition v2', () => {
const pd: PresentationDefinitionV2 = getPresentationDefinitionV2();
const result: Validated = PEX.validateDefinition(pd);
Expand Down
46 changes: 46 additions & 0 deletions test/resources/pd_const_values.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"presentation_definition": {
"id": "56e001a9-c41f-49c5-9b12-440ad4861f58",
"name": "DIIP v3 compliance",
"purpose": "Prove you're compliant with DIIP v3",
"input_descriptors": [
{
"id": "b2a1f1d3-37ee-4494-98e2-ef9853b28197",
"name": "DIIP v3 compliance",
"purpose": "Prove you're compliant with DIIP v3",
"format": {
"vc+sd-jwt": {}
},
"constraints": {
"limit_disclosure": "preferred",
"fields": [
{
"path": ["$.compliant"],
"name": "compliant",
"filter": {
"type": "boolean",
"const": true
}
},
{
"path": ["$.name"],
"name": "name",
"filter": {
"type": "string",
"const": "name"
}
},
{
"path": ["$.age"],
"name": "age",
"filter": {
"type": "number",
"const": 12
}
}
]
}
}
]
}
}

0 comments on commit c15fe2a

Please sign in to comment.