5
5
*/
6
6
7
7
import { addPerTestMetadata , setupMatrix } from './helpers.js' ;
8
+ import { credential , relatedResource } from './fixtures.js' ;
8
9
import assert from 'node:assert/strict' ;
9
10
import chai from 'chai' ;
10
11
import { createRequire } from 'module' ;
@@ -22,6 +23,8 @@ const {match} = filterByTag({tags: [tag]});
22
23
// 5. Advanced Concepts https://w3c.github.io/vc-data-model/#advanced-concepts
23
24
describe ( 'Advanced Concepts' , function ( ) {
24
25
setupMatrix . call ( this , match ) ;
26
+ let positiveFixture ;
27
+ let negativeFixture ;
25
28
for ( const [ name , implementation ] of match ) {
26
29
const endpoints = new TestEndpoints ( { implementation, tag} ) ;
27
30
@@ -55,20 +58,40 @@ describe('Advanced Concepts', function() {
55
58
it ( 'The value of the relatedResource property MUST be one or more ' +
56
59
'objects of the following form:' , async function ( ) {
57
60
this . test . link = `https://w3c.github.io/vc-data-model/#integrity-of-related-resources:~:text=The%20value%20of%20the%20relatedResource%20property%20MUST%20be%20one%20or%20more%20objects%20of%20the%20following%20form%3A` ;
58
- await assert . doesNotReject ( endpoints . issue ( require (
59
- './input/relatedResource/relatedResource-digest-sri-ok.json'
60
- ) ) , 'Failed to accept a VC with valid relatedResource objects.' ) ;
61
- await assert . doesNotReject ( endpoints . issue ( require (
62
- './input/relatedResource/relatedResource-digest-multibase-ok.json'
63
- ) ) , 'Failed to accept a VC with valid relatedResource objects.' ) ;
64
- await assert . doesNotReject ( endpoints . issue ( require (
65
- './input/relatedResource/relatedResource-with-mediaType-ok.json'
66
- ) ) ,
67
- 'Failed to accept a VC with valid relatedResource.mediaType values.' ) ;
68
- await assert . rejects ( endpoints . issue ( require (
69
- './input/relatedResource/relatedResource-list-of-strings-fail.json'
70
- ) ) ,
71
- 'Failed to reject a VC with a relatedResource as an array of strings.' ) ;
61
+
62
+ positiveFixture = structuredClone ( credential ) ;
63
+
64
+ // digestSRI positive test
65
+ positiveFixture . relatedResource = {
66
+ id : relatedResource . id ,
67
+ digestSRI : relatedResource . digestSRI ,
68
+ } ;
69
+ await assert . doesNotReject ( endpoints . issue ( positiveFixture ) ,
70
+ 'Failed to accept a VC with valid relatedResource objects.' ) ;
71
+
72
+ // digestMultibase positive test
73
+ positiveFixture . relatedResource = {
74
+ id : relatedResource . id ,
75
+ digestMultibase : relatedResource . digestMultibase ,
76
+ } ;
77
+ await assert . doesNotReject ( endpoints . issue ( positiveFixture ) ,
78
+ 'Failed to accept a VC with valid relatedResource objects.' ) ;
79
+
80
+ // mediaType positive test
81
+ positiveFixture . relatedResource = [ {
82
+ id : relatedResource . id ,
83
+ mediaType : relatedResource . mediaType ,
84
+ digestSRI : relatedResource . digestSRI ,
85
+ } ] ;
86
+ await assert . doesNotReject ( endpoints . issue ( positiveFixture ) ,
87
+ 'Failed to accept a VC with valid relatedResource mediaType.' ) ;
88
+
89
+ negativeFixture = structuredClone ( credential ) ;
90
+ negativeFixture . relatedResource = [ {
91
+ id : relatedResource . id ,
92
+ } ] ;
93
+ await assert . rejects ( endpoints . issue ( negativeFixture ) ,
94
+ 'Failed to reject a VC with a relatedResource as an array of strings.' ) ;
72
95
} ) ;
73
96
it ( 'The identifier for the resource is REQUIRED and conforms to the ' +
74
97
'format defined in Section 4.4 Identifiers.' , async function ( ) {
0 commit comments