55import {
66 generateCredential ,
77 isValidDatetime ,
8+ < << << << HEAD
89 proofExists ,
910 secureCredential ,
11+ = === ===
12+ << << << < HEAD
13+ isValidUtf8 ,
14+ = === ===
15+ proofExists ,
16+ secureCredential ,
17+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
18+ >>> >>> > ec4cd6a ( improve proof handling when asserting a secured credential )
1019 setupReportableTestSuite ,
1120 setupRow
1221} from './helpers.js' ;
@@ -33,27 +42,67 @@ describe('Algorithms - Transformation (ecdsa-rdfc-2019)', function() {
3342 for ( const [ columnId , { endpoints} ] of issuers ) {
3443 describe ( columnId , function ( ) {
3544 const [ issuer ] = endpoints ;
45+ < << << << HEAD
3646 let securedCredential ;
3747 before ( async function ( ) {
3848 securedCredential = await secureCredential (
3949 { issuer, vc : generateCredential ( ) } ) ;
50+ = === ===
51+ << << << < HEAD
52+ let issuedVc ;
53+ let proofs ;
54+ let rdfc2019Proofs = [ ] ;
55+ before ( async function ( ) {
56+ issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
57+ proofs = getProofs ( issuedVc ) ;
58+ if ( proofs ?. length ) {
59+ rdfc2019Proofs = proofs . filter (
60+ proof => proof ?. cryptosuite === cryptosuite ) ;
61+ }
62+ = === ===
63+ let securedCredential ;
64+ let proofs ;
65+ before ( async function ( ) {
66+ securedCredential = await secureCredential (
67+ { issuer, vc : generateCredential ( ) } ) ;
68+ proofs = getProofs ( securedCredential ) ;
69+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
70+ >>> > >>> ec4cd6a ( improve proof handling when asserting a secured credential )
4071 } ) ;
4172 beforeEach ( setupRow ) ;
4273 it ( 'The transformation options MUST contain a type identifier ' +
4374 'for the cryptographic suite (type) and a cryptosuite identifier ' +
4475 '(cryptosuite).' ,
4576 async function ( ) {
4677 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
78+ < << << << HEAD
4779 const proof = proofExists ( securedCredential ) ;
80+ === === =
81+ < << << << HEAD
82+ assertBefore ( ) ;
83+ for ( const proof of rdfc2019Proofs ) {
84+ should . exist ( proof . type , 'Expected a type identifier on ' +
85+ 'the proof.' ) ;
86+ should . exist ( proof . cryptosuite ,
87+ 'Expected a cryptosuite identifier on the proof.' ) ;
88+ }
89+ = === ===
90+ const proof = proofExists ( proofs ) ;
91+ >>> >>> > ec4cd6a (improve proof handling when asserting a secured credential)
4892 should.exist(proof.type,
4993 'Expected a type identifier on the proof.');
5094 should.exist(proof.cryptosuite,
5195 'Expected a cryptosuite identifier on the proof.');
96+ < << << << HEAD
97+ = === ===
98+ >>> >>> > 265e798 (improve proof handling when asserting a secured credential)
99+ >>> >>> > ec4cd6a (improve proof handling when asserting a secured credential)
52100 } ) ;
53101 it ( 'Whenever this algorithm encodes strings, ' +
54102 'it MUST use UTF-8 encoding.' ,
55103 async function ( ) {
56104 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
105+ < << << << HEAD
57106 const proof = proofExists ( securedCredential ) ;
58107 assertAllUtf8 ( proof ) ;
59108 } ) ;
@@ -124,11 +173,113 @@ describe('Algorithms - Proof Configuration (ecdsa-rdfc-2019)', function() {
124173 const proof = proofExists ( securedCredential ) ;
125174 if ( proof ?. created ) {
126175 isValidDatetime ( proof . created ) . should . equal (
176+ = === ===
177+ << < << << HEAD
178+ assertBefore ( ) ;
179+ for ( const proof of rdfc2019Proofs ) {
180+ should . exist ( proof ?. proofValue ,
181+ 'Expected proofValue to exist.' ) ;
182+ isValidUtf8 ( proof . proofValue ) . should . equal (
183+ > >>> >>> ec4cd6a ( improve proof handling when asserting a secured credential )
184+ true ,
185+ 'Expected created value to be a valid datetime string.'
186+ ) ;
187+ }
188+ = === ===
189+ const proof = proofExists ( proofs ) ;
190+ assertAllUtf8 ( proof ) ;
191+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
192+ } ) ;
193+ < << << << HEAD
194+ = === ===
195+ it ( 'If options.type is not set to the string DataIntegrityProof or ' +
196+ 'options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
197+ 'an error MUST be raised and SHOULD convey an error type ' +
198+ 'of PROOF_TRANSFORMATION_ERROR.' ,
199+ async function ( ) {
200+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
201+ < << << << HEAD
202+ assertBefore ( ) ;
203+ for ( const proof of rdfc2019Proofs ) {
204+ should . exist ( proof . type ,
205+ 'Expected a type identifier on the proof.' ) ;
206+ should . exist ( proof . cryptosuite ,
207+ 'Expected a cryptosuite identifier on the proof.' ) ;
208+ proof . type . should . equal ( 'DataIntegrityProof' ,
209+ 'Expected DataIntegrityProof type.' ) ;
210+ proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
211+ 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
212+ = === ===
213+ const proof = proofExists ( proofs ) ;
214+ should . exist ( proof . type ,
215+ 'Expected a type identifier on the proof.' ) ;
216+ should . exist ( proof . cryptosuite ,
217+ 'Expected a cryptosuite identifier on the proof.' ) ;
218+ proof . type . should . equal ( 'DataIntegrityProof' ,
219+ 'Expected DataIntegrityProof type.' ) ;
220+ proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
221+ 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
222+ } ) ;
223+ } ) ;
224+ }
225+ } ) ;
226+
227+ describe ( 'Algorithms - Proof Configuration (ecdsa-rdfc-2019)' , function ( ) {
228+ setupReportableTestSuite ( this ) ;
229+ this . implemented = [ ...issuers . keys ( ) ] ;
230+ for ( const [ columnId , { endpoints} ] of issuers ) {
231+ describe ( columnId , function ( ) {
232+ const [ issuer ] = endpoints ;
233+ let securedCredential ;
234+ let proofs ;
235+ before ( async function ( ) {
236+ securedCredential = await secureCredential (
237+ { issuer, vc : generateCredential ( ) } ) ;
238+ proofs = getProofs ( securedCredential ) ;
239+ } ) ;
240+ beforeEach ( setupRow ) ;
241+ it ( 'The proof options MUST contain a type identifier for the ' +
242+ 'cryptographic suite (type) and MUST contain a cryptosuite ' +
243+ 'identifier (cryptosuite).' ,
244+ async function ( ) {
245+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
246+ const proof = proofExists ( proofs ) ;
247+ should . exist ( proof . type ,
248+ 'Expected a type identifier on the proof.' ) ;
249+ should . exist ( proof . cryptosuite ,
250+ 'Expected a cryptosuite identifier on the proof.' ) ;
251+ } ) ;
252+ it ( 'If proofConfig.type is not set to DataIntegrityProof ' +
253+ 'and/or proofConfig.cryptosuite is not set to ecdsa-rdfc-2019, ' +
254+ 'an error MUST be raised and SHOULD convey an error type ' +
255+ 'of PROOF_GENERATION_ERROR.' ,
256+ async function ( ) {
257+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
258+ const proof = proofExists ( proofs ) ;
259+ should . exist ( proof . type ,
260+ 'Expected a type identifier on the proof.' ) ;
261+ should . exist ( proof . cryptosuite ,
262+ 'Expected a cryptosuite identifier on the proof.' ) ;
263+ proof . type . should . equal ( 'DataIntegrityProof' ,
264+ 'Expected DataIntegrityProof type.' ) ;
265+ proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
266+ 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
267+ } ) ;
268+ it ( 'If proofConfig.created is set and if the value is not a ' +
269+ 'valid [XMLSCHEMA11-2] datetime, an error MUST be raised and ' +
270+ 'SHOULD convey an error type of PROOF_GENERATION_ERROR.' ,
271+ async function ( ) {
272+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
273+ const proof = proofExists ( proofs ) ;
274+ if ( proof ?. created ) {
275+ isValidDatetime ( proof . created ) . should . equal (
127276 true ,
128277 'Expected created value to be a valid datetime string.'
129278 ) ;
279+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
130280 }
131281 } ) ;
282+ > >>> >>> ec4cd6a ( improve proof handling when asserting a secured credential )
132283 } ) ;
133284 }
134285} ) ;
@@ -139,20 +290,56 @@ describe('Algorithms - Proof Serialization (ecdsa-rdfc-2019)', function() {
139290 for ( const [ columnId , { endpoints} ] of issuers ) {
140291 describe ( columnId , function ( ) {
141292 const [ issuer ] = endpoints ;
293+ < << << << HEAD
294+ let securedCredential ;
295+ before ( async function ( ) {
296+ securedCredential = await secureCredential (
297+ { issuer, vc : generateCredential ( ) } ) ;
298+ = === ===
299+ << << << < HEAD
300+ let issuedVc ;
301+ let proofs ;
302+ let rdfc2019Proofs = [ ] ;
303+ before ( async function ( ) {
304+ issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
305+ proofs = getProofs ( issuedVc ) ;
306+ if ( proofs ?. length ) {
307+ rdfc2019Proofs = proofs . filter (
308+ proof => proof ?. cryptosuite === cryptosuite ) ;
309+ }
310+ = === ===
142311 let securedCredential ;
312+ let proofs ;
143313 before ( async function ( ) {
144314 securedCredential = await secureCredential (
145315 { issuer, vc : generateCredential ( ) } ) ;
316+ proofs = getProofs ( securedCredential ) ;
317+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
318+ >>> > >>> ec4cd6a ( improve proof handling when asserting a secured credential )
146319 } ) ;
147320 beforeEach ( setupRow ) ;
148321 it ( 'The proof options MUST contain a type identifier for the ' +
149322 'cryptographic suite (type) and MAY contain a cryptosuite identifier ' +
150323 '(cryptosuite).' ,
151324 async function ( ) {
152325 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-serialization-ecdsa-rdfc-2019' ;
326+ < << << << HEAD
153327 const proof = proofExists ( securedCredential ) ;
154328 should . exist ( proof . type ,
155329 'Expected a type identifier on the proof.' ) ;
330+ = === ===
331+ << << << < HEAD
332+ assertBefore ( ) ;
333+ for ( const proof of rdfc2019Proofs ) {
334+ should . exist ( proof . type ,
335+ 'Expected a type identifier on the proof.' ) ;
336+ }
337+ = === ===
338+ const proof = proofExists ( proofs ) ;
339+ should . exist ( proof . type ,
340+ 'Expected a type identifier on the proof.' ) ;
341+ > >>> >>> 265e798 ( improve proof handling when asserting a secured credential )
342+ >>> > >>> ec4cd6a ( improve proof handling when asserting a secured credential )
156343 } ) ;
157344 } ) ;
158345 }
0 commit comments