@@ -11,11 +11,6 @@ import {createInitialVc, endpointCheck} from '../helpers.js';
11
11
import { expect } from 'chai' ;
12
12
import { localVerifier } from '../vc-verifier/index.js' ;
13
13
14
- export function algorithmSuite ( {
15
- suiteName
16
- } ) {
17
- }
18
-
19
14
export function commonAlgorithms ( {
20
15
credential,
21
16
issuers,
@@ -84,39 +79,31 @@ export function ecdsaRdfc2019Algorithms({
84
79
credential,
85
80
verifiers,
86
81
mandatoryPointers,
82
+ selectivePointers,
87
83
keyType,
88
84
suiteName,
89
- vcVersion
85
+ vcVersion,
86
+ suite = _suite
90
87
} ) {
91
88
return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
92
89
this . matrix = true ;
93
90
this . report = true ;
94
91
this . implemented = [ ...verifiers ] ;
95
92
this . rowLabel = 'Test Name' ;
96
93
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
+ } ) ;
97
104
for ( const [ name , { endpoints} ] of verifiers ) {
98
105
const [ verifier ] = endpoints ;
99
- // does the endpoint support this test?
100
- if ( ! endpointCheck ( { endpoint : verifier , keyType, vcVersion} ) ) {
101
- continue ;
102
- }
103
106
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
- } ) ;
120
107
beforeEach ( function ( ) {
121
108
this . currentTest . cell = {
122
109
rowId : this . currentTest . title ,
@@ -127,36 +114,77 @@ export function ecdsaRdfc2019Algorithms({
127
114
'the cryptographic suite (type) and a cryptosuite identifier ' +
128
115
'(cryptosuite).' , async function ( ) {
129
116
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
+ } ) ;
130
122
} ) ;
131
123
it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
132
124
'encoding. (proof.type)' , async function ( ) {
133
125
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
+ } ) ;
134
131
} ) ;
135
132
it ( 'If options.type is not set to the string DataIntegrityProof ' +
136
133
'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
137
134
'an error MUST be raised ' , async function ( ) {
138
135
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
+ } ) ;
139
141
} ) ;
140
142
it ( 'The proof options MUST contain a type identifier for the ' +
141
143
'cryptographic suite (type) and MUST contain a cryptosuite ' +
142
144
'identifier (cryptosuite).' , async function ( ) {
143
145
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
+ } ) ;
144
151
} ) ;
145
152
it ( 'If proofConfig.type is not set to DataIntegrityProof and/or ' +
146
153
'proofConfig.cryptosuite is not set to ecdsa-rdfc-2019, an error ' +
147
154
'MUST be raised' , async function ( ) {
148
155
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
+ } ) ;
149
161
} ) ;
150
162
it ( 'If proofConfig.created is set and if the value is not a valid ' +
151
163
'[XMLSCHEMA11-2] datetime, an error MUST be raised' , async function ( ) {
152
164
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
+ } ) ;
153
170
} ) ;
154
171
it ( 'The proof options MUST contain a type identifier for the ' +
155
172
'cryptographic suite (type) and MAY contain a cryptosuite ' +
156
173
'identifier (cryptosuite).' , async function ( ) {
157
174
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
+ } ) ;
158
180
} ) ;
159
181
} ) ;
160
182
}
161
183
} ) ;
162
184
}
185
+
186
+ async function _suite ( {
187
+
188
+ } ) {
189
+
190
+ }
0 commit comments