Skip to content

Commit da5d08c

Browse files
committed
Move proofChain tests into optional tests.
1 parent 7038619 commit da5d08c

File tree

2 files changed

+67
-62
lines changed

2 files changed

+67
-62
lines changed

suites/create.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,6 @@ export function runDataIntegrityProofFormatTests({
216216
shouldHaveProofValue({proof, expectedPrefix, encodingName});
217217
}
218218
});
219-
it('If "proof.previousProof" property exists, it MUST be a string value ' +
220-
'or unordered list of string values.',
221-
function() {
222-
for(const proof of proofs) {
223-
if(proof.previousProof) {
224-
proof.previousProof.should.be.
225-
oneOf(['string', 'object'], 'Expected ' +
226-
'"proof.previousProof" to be a string or an array.');
227-
if(typeof proof.previousProof === 'object') {
228-
for(const previousProof in proof.previousProof) {
229-
previousProof.should.be.a('string', 'Expected ' +
230-
'"previousProof" items to be a string.');
231-
}
232-
}
233-
}
234-
}
235-
});
236219
it('Cryptographic suite designers MUST use mandatory proof value ' +
237220
'properties defined in Section 2.1 Proofs, and MAY define other ' +
238221
'properties specific to their cryptographic suite.', async function() {
@@ -420,6 +403,24 @@ export function runDataIntegrityProofFormatTests({
420403
}
421404
});
422405
}
406+
if(optionalTests.proofChain) {
407+
it('If "proof.previousProof" property exists, it MUST be a string ' +
408+
'value or unordered list of string values.', function() {
409+
for(const proof of proofs) {
410+
if(proof.previousProof) {
411+
proof.previousProof.should.be.
412+
oneOf(['string', 'object'], 'Expected ' +
413+
'"proof.previousProof" to be a string or an array.');
414+
if(typeof proof.previousProof === 'object') {
415+
for(const previousProof in proof.previousProof) {
416+
previousProof.should.be.a('string', 'Expected ' +
417+
'"previousProof" items to be a string.');
418+
}
419+
}
420+
}
421+
}
422+
});
423+
}
423424
});
424425
}
425426

suites/verify.js

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,6 @@ export function runDataIntegrityProofVerifyTests({
2929
before(async function() {
3030
proofValueTests = shouldBeProofValue({credentials, verifier});
3131
});
32-
it('An OPTIONAL string value (proof.previousProof) or unordered list of ' +
33-
'string values. Each value identifies another data integrity proof that ' +
34-
'MUST verify before the current proof is processed.', async function() {
35-
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=An%20OPTIONAL%20string%20value%20or%20unordered%20list%20of%20string%20values.%20Each%20value%20identifies%20another%20data%20integrity%20proof%20that%20MUST%20verify%20before%20the%20current%20proof%20is%20processed';
36-
await verificationSuccess({
37-
credential: credentials.clone('previousProofString'),
38-
verifier,
39-
reason: 'Should verify VC with a string "proof.previousProof".'
40-
});
41-
await verificationSuccess({
42-
credential: credentials.clone('previousProofArray'),
43-
verifier,
44-
reason: 'Should verify VC with an Array "proof.previousProof".'
45-
});
46-
});
47-
it('If an unordered list (proof), all referenced proofs in ' +
48-
'the array MUST verify.', async function() {
49-
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20an%20unordered%20list%2C%20all%20referenced%20proofs%20in%20the%20array%20MUST%20verify';
50-
await verificationSuccess({
51-
credential: credentials.clone('proofSet'),
52-
verifier,
53-
reason: 'Should verify VC with multiple proofs.'
54-
});
55-
});
56-
it('If a proof with id equal to previousProof does not exist in ' +
57-
'allProofs, an error MUST be raised and SHOULD convey an error type ' +
58-
'of PROOF_GENERATION_ERROR.', async function() {
59-
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20a%20proof%20with%20id%20equal%20to%20previousProof%20does%20not%20exist%20in%20allProofs%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.';
60-
await verificationFail({
61-
credential: credentials.clone('missingPreviousProofString'),
62-
verifier,
63-
reason: 'Should not verify VC with invalid "proof.previousProof".'
64-
});
65-
});
66-
it('If any element of previousProof list has an id attribute that does ' +
67-
'not match the id attribute of any element of allProofs, an error MUST ' +
68-
'be raised and SHOULD convey an error type of PROOF_GENERATION_ERROR.',
69-
async function() {
70-
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20any%20element%20of%20previousProof%20list%20has%20an%20id%20attribute%20that%20does%20not%20match%20the%20id%20attribute%20of%20any%20element%20of%20allProofs%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.';
71-
await verificationFail({
72-
credential: credentials.clone('missingPreviousProofArray'),
73-
verifier,
74-
reason: 'Should not verify VC with invalid "proof.previousProof".'
75-
});
76-
});
7732
it('When deserializing to RDF, implementations MUST ensure that the ' +
7833
'base URL is set to null.', async function() {
7934
this.test.link = 'https://w3c.github.io/vc-data-integrity/#securing-data-losslessly:~:text=When%20deserializing%20to%20RDF%2C%20implementations%20MUST%20ensure%20that%20the%20base%20URL%20is%20set%20to%20null.';
@@ -272,6 +227,55 @@ export function runDataIntegrityProofVerifyTests({
272227
});
273228
});
274229
}
230+
if(optionalTests.proofChain) {
231+
it('An OPTIONAL string value (proof.previousProof) or unordered list ' +
232+
'of string values. Each value identifies another data integrity proof ' +
233+
'that MUST verify before the current proof is processed.',
234+
async function() {
235+
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=An%20OPTIONAL%20string%20value%20or%20unordered%20list%20of%20string%20values.%20Each%20value%20identifies%20another%20data%20integrity%20proof%20that%20MUST%20verify%20before%20the%20current%20proof%20is%20processed';
236+
await verificationSuccess({
237+
credential: credentials.clone('previousProofString'),
238+
verifier,
239+
reason: 'Should verify VC with a string "proof.previousProof".'
240+
});
241+
await verificationSuccess({
242+
credential: credentials.clone('previousProofArray'),
243+
verifier,
244+
reason: 'Should verify VC with an Array "proof.previousProof".'
245+
});
246+
});
247+
it('If an unordered list (proof), all referenced proofs in ' +
248+
'the array MUST verify.', async function() {
249+
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20an%20unordered%20list%2C%20all%20referenced%20proofs%20in%20the%20array%20MUST%20verify';
250+
await verificationSuccess({
251+
credential: credentials.clone('proofSet'),
252+
verifier,
253+
reason: 'Should verify VC with multiple proofs.'
254+
});
255+
});
256+
it('If a proof with id equal to previousProof does not exist in ' +
257+
'allProofs, an error MUST be raised and SHOULD convey an error type ' +
258+
'of PROOF_GENERATION_ERROR.', async function() {
259+
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20a%20proof%20with%20id%20equal%20to%20previousProof%20does%20not%20exist%20in%20allProofs%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.';
260+
await verificationFail({
261+
credential: credentials.clone('missingPreviousProofString'),
262+
verifier,
263+
reason: 'Should not verify VC with invalid "proof.previousProof".'
264+
});
265+
});
266+
it('If any element of previousProof list has an id attribute that does ' +
267+
'not match the id attribute of any element of allProofs, an error MUST ' +
268+
'be raised and SHOULD convey an error type of PROOF_GENERATION_ERROR.',
269+
async function() {
270+
this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20any%20element%20of%20previousProof%20list%20has%20an%20id%20attribute%20that%20does%20not%20match%20the%20id%20attribute%20of%20any%20element%20of%20allProofs%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.';
271+
await verificationFail({
272+
credential: credentials.clone('missingPreviousProofArray'),
273+
verifier,
274+
reason: 'Should not verify VC with invalid "proof.previousProof".'
275+
});
276+
});
277+
278+
}
275279
});
276280
}
277281

0 commit comments

Comments
 (0)