Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(11) Add assertion for mandatoryPointers and test for mandatoryPointers. #43

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "mandatoryPointer".');
};

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 @@ -259,6 +260,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