Skip to content

Commit 9bab72a

Browse files
PatStLouisBigBlueHat
authored andcommitted
Add presentation holder tests, update test file numeration, fix related resources tests
Signed-off-by: PatStLouis <[email protected]>
1 parent 3a50329 commit 9bab72a

25 files changed

+376
-32
lines changed
File renamed without changes.

tests/410-status.js renamed to tests/4.10-status.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ describe('Status', function() {
2828
describe(name, function() {
2929
beforeEach(addPerTestMetadata);
3030

31+
it('The type property is REQUIRED.', async function() {
32+
this.test.link = `https://w3c.github.io/vc-data-model/#status:~:text=credential%20status%20object.-,If%20present%2C%20the%20normative%20guidance%20in%20Section%204.4%20Identifiers%20MUST%20be%20followed.,-type`;
33+
await assert.rejects(endpoints.issue(require(
34+
'./input/credential-status-missing-type-fail.json')),
35+
'Failed to reject a VC with `credentialStatus` without a `type`.');
36+
});
37+
38+
it('The related normative guidance in Section 4.5 ' +
39+
'Types MUST be followed.',
40+
async function() {
41+
this.test.link = `https://w3c.github.io/vc-data-model/#status:~:text=credential%20status%20object.-,If%20present%2C%20the%20normative%20guidance%20in%20Section%204.4%20Identifiers%20MUST%20be%20followed.,-type`;
42+
await assert.doesNotReject(endpoints.issue(require(
43+
'./input/credential-status-ok.json')),
44+
'Failed to accept a VC with `credentialStatus` with a `type`.');
45+
await assert.rejects(endpoints.issue(require(
46+
'./input/credential-status-missing-type-fail.json')),
47+
'Failed to reject a VC with `credentialStatus` without a `type`.');
48+
});
49+
3150
it('If present (credentialStatus.id), the normative guidance ' +
3251
'in Section 4.4 Identifiers MUST be followed.', async function() {
3352
this.test.link = `https://w3c.github.io/vc-data-model/#status:~:text=credential%20status%20object.-,If%20present%2C%20the%20normative%20guidance%20in%20Section%204.4%20Identifiers%20MUST%20be%20followed.,-type`;
File renamed without changes.

tests/413-verifiable-presentations.js renamed to tests/4.13-verifiable-presentations.js

Lines changed: 89 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import {addPerTestMetadata, setupMatrix}
88
from './helpers.js';
9+
import {createLocalVp, localIssuer} from './data-generator.js';
910
import assert from 'node:assert/strict';
1011
import chai from 'chai';
11-
import {createLocalVp} from './data-generator.js';
1212
import {createRequire} from 'module';
1313
import {filterByTag} from 'vc-test-suite-implementations';
1414
import {TestEndpoints} from './TestEndpoints.js';
@@ -33,7 +33,6 @@ describe('Verifiable Presentations', function() {
3333
it('If [the `id` field is] present, the normative guidance in Section ' +
3434
'4.4 Identifiers MUST be followed.', async function() {
3535
this.test.link = `https://w3c.github.io/vc-data-model/#verifiable-presentations:~:text=verifiable%20presentation.-,If%20present%2C%20the%20normative%20guidance%20in%20Section%204.4%20Identifiers%20MUST%20be%20followed.,-type`;
36-
// a presentation with a valid id should verify
3736
const presentationValidId = await createLocalVp({
3837
presentation: require('./input/presentation-id-ok.json')
3938
});
@@ -43,19 +42,33 @@ describe('Verifiable Presentations', function() {
4342
);
4443
});
4544

46-
it('The type property MUST be present. One value of this property MUST ' +
45+
it('The type property MUST be present.',
46+
async function() {
47+
this.test.link = `https://w3c.github.io/vc-data-model/#verifiable-presentations:~:text=The%20type%20property%20MUST%20be%20present.%20It%20is%20used%20to%20express%20the%20type%20of%20verifiable%20presentation.%20One%20value%20of%20this%20property%20MUST%20be%20VerifiablePresentation%2C%20but%20additional%20types%20MAY%20be%20included.%20The%20related%20normative%20guidance%20in%20Section%204.5%20Types%20MUST%20be%20followed.`;
48+
const presentationWithType = await createLocalVp({
49+
presentation: require('./input/presentation-ok.json')
50+
});
51+
await assert.doesNotReject(
52+
endpoints.verifyVp(presentationWithType),
53+
`Expected verifier ${name} to verify a VP with initial ` +
54+
`type VerifiablePresentation.`);
55+
// TODO, how to create negative fixture (missing type)
56+
});
57+
58+
it('One value of this property MUST ' +
4759
'be VerifiablePresentation, but additional types MAY be included.' +
4860
'The related normative guidance in Section 4.5 Types MUST be followed.',
4961
async function() {
5062
this.test.link = `https://w3c.github.io/vc-data-model/#verifiable-presentations:~:text=The%20type%20property%20MUST%20be%20present.%20It%20is%20used%20to%20express%20the%20type%20of%20verifiable%20presentation.%20One%20value%20of%20this%20property%20MUST%20be%20VerifiablePresentation%2C%20but%20additional%20types%20MAY%20be%20included.%20The%20related%20normative%20guidance%20in%20Section%204.5%20Types%20MUST%20be%20followed.`;
5163
const presentationWithType = await createLocalVp({
52-
presentation: require('./input/presentation-vc-ok.json')
64+
presentation: require('./input/presentation-ok.json')
5365
});
5466
await assert.doesNotReject(
5567
endpoints.verifyVp(presentationWithType),
5668
`Expected verifier ${name} to verify a VP with initial ` +
5769
`type VerifiablePresentation.`
5870
);
71+
// TODO, how to create negative fixture (wrong type)
5972
});
6073

6174
it('The verifiableCredential property MAY be present. The value MUST be' +
@@ -71,13 +84,38 @@ describe('Verifiable Presentations', function() {
7184
await assert.doesNotReject(endpoints.verifyVp(
7285
presentationWithCredentials
7386
), 'Failed to verify a valid VP.');
74-
await assert.rejects(endpoints.verifyVp(require(
75-
'./input/presentation-vc-missing-required-type-fail.json')),
87+
// TODO, how to create negative fixture (bad vc values)
88+
});
89+
90+
it('If present (holder), the value MUST be either a URL or ' +
91+
'an object containing an id property.',
92+
async function() {
93+
this.test.link = `https://w3c.github.io/vc-data-model/#verifiable-presentations:~:text=The%20verifiableCredential%20property%20MAY%20be%20present.%20The%20value%20MUST%20be%20one%20or%20more%20verifiable%20credential%20and/or%20enveloped%20verifiable%20credential%20objects%20(the%20values%20MUST%20NOT%20be%20non%2Dobject%20values%20such%20as%20numbers%2C%20strings%2C%20or%20URLs).`;
94+
// TODO: Test with remote presentation creation or querying if/when
95+
// supported by the implementation
96+
const presentationWithHolder = await createLocalVp({
97+
presentation: require('./input/presentation-holder-ok.json')
98+
});
99+
await assert.doesNotReject(endpoints.verifyVp(
100+
presentationWithHolder
101+
), 'Failed to verify a valid VP with holder.');
102+
103+
// presentation.holder = {id: localIssuer};
104+
const presentationWithHolderObject = await createLocalVp({
105+
presentation: require('./input/presentation-holder-object-ok.json')
106+
});
107+
await assert.doesNotReject(endpoints.verifyVp(
108+
presentationWithHolderObject
109+
), 'Failed to verify a valid VP with holder object.');
76110

77-
'Failed to reject a VP containing a VC with no `type` value.');
78-
await assert.rejects(endpoints.verifyVp(require(
79-
'./input/presentation-vc-as-string-fail.json')),
80-
'Failed to reject a VP containing a VC represented as a string.');
111+
const presentationMissingHolderId = await createLocalVp({
112+
presentation: require('./input/presentation-holder-object-fail.json')
113+
});
114+
await assert.rejects(endpoints.verifyVp(
115+
presentationMissingHolderId
116+
), 'Failed to reject a VP with an invalid holder.');
117+
118+
// TODO, how to create negative fixture (bad holder values)
81119
});
82120
});
83121
}
@@ -86,7 +124,8 @@ describe('Verifiable Presentations', function() {
86124
// 4.12.4 Presentations Including Holder Claims https://w3c.github.io/vc-data-model/#presentations-including-holder-claims
87125
describe('VP - Presentations Including Holder Claims', function() {
88126
setupMatrix.call(this, match);
89-
for(const [name] of match) {
127+
for(const [name, implementation] of match) {
128+
const endpoints = new TestEndpoints({implementation, tag});
90129

91130
describe(name, function() {
92131
beforeEach(addPerTestMetadata);
@@ -96,9 +135,15 @@ describe('VP - Presentations Including Holder Claims', function() {
96135
'verifiable presentation MUST include a holder property.',
97136
async function() {
98137
this.test.link = `https://w3c.github.io/vc-data-model/#presentations-including-holder-claims:~:text=A%20verifiable%20presentation%20that%20includes%20a%20self%2Dasserted%20verifiable%20credential%20that%20is%20only%20secured%20using%20the%20same%20mechanism%20as%20the%20verifiable%20presentation%20MUST%20include%20a%20holder%20property.`;
99-
// TODO: implement test
100-
this.test.cell.skipMessage = 'TBD';
101-
this.skip();
138+
const presentation = require('./input/presentation-vc-ok.json');
139+
140+
presentation.verifiableCredential[0].issuer = localIssuer;
141+
const presentationMissingHolder = await createLocalVp({
142+
presentation
143+
});
144+
await assert.rejects(endpoints.verifyVp(
145+
presentationMissingHolder
146+
), 'Failed to reject a VP with self-asserted VC without holder.');
102147
});
103148

104149
it('When a self-asserted verifiable credential is secured using the ' +
@@ -107,9 +152,36 @@ describe('VP - Presentations Including Holder Claims', function() {
107152
'the holder property of the verifiable presentation.',
108153
async function() {
109154
this.test.link = `https://w3c.github.io/vc-data-model/#presentations-including-holder-claims:~:text=When%20a%20self%2Dasserted%20verifiable%20credential%20is%20secured%20using%20the%20same%20mechanism%20as%20the%20verifiable%20presentation%2C%20the%20value%20of%20the%20issuer%20property%20of%20the%20verifiable%20credential%20MUST%20be%20identical%20to%20the%20holder%20property%20of%20the%20verifiable%20presentation.`;
110-
// TODO: implement test
111-
this.test.cell.skipMessage = 'TBD';
112-
this.skip();
155+
const presentation = require('./input/presentation-vc-ok.json');
156+
157+
presentation.verifiableCredential[0].issuer = localIssuer;
158+
presentation.holder = localIssuer;
159+
const presentationHolderMatch = await createLocalVp({
160+
presentation
161+
});
162+
await assert.doesNotReject(endpoints.verifyVp(
163+
presentationHolderMatch
164+
), 'Failed to verify a VP containing a self-asserted VC.');
165+
166+
presentation.verifiableCredential[0].issuer = localIssuer;
167+
presentation.holder = 'did:example:acme';
168+
const presentationHolderMismatch = await createLocalVp({
169+
presentation
170+
});
171+
await assert.rejects(endpoints.verifyVp(
172+
presentationHolderMismatch
173+
), 'Failed to reject a VP with self-asserted VC ' +
174+
'with a holder/issuer mismatch.');
175+
176+
presentation.verifiableCredential[0].issuer = 'did:example:acme';
177+
presentation.holder = localIssuer;
178+
const presentationIssuerMismatch = await createLocalVp({
179+
presentation
180+
});
181+
await assert.rejects(endpoints.verifyVp(
182+
presentationIssuerMismatch
183+
), 'Failed to reject a VP with self-asserted VC ' +
184+
'with a holder/issuer mismatch.');
113185
});
114186
});
115187
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/4-7-issuer.js renamed to tests/4.7-issuer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ describe('Issuer', function() {
3535
require('./input/credential-ok.json'));
3636
vc.hasOwnProperty('issuer');
3737
});
38-
it('The value of the issuer property MUST be either a URL, or ' +
39-
'an object containing an id property whose value is a URL.',
38+
it('The value of the issuer property MUST be either a URL or an ' +
39+
'object containing an id property whose value is a URL; ' +
40+
'in either case, the issuer selects this URL to identify itself in a ' +
41+
'globally unambiguous way.',
4042
async function() {
4143
this.test.link = `https://w3c.github.io/vc-data-model/#issuer:~:text=The%20value%20of%20the%20issuer%20property%20MUST%20be%20either%20a%20URL%2C%20or%20an%20object%20containing%20an%20id%20property%20whose%20value%20is%20a%20URL`;
4244
await assert.doesNotReject(endpoints.issue(require(

0 commit comments

Comments
 (0)