Skip to content

Commit 32a8209

Browse files
committed
Add proof representation test block
Signed-off-by: PatStLouis <[email protected]>
1 parent bcef380 commit 32a8209

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/70-data-model.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*!
2+
* Copyright 2024 Digital Bazaar, Inc.
3+
* SPDX-License-Identifier: BSD-3-Clause
4+
*/
5+
import {
6+
createInitialVc,
7+
createValidCredential,
8+
getProofs,
9+
setupReportableTestSuite,
10+
setupRow
11+
} from './helpers.js';
12+
import chai from 'chai';
13+
import {endpoints} from 'vc-test-suite-implementations';
14+
15+
const should = chai.should();
16+
17+
const cryptosuites = [
18+
'ecdsa-sd-2023',
19+
'ecdsa-jcs-2019',
20+
'ecdsa-rdfc-2019',
21+
];
22+
23+
const {match: issuers} = endpoints.filterByTag({
24+
tags: cryptosuites,
25+
property: 'issuers'
26+
});
27+
28+
describe('Data Model - Proof Representations', function() {
29+
setupReportableTestSuite(this);
30+
this.implemented = [...issuers.keys()];
31+
let validCredential;
32+
before(async function() {
33+
validCredential = await createValidCredential();
34+
});
35+
for(const [columnId, {endpoints}] of issuers) {
36+
describe(columnId, function() {
37+
const [issuer] = endpoints;
38+
let issuedVc;
39+
let proofs;
40+
let ecdsaProofs = [];
41+
before(async function() {
42+
issuedVc = await createInitialVc({issuer, vc: validCredential});
43+
proofs = getProofs(issuedVc);
44+
if(proofs?.length) {
45+
ecdsaProofs = proofs.filter(
46+
proof => cryptosuites.includes(proof?.cryptosuite));
47+
}
48+
});
49+
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+
};
58+
it('The type property MUST be DataIntegrityProof.',
59+
async function() {
60+
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
61+
assertBefore();
62+
});
63+
it('The cryptosuite property MUST be ecdsa-rdfc-2019, ' +
64+
'ecdsa-jcs-2019, or ecdsa-sd-2023.',
65+
async function() {
66+
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof';
67+
assertBefore();
68+
});
69+
});
70+
}
71+
});

0 commit comments

Comments
 (0)