22 * Copyright 2024 Digital Bazaar, Inc.
33 * SPDX-License-Identifier: BSD-3-Clause
44 */
5+ import { createInitialVc , endpointCheck } from '../helpers.js' ;
6+ import { expect } from 'chai' ;
57
68export function algorithmSuite ( {
79 suiteName
@@ -23,9 +25,11 @@ export function algorithmSuite({
2325}
2426
2527export function ecdsaRdfc2019Algorithms ( {
28+ credential,
2629 endpoints,
27- suiteName ,
30+ mandatoryPointers ,
2831 keyType,
32+ suiteName,
2933 vcVersion
3034} ) {
3135 return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
@@ -35,7 +39,28 @@ export function ecdsaRdfc2019Algorithms({
3539 this . rowLabel = 'Test Name' ;
3640 this . columnLabel = 'Implementation' ;
3741 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+ }
3847 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+ } ) ;
3964 beforeEach ( function ( ) {
4065 this . currentTest . cell = {
4166 rowId : this . currentTest . title ,
@@ -50,6 +75,14 @@ export function ecdsaRdfc2019Algorithms({
5075 it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
5176 'encoding. (proof.type)' , async function ( ) {
5277 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+ }
5386 } ) ;
5487 it ( 'If options.type is not set to the string DataIntegrityProof ' +
5588 'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
0 commit comments