Skip to content

Commit

Permalink
Add test for optional cryptosuite value.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Jun 21, 2024
1 parent 2b4e833 commit ac291ae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
22 changes: 16 additions & 6 deletions tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2024 Digital Bazaar, Inc.
* SPDX-License-Identifier: BSD-3-Clause
*/
import {
allowUnsafeCanonize,
invalidStringEncoding
} from './vc-generator/generators.js';
import {
deriveCredentials,
getMultikeys,
issueCredentials
} from './vc-generator/index.js';
import {
invalidStringEncoding,
noProofTypeorCryptosuite
} from './vc-generator/generators.js';
import {generators} from 'data-integrity-test-suite-assertion';

export async function verifySetup({credentials, keyTypes, suite}) {
Expand Down Expand Up @@ -149,8 +149,18 @@ export async function verifySetup({credentials, keyTypes, suite}) {
proofType: '',
cryptosuiteName: ''
},
// add a generator to turns safe mode off for proof cannonize and hash
generators: [noProofTypeorCryptosuite, invalidProofType, invalidCryptosuite]
// add a generator to turns safe mode off for proof canonize and hash
generators: [allowUnsafeCanonize, invalidProofType, invalidCryptosuite]
});
disclosed.invalid.noProofType = await deriveCredentials({
keys,
vectors: disclosedBasicVectors,
suiteName: suite,
initialParams: {
proofType: '',
},
// add a generator to turns safe mode off for proof canonize and hash
generators: [allowUnsafeCanonize, invalidProofType]
});
disclosed.invalid.nonUTF8 = await deriveCredentials({
keys,
Expand Down
15 changes: 15 additions & 0 deletions tests/suites/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ export function verifySuite({
disclosed?.invalid?.noProofTypeOrCryptosuite);
await verificationFail({credential, verifier});
});
it('The proof options MUST contain a type identifier for the ' +
'cryptographic suite (type) and MAY contain a cryptosuite ' +
'identifier (cryptosuite).', async function() {
this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=The%20proof%20options%20MUST%20contain%20a%20type%20identifier%20for%20the%20cryptographic%20suite%20(type)%20and%20MAY%20contain%20a%20cryptosuite%20identifier%20(cryptosuite).';
await verificationFail({
credential: cloneTestVector(
disclosed?.invalid?.noProofTypeOrCryptosuite),
verifier
});
await verificationFail({
credential: cloneTestVector(
disclosed?.invalid?.noProofType),
verifier
});
});

it('MUST fail to verify a base proof.', async function() {
const credential = cloneTestVector(base);
Expand Down
2 changes: 1 addition & 1 deletion tests/vc-generator/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import * as mocks from './mockMethods.js';

export function noProofTypeorCryptosuite({
export function allowUnsafeCanonize({
suite,
selectiveSuite,
...args}) {
Expand Down

0 comments on commit ac291ae

Please sign in to comment.