88 createValidCredential ,
99 getProofs ,
1010 isValidDatetime ,
11- isValidUtf8 ,
11+ proofExists ,
12+ secureCredential ,
1213 setupReportableTestSuite ,
1314 setupRow
1415} from './helpers.js' ;
@@ -36,16 +37,12 @@ describe('ecdsa-rdfc-2019 - Algorithms - Transformation', function() {
3637 for ( const [ columnId , { endpoints} ] of issuers ) {
3738 describe ( columnId , function ( ) {
3839 const [ issuer ] = endpoints ;
39- let issuedVc ;
40+ let securedCredential ;
4041 let proofs ;
41- let rdfc2019Proofs = [ ] ;
4242 before ( async function ( ) {
43- issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
44- proofs = getProofs ( issuedVc ) ;
45- if ( proofs ?. length ) {
46- rdfc2019Proofs = proofs . filter (
47- proof => proof ?. cryptosuite === cryptosuite ) ;
48- }
43+ securedCredential = await secureCredential (
44+ { issuer, vc : generateCredential ( ) } ) ;
45+ proofs = getProofs ( securedCredential ) ;
4946 } ) ;
5047 beforeEach ( setupRow ) ;
5148 const assertBefore = ( ) => {
@@ -60,44 +57,91 @@ describe('ecdsa-rdfc-2019 - Algorithms - Transformation', function() {
6057 '(cryptosuite).' ,
6158 async function ( ) {
6259 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
63- assertBefore ( ) ;
64- for ( const proof of rdfc2019Proofs ) {
65- should . exist ( proof . type , 'Expected a type identifier on ' +
66- 'the proof.' ) ;
67- should . exist ( proof . cryptosuite ,
68- 'Expected a cryptosuite identifier on the proof.' ) ;
69- }
60+ const proof = proofExists ( proofs ) ;
61+ should . exist ( proof . type ,
62+ 'Expected a type identifier on the proof.' ) ;
63+ should . exist ( proof . cryptosuite ,
64+ 'Expected a cryptosuite identifier on the proof.' ) ;
7065 } ) ;
7166 it ( 'Whenever this algorithm encodes strings, ' +
7267 'it MUST use UTF-8 encoding.' ,
7368 async function ( ) {
7469 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
75- assertBefore ( ) ;
76- for ( const proof of rdfc2019Proofs ) {
77- should . exist ( proof ?. proofValue ,
78- 'Expected proofValue to exist.' ) ;
79- isValidUtf8 ( proof . proofValue ) . should . equal (
80- true ,
81- 'Expected proofValue value to be a valid UTF-8 encoded string.'
82- ) ;
83- }
70+ const proof = proofExists ( proofs ) ;
71+ assertAllUtf8 ( proof ) ;
8472 } ) ;
8573 it ( 'If options.type is not set to the string DataIntegrityProof or ' +
8674 'options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
8775 'an error MUST be raised and SHOULD convey an error type ' +
8876 'of PROOF_TRANSFORMATION_ERROR.' ,
8977 async function ( ) {
9078 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
91- assertBefore ( ) ;
92- for ( const proof of rdfc2019Proofs ) {
93- should . exist ( proof . type ,
94- 'Expected a type identifier on the proof.' ) ;
95- should . exist ( proof . cryptosuite ,
96- 'Expected a cryptosuite identifier on the proof.' ) ;
97- proof . type . should . equal ( 'DataIntegrityProof' ,
98- 'Expected DataIntegrityProof type.' ) ;
99- proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
100- 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
79+ const proof = proofExists ( proofs ) ;
80+ should . exist ( proof . type ,
81+ 'Expected a type identifier on the proof.' ) ;
82+ should . exist ( proof . cryptosuite ,
83+ 'Expected a cryptosuite identifier on the proof.' ) ;
84+ proof . type . should . equal ( 'DataIntegrityProof' ,
85+ 'Expected DataIntegrityProof type.' ) ;
86+ proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
87+ 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
88+ } ) ;
89+ } ) ;
90+ }
91+ } ) ;
92+
93+ describe ( 'Algorithms - Proof Configuration (ecdsa-rdfc-2019)' , function ( ) {
94+ setupReportableTestSuite ( this ) ;
95+ this . implemented = [ ...issuers . keys ( ) ] ;
96+ for ( const [ columnId , { endpoints} ] of issuers ) {
97+ describe ( columnId , function ( ) {
98+ const [ issuer ] = endpoints ;
99+ let securedCredential ;
100+ let proofs ;
101+ before ( async function ( ) {
102+ securedCredential = await secureCredential (
103+ { issuer, vc : generateCredential ( ) } ) ;
104+ proofs = getProofs ( securedCredential ) ;
105+ } ) ;
106+ beforeEach ( setupRow ) ;
107+ it ( 'The proof options MUST contain a type identifier for the ' +
108+ 'cryptographic suite (type) and MUST contain a cryptosuite ' +
109+ 'identifier (cryptosuite).' ,
110+ async function ( ) {
111+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
112+ const proof = proofExists ( proofs ) ;
113+ should . exist ( proof . type ,
114+ 'Expected a type identifier on the proof.' ) ;
115+ should . exist ( proof . cryptosuite ,
116+ 'Expected a cryptosuite identifier on the proof.' ) ;
117+ } ) ;
118+ it ( 'If proofConfig.type is not set to DataIntegrityProof ' +
119+ 'and/or proofConfig.cryptosuite is not set to ecdsa-rdfc-2019, ' +
120+ 'an error MUST be raised and SHOULD convey an error type ' +
121+ 'of PROOF_GENERATION_ERROR.' ,
122+ async function ( ) {
123+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
124+ const proof = proofExists ( proofs ) ;
125+ should . exist ( proof . type ,
126+ 'Expected a type identifier on the proof.' ) ;
127+ should . exist ( proof . cryptosuite ,
128+ 'Expected a cryptosuite identifier on the proof.' ) ;
129+ proof . type . should . equal ( 'DataIntegrityProof' ,
130+ 'Expected DataIntegrityProof type.' ) ;
131+ proof . cryptosuite . should . equal ( 'ecdsa-rdfc-2019' ,
132+ 'Expected ecdsa-rdfc-2019 cryptosuite.' ) ;
133+ } ) ;
134+ it ( 'If proofConfig.created is set and if the value is not a ' +
135+ 'valid [XMLSCHEMA11-2] datetime, an error MUST be raised and ' +
136+ 'SHOULD convey an error type of PROOF_GENERATION_ERROR.' ,
137+ async function ( ) {
138+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-rdfc-2019' ;
139+ const proof = proofExists ( proofs ) ;
140+ if ( proof ?. created ) {
141+ isValidDatetime ( proof . created ) . should . equal (
142+ true ,
143+ 'Expected created value to be a valid datetime string.'
144+ ) ;
101145 }
102146 } ) ;
103147 } ) ;
@@ -114,16 +158,12 @@ describe('ecdsa-rdfc-2019 - Algorithms - Proof Configuration', function() {
114158 for ( const [ columnId , { endpoints} ] of issuers ) {
115159 describe ( columnId , function ( ) {
116160 const [ issuer ] = endpoints ;
117- let issuedVc ;
161+ let securedCredential ;
118162 let proofs ;
119- let rdfc2019Proofs = [ ] ;
120163 before ( async function ( ) {
121- issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
122- proofs = getProofs ( issuedVc ) ;
123- if ( proofs ?. length ) {
124- rdfc2019Proofs = proofs . filter (
125- proof => proof ?. cryptosuite === cryptosuite ) ;
126- }
164+ securedCredential = await secureCredential (
165+ { issuer, vc : generateCredential ( ) } ) ;
166+ proofs = getProofs ( securedCredential ) ;
127167 } ) ;
128168 beforeEach ( setupRow ) ;
129169 const assertBefore = ( ) => {
@@ -216,11 +256,9 @@ describe('ecdsa-rdfc-2019 - Algorithms - Proof Serialization', function() {
216256 '(cryptosuite).' ,
217257 async function ( ) {
218258 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-serialization-ecdsa-rdfc-2019' ;
219- assertBefore ( ) ;
220- for ( const proof of rdfc2019Proofs ) {
221- should . exist ( proof . type ,
222- 'Expected a type identifier on the proof.' ) ;
223- }
259+ const proof = proofExists ( proofs ) ;
260+ should . exist ( proof . type ,
261+ 'Expected a type identifier on the proof.' ) ;
224262 } ) ;
225263 } ) ;
226264 }
0 commit comments