@@ -87,49 +87,81 @@ describe('Advanced Concepts', function() {
8787 'Failed to accept a VC with valid relatedResource mediaType.' ) ;
8888
8989 negativeFixture = structuredClone ( credential ) ;
90- negativeFixture . relatedResource = [ {
91- id : relatedResource . id ,
92- } ] ;
90+
91+ // Data model negative test (array of strings)
92+ negativeFixture . relatedResource = [
93+ relatedResource . id
94+ ] ;
9395 await assert . rejects ( endpoints . issue ( negativeFixture ) ,
94- 'Failed to reject a VC with a relatedResource as an array of strings.' ) ;
96+ 'Failed to reject a VC with a relatedResource as array of strings.' ) ;
9597 } ) ;
9698 it ( 'The identifier for the resource is REQUIRED and conforms to the ' +
9799 'format defined in Section 4.4 Identifiers.' , async function ( ) {
98100 this . test . link = `https://w3c.github.io/vc-data-model/#integrity-of-related-resources:~:text=The%20identifier%20for%20the%20resource%20is%20REQUIRED%20and%20conforms%20to%20the%20format%20defined%20in%20Section%204.4%20Identifiers.%20The%20value%20MUST%20be%20unique%20among%20the%20list%20of%20related%20resource%20objects.` ;
99- await assert . rejects ( endpoints . issue ( require (
100- './input/relatedResource/relatedResource-missing-id-fail.json'
101- ) ) ,
102- 'Failed to reject a VC with a relatedResource with no `id` field.' ) ;
101+
102+ negativeFixture = structuredClone ( credential ) ;
103+
104+ // Missing ID negative test
105+ negativeFixture . relatedResource = [ {
106+ digestMultibase : relatedResource . digestMultibase ,
107+ } ] ;
108+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
109+ 'Failed to reject a VC with a relatedResource with no `id` field.' ) ;
103110 } ) ;
104111 it ( 'The value MUST be unique ' +
105112 'among the list of related resource objects.' , async function ( ) {
106113 this . test . link = `https://w3c.github.io/vc-data-model/#integrity-of-related-resources:~:text=The%20identifier%20for%20the%20resource%20is%20REQUIRED%20and%20conforms%20to%20the%20format%20defined%20in%20Section%204.4%20Identifiers.%20The%20value%20MUST%20be%20unique%20among%20the%20list%20of%20related%20resource%20objects.` ;
107- await assert . rejects ( endpoints . issue ( require (
108- './input/relatedResource/relatedResource-duplicate-id-fail.json'
109- ) ) ,
110- 'Failed to reject a VC with a relatedResource with ' +
114+
115+ negativeFixture = structuredClone ( credential ) ;
116+
117+ // Duplicate ID negative test
118+ negativeFixture . relatedResource = [ {
119+ id : relatedResource . id ,
120+ digestSRI : relatedResource . digestSRI ,
121+ } , {
122+ id : relatedResource . id ,
123+ digestMultibase : relatedResource . digestMultibase ,
124+ } ] ;
125+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
126+ 'Failed to reject a VC with a relatedResource with ' +
111127 'a duplicate `id` field.' ) ;
112128 } ) ;
113129 it ( 'Each object associated with relatedResource MUST contain at least ' +
114130 'a digestSRI or a digestMultibase value.' , async function ( ) {
115131 this . test . link = `https://w3c.github.io/vc-data-model/#integrity-of-related-resources:~:text=Each%20object%20associated%20with%20relatedResource%20MUST%20contain%20at%20least%20a%20digestSRI%20or%20a%20digestMultibase%20value.` ;
116- await assert . rejects ( endpoints . issue ( require (
117- './input/relatedResource/relatedResource-no-digest-fail.json'
118- ) ) ,
119- 'Failed to reject a VC with a relatedResource with no digest info.' ) ;
132+
133+ negativeFixture = structuredClone ( credential ) ;
134+
135+ // Missing digest negative test
136+ negativeFixture . relatedResource = [ {
137+ id : relatedResource . id
138+ } ] ;
139+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
140+ 'Failed to reject a VC with a relatedResource with no digest info.' ) ;
120141 } ) ;
121142 it ( 'If the digest provided by the issuer does not match the digest ' +
122143 'computed for the retrieved resource, the conforming verifier ' +
123144 'implementation MUST produce an error.' , async function ( ) {
124145 this . test . link = `https://w3c.github.io/vc-data-model/#integrity-of-related-resources:~:text=If%20the%20digest%20provided%20by%20the%20issuer%20does%20not%20match%20the%20digest%20computed%20for%20the%20retrieved%20resource%2C%20the%20conforming%20verifier%20implementation%20MUST%20produce%20an%20error.` ;
125- await assert . rejects ( endpoints . issue ( require (
126- './input/relatedResource/relatedResource-digest-sri-fail.json'
127- ) ) ,
128- 'Failed to reject a VC with a relatedResource with wrong digest.' ) ;
129- await assert . rejects ( endpoints . issue ( require (
130- './input/relatedResource/relatedResource-digest-multibase-fail.json'
131- ) ) ,
132- 'Failed to reject a VC with a relatedResource with wrong digest.' ) ;
146+
147+ negativeFixture = structuredClone ( credential ) ;
148+
149+ // Wrong digestMultibase negative test
150+ negativeFixture . relatedResource = [ {
151+ id : relatedResource . id ,
152+ digestMultibase : 'uM4RgWQc3RUDtjJCSgTJtTfvpZ7SPEg_LNO0ESlovQC0'
153+ } ] ;
154+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
155+ 'Failed to reject a VC with a relatedResource with wrong digest.' ) ;
156+
157+ // Wrong digestSRI negative test
158+ negativeFixture . relatedResource = [ {
159+ id : relatedResource . id ,
160+ digestSRI : 'sha256-' +
161+ '3384605907374540ed8c909281326d4dfbe967b48f120fcb34ed044a5a2f402d'
162+ } ] ;
163+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
164+ 'Failed to reject a VC with a relatedResource with wrong digest.' ) ;
133165 } ) ;
134166
135167 // 5.4 Refreshing https://w3c.github.io/vc-data-model/#integrity-of-related-resources
0 commit comments