2
2
* Copyright 2024 Digital Bazaar, Inc.
3
3
* SPDX-License-Identifier: BSD-3-Clause
4
4
*/
5
+ import { createInitialVc , endpointCheck } from '../helpers.js' ;
6
+ import { expect } from 'chai' ;
5
7
6
8
export function algorithmSuite ( {
7
9
suiteName
@@ -23,9 +25,11 @@ export function algorithmSuite({
23
25
}
24
26
25
27
export function ecdsaRdfc2019Algorithms ( {
28
+ credential,
26
29
endpoints,
27
- suiteName ,
30
+ mandatoryPointers ,
28
31
keyType,
32
+ suiteName,
29
33
vcVersion
30
34
} ) {
31
35
return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
@@ -35,7 +39,28 @@ export function ecdsaRdfc2019Algorithms({
35
39
this . rowLabel = 'Test Name' ;
36
40
this . columnLabel = 'Implementation' ;
37
41
for ( const [ name , { endpoints : issuers } ] of endpoints ) {
42
+ const [ issuer ] = issuers ;
43
+ // does the endpoint support this test?
44
+ if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
45
+ continue ;
46
+ }
38
47
describe ( `${ name } : ${ keyType } ` , function ( ) {
48
+ let securedCredential = null ;
49
+ let proofs = [ ] ;
50
+ before ( async function ( ) {
51
+ securedCredential = await createInitialVc ( {
52
+ issuer,
53
+ vcVersion,
54
+ vc : credential ,
55
+ mandatoryPointers
56
+ } ) ;
57
+ if ( securedCredential ) {
58
+ proofs = Array . isArray ( securedCredential . proof ) ?
59
+ securedCredential ?. proof : [ securedCredential ?. proof ] ;
60
+ // only test proofs that match the relevant cryptosuite
61
+ proofs = proofs . filter ( p => p ?. cryptosuite === suiteName ) ;
62
+ }
63
+ } ) ;
39
64
beforeEach ( function ( ) {
40
65
this . currentTest . cell = {
41
66
rowId : this . currentTest . title ,
@@ -50,6 +75,14 @@ export function ecdsaRdfc2019Algorithms({
50
75
it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
51
76
'encoding. (proof.type)' , async function ( ) {
52
77
this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
78
+ for ( const proof of proofs ) {
79
+ expect ( proof ?. type ) . to . exist ;
80
+ expect ( proof . type ) . to . be . a ( 'string' ) ;
81
+ expect (
82
+ proof . type . isWellFormed ( ) ,
83
+ 'Expected string to be a well formed UTF string'
84
+ ) . to . be . true ;
85
+ }
53
86
} ) ;
54
87
it ( 'If options.type is not set to the string DataIntegrityProof ' +
55
88
'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
0 commit comments