Skip to content

Commit 76c823d

Browse files
committed
Reuse DI generators for conformance setup.
1 parent 9455f73 commit 76c823d

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

tests/suites/conformance.js

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
* Copyright 2024 Digital Bazaar, Inc.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
5-
import {assertions} from 'data-integrity-test-suite-assertion';
5+
import {
6+
assertions,
7+
generators,
8+
issueCloned
9+
} from 'data-integrity-test-suite-assertion';
10+
import {getMultiKey} from '../vc-generator/key-gen.js';
611

712
export function assertConformance({
813
verifiers,
@@ -39,19 +44,45 @@ export function assertConformance({
3944
it('Conforming processors MUST produce errors when non-conforming ' +
4045
'documents are consumed.', async function() {
4146
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#:~:text=Conforming%20processors%20MUST%20produce%20errors%20when%20non%2Dconforming%20documents%20are%20consumed.';
42-
await assertions.verificationFail({
43-
verifier,
44-
credential: {},
45-
reason: 'Should '
46-
});
47+
for(const [key, credential] of credentials) {
48+
await assertions.verificationFail({
49+
verifier,
50+
credential,
51+
reason: `Should not verify VC with ${key}`
52+
});
53+
}
4754
});
4855
});
4956
}
5057
});
5158
}
52-
async function _setup({}) {
53-
// not bs58 encoded verificationMethod
54-
// type is not DataIntegrityProof
55-
// invalid cryptosuite name
59+
async function _setup({
60+
credential,
61+
suiteName,
62+
keyType,
63+
cryptosuite,
64+
mandatoryPointers,
65+
selectivePointers
66+
}) {
67+
const {
68+
invalidProofType,
69+
invalidVm,
70+
invalidCryptosuite
71+
} = generators?.mandatory;
72+
const credentials = new Map();
73+
const keyPair = await getMultiKey({keyType});
74+
const signer = keyPair.signer();
75+
// not bs58 encoded verificationMethod via invalidVm
76+
// type is not DataIntegrityProof invalidType
77+
// invalid cryptosuite name invalidCryptosuite
78+
credentials.set('invalidCryptosuite', await issueCloned(invalidCryptosuite({
79+
80+
})));
81+
credentials.set('invalidVerificationMethod', await issueCloned(invalidVm({
82+
83+
})));
84+
credentials.set('invalidProofType', await issueCloned(invalidProofType({
5685

86+
})));
87+
return credentials;
5788
}

0 commit comments

Comments
 (0)