Skip to content

Commit 8a870fc

Browse files
committed
add data model tests
Signed-off-by: PatStLouis <[email protected]>
1 parent 32a8209 commit 8a870fc

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

tests/70-data-model.js

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55
import {
6+
assertIssuedVc,
67
createInitialVc,
78
createValidCredential,
89
getProofs,
@@ -25,6 +26,47 @@ const {match: issuers} = endpoints.filterByTag({
2526
property: 'issuers'
2627
});
2728

29+
describe('Data Model - Verification Methods (Multikey)', function() {
30+
setupReportableTestSuite(this);
31+
this.implemented = [...issuers.keys()];
32+
let validCredential;
33+
before(async function() {
34+
validCredential = await createValidCredential();
35+
});
36+
for(const [columnId, {endpoints}] of issuers) {
37+
describe(columnId, function() {
38+
const [issuer] = endpoints;
39+
let issuedVc;
40+
let proofs;
41+
let ecdsaProofs = [];
42+
before(async function() {
43+
issuedVc = await createInitialVc({issuer, vc: validCredential});
44+
proofs = getProofs(issuedVc);
45+
if(proofs?.length) {
46+
ecdsaProofs = proofs.filter(
47+
proof => cryptosuites.includes(proof?.cryptosuite));
48+
}
49+
});
50+
beforeEach(setupRow);
51+
it('The publicKeyMultibase value of the verification method ' +
52+
'MUST start with the base-58-btc prefix (z), as defined in ' +
53+
'the Multibase section of Controller Documents 1.0.',
54+
async function() {
55+
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
56+
assertIssuedVc(issuedVc, proofs, ecdsaProofs);
57+
});
58+
it('A Multibase-encoded ECDSA 256-bit public key value or an ' +
59+
'ECDSA 384-bit public key value follows, as defined in the Multikey ' +
60+
'section of Controller Documents 1.0. Any other encoding ' +
61+
'MUST NOT be allowed.',
62+
async function() {
63+
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
64+
assertIssuedVc(issuedVc, proofs, ecdsaProofs);
65+
});
66+
});
67+
}
68+
});
69+
2870
describe('Data Model - Proof Representations', function() {
2971
setupReportableTestSuite(this);
3072
this.implemented = [...issuers.keys()];
@@ -47,24 +89,16 @@ describe('Data Model - Proof Representations', function() {
4789
}
4890
});
4991
beforeEach(setupRow);
50-
const assertBefore = () => {
51-
should.exist(issuedVc,
52-
'Expected issuer to have issued a credential.');
53-
should.exist(proofs,
54-
'Expected credential to have a proof.');
55-
ecdsaProofs.length.should.be.gte(1,
56-
'Expected at least one ecdsa cryptosuite.');
57-
};
5892
it('The type property MUST be DataIntegrityProof.',
5993
async function() {
6094
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
61-
assertBefore();
95+
assertIssuedVc(issuedVc, proofs, ecdsaProofs);
6296
});
6397
it('The cryptosuite property MUST be ecdsa-rdfc-2019, ' +
6498
'ecdsa-jcs-2019, or ecdsa-sd-2023.',
6599
async function() {
66100
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
67-
assertBefore();
101+
assertIssuedVc(issuedVc, proofs, ecdsaProofs);
68102
});
69103
});
70104
}

0 commit comments

Comments
 (0)