Skip to content

Commit

Permalink
Add test for previousProof fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Sep 26, 2024
1 parent aa95825 commit df355a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions suites/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,18 @@ export function runDataIntegrityProofVerifyTests({
reason: 'Should not verify VC with invalid "proof.previousProof".'
});
});
it('Each value identifies another data integrity proof, all of which ' +
'MUST also verify for the current proof to be considered verified',
async function() {
this.test.link = 'https://w3c.github.io/vc-data-integrity/#:~:text=Each%20value%20identifies%20another%20data%20integrity%20proof%2C%20all%20of%20which%20MUST%20also%20verify%20for%20the%20current%20proof%20to%20be%20considered%20verified';
await verificationFail({
credential: credentials.clone('previousProofFail'),
verifier,
reason: 'Should not verify VC with a "previousProof" that does ' +
'not verify.'
});

});
}
});
}
Expand Down
28 changes: 28 additions & 0 deletions vc-generator/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const generators = {
invalidVm,
undefinedTerm,
previousProofString: defaultGen,
previousProofFail: defaultGen,
previousProofArray: defaultGen,
missingPreviousProofString: defaultGen,
missingPreviousProofArray: defaultGen,
Expand Down Expand Up @@ -87,6 +88,28 @@ export const setups = {
suites: [firstSuite, secondSuite]
};
},
previousProofFail({
cryptosuite,
signer,
mandatoryPointers,
selectivePointers,
proofId = 'urn:uuid:test:first:proof'

}) {
const {suite: firstSuite} = getSuites({
cryptosuite, signer,
mandatoryPointers, selectivePointers
});
firstSuite.proof = {id: proofId};
const {suite: secondSuite} = getSuites({
cryptosuite, signer,
mandatoryPointers, selectivePointers
});
secondSuite.proof = {previousProof: proofId};
return {
suites: [firstSuite, secondSuite]
};
},
previousProofArray({
cryptosuite,
signer,
Expand Down Expand Up @@ -181,6 +204,11 @@ export const cleanups = {
return !('@base' in c);
});
return issuedCredential;
},
previousProofFail({issuedCredential}) {
// make the first proof fail verification
issuedCredential.proof[0].proofValue = 'invalidProofValue';
return issuedCredential;
}
};
/**
Expand Down

0 comments on commit df355a8

Please sign in to comment.