Skip to content

Commit

Permalink
Add assertion for mandatoryPointers and test for mandatoryPointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Jun 30, 2024
1 parent 3ebb655 commit 9d926fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export const shouldNotUseCborTags = ({proof}) => {
should.exist(result, 'Expected proof to be decoded.');
};

export const shouldHaveMandatoryPointers = ({proof}) => {
const {mandatoryPointers} = parseBaseProofValue({proof});
should.exist(mandatoryPointers, 'Expected "mandatoryPointers" to exist.');
mandatoryPointers.should.be.an(
'Array', 'Expected "mandatoryPointers" to be an Array.');
mandatoryPointers.length.should.be.gt(
0, 'Expected at least one "mandatoyPointer".');
};

export const shouldBeMultibaseEncoded = async ({
expectedLength,
prefixes = {
Expand Down
8 changes: 8 additions & 0 deletions tests/suites/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
checkHmacKeyLength,
shouldBeMultibaseEncoded,
shouldBeProofValue,
shouldHaveMandatoryPointers,
shouldNotUseCborTags,
shouldVerifyDerivedProof
} from '../assertions.js';
Expand Down Expand Up @@ -221,6 +222,13 @@ export function createSuite({
shouldNotUseCborTags({proof});
}
});
it('The transformation options MUST contain an array of mandatory ' +
'JSON pointers (mandatoryPointers)', function() {
this.test.link = 'https://w3c.github.io/vc-di-bbs/#:~:text=The%20transformation%20options%20MUST%20contain%20an%20array%20of%20mandatory%20JSON%20pointers%20(mandatoryPointers)';
for(const proof of bbsProofs) {
shouldHaveMandatoryPointers({proof});
}
});
});
}
});
Expand Down

0 comments on commit 9d926fd

Please sign in to comment.