@@ -11,11 +11,6 @@ import {createInitialVc, endpointCheck} from '../helpers.js';
1111import { expect } from 'chai' ;
1212import { localVerifier } from '../vc-verifier/index.js' ;
1313
14- export function algorithmSuite ( {
15- suiteName
16- } ) {
17- }
18-
1914export function commonAlgorithms ( {
2015 credential,
2116 issuers,
@@ -84,39 +79,31 @@ export function ecdsaRdfc2019Algorithms({
8479 credential,
8580 verifiers,
8681 mandatoryPointers,
82+ selectivePointers,
8783 keyType,
8884 suiteName,
89- vcVersion
85+ vcVersion,
86+ suite = _suite
9087} ) {
9188 return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
9289 this . matrix = true ;
9390 this . report = true ;
9491 this . implemented = [ ...verifiers ] ;
9592 this . rowLabel = 'Test Name' ;
9693 this . columnLabel = 'Implementation' ;
94+ let credentials = new Map ( ) ;
95+ before ( async function ( ) {
96+ credentials = await setup ( {
97+ suiteName,
98+ keyType,
99+ credential,
100+ mandatoryPointers,
101+ selectivePointers
102+ } ) ;
103+ } ) ;
97104 for ( const [ name , { endpoints} ] of verifiers ) {
98105 const [ verifier ] = endpoints ;
99- // does the endpoint support this test?
100- if ( ! endpointCheck ( { endpoint : verifier , keyType, vcVersion} ) ) {
101- continue ;
102- }
103106 describe ( `${ name } : ${ keyType } ` , function ( ) {
104- let securedCredential = null ;
105- let proofs = [ ] ;
106- before ( async function ( ) {
107- securedCredential = await createInitialVc ( {
108- issuer,
109- vcVersion,
110- vc : credential ,
111- mandatoryPointers
112- } ) ;
113- if ( securedCredential ) {
114- proofs = Array . isArray ( securedCredential . proof ) ?
115- securedCredential ?. proof : [ securedCredential ?. proof ] ;
116- // only test proofs that match the relevant cryptosuite
117- proofs = proofs . filter ( p => p ?. cryptosuite === suiteName ) ;
118- }
119- } ) ;
120107 beforeEach ( function ( ) {
121108 this . currentTest . cell = {
122109 rowId : this . currentTest . title ,
@@ -127,36 +114,77 @@ export function ecdsaRdfc2019Algorithms({
127114 'the cryptographic suite (type) and a cryptosuite identifier ' +
128115 '(cryptosuite).' , async function ( ) {
129116 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
117+ await assertions . verificationFail ( {
118+ verifier,
119+ credentials : credentials . get ( 'noTypeOrCryptosuite' ) ,
120+ reason : 'Should not verify VC w/ no type or cryptosuite identifier'
121+ } ) ;
130122 } ) ;
131123 it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
132124 'encoding. (proof.type)' , async function ( ) {
133125 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
126+ await assertions . verificationFail ( {
127+ verifier,
128+ credentials : credentials . get ( 'notUTF8' ) ,
129+ reason : 'Should not verify VC w/ non UTF-8 encoding'
130+ } ) ;
134131 } ) ;
135132 it ( 'If options.type is not set to the string DataIntegrityProof ' +
136133 'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
137134 'an error MUST be raised ' , async function ( ) {
138135 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019:~:text=If%20options.type%20is%20not%20set%20to%20the%20string%20DataIntegrityProof%20and%20options.cryptosuite%20is%20not%20set%20to%20the%20string%20ecdsa%2Drdfc%2D2019%2C%20an%20error%20MUST%20be%20raised' ;
136+ await assertions . verificationFail ( {
137+ verifier,
138+ credentials : credentials . get ( 'noTypeOrCryptosuite' ) ,
139+ reason : 'Should not verify VC w/ no type or cryptosuite identifier'
140+ } ) ;
139141 } ) ;
140142 it ( 'The proof options MUST contain a type identifier for the ' +
141143 'cryptographic suite (type) and MUST contain a cryptosuite ' +
142144 'identifier (cryptosuite).' , async function ( ) {
143145 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
146+ await assertions . verificationFail ( {
147+ verifier,
148+ credentials : credentials . get ( 'noTypeOrCryptosuite' ) ,
149+ reason : 'Should not verify VC w/ no type or cryptosuite identifier'
150+ } ) ;
144151 } ) ;
145152 it ( 'If proofConfig.type is not set to DataIntegrityProof and/or ' +
146153 'proofConfig.cryptosuite is not set to ecdsa-rdfc-2019, an error ' +
147154 'MUST be raised' , async function ( ) {
148155 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019:~:text=If%20proofConfig.type%20is%20not%20set%20to%20DataIntegrityProof%20and/or%20proofConfig.cryptosuite%20is%20not%20set%20to%20ecdsa%2Drdfc%2D2019%2C%20an%20error%20MUST%20be%20raised' ;
156+ await assertions . verificationFail ( {
157+ verifier,
158+ credentials : credentials . get ( 'noTypeOrCryptosuite' ) ,
159+ reason : 'Should not verify VC w/ no type or cryptosuite identifier'
160+ } ) ;
149161 } ) ;
150162 it ( 'If proofConfig.created is set and if the value is not a valid ' +
151163 '[XMLSCHEMA11-2] datetime, an error MUST be raised' , async function ( ) {
152164 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
165+ await assertions . verificationFail ( {
166+ verifier,
167+ credentials : credentials . get ( 'invalidCreated' ) ,
168+ reason : 'Should not verify VC w/ invalid "proof.created"'
169+ } ) ;
153170 } ) ;
154171 it ( 'The proof options MUST contain a type identifier for the ' +
155172 'cryptographic suite (type) and MAY contain a cryptosuite ' +
156173 'identifier (cryptosuite).' , async function ( ) {
157174 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#proof-serialization-ecdsa-rdfc-2019' ;
175+ await assertions . verificationFail ( {
176+ verifier,
177+ credentials : credentials . get ( 'noTypeOrCryptosuite' ) ,
178+ reason : 'Should not verify VC w/ no type or cryptosuite identifier'
179+ } ) ;
158180 } ) ;
159181 } ) ;
160182 }
161183 } ) ;
162184}
185+
186+ async function _suite ( {
187+
188+ } ) {
189+
190+ }
0 commit comments