Skip to content

Commit 2c61b4a

Browse files
PatStLouisBigBlueHat
authored andcommitted
improve related resources
Signed-off-by: PatStLouis <[email protected]>
1 parent cf38ee1 commit 2c61b4a

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

tests/5-advanced-concepts.js

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import {addPerTestMetadata, setupMatrix} from './helpers.js';
8+
import {credential, relatedResource} from './fixtures.js';
89
import assert from 'node:assert/strict';
910
import chai from 'chai';
1011
import {createRequire} from 'module';
@@ -22,6 +23,8 @@ const {match} = filterByTag({tags: [tag]});
2223
// 5. Advanced Concepts https://w3c.github.io/vc-data-model/#advanced-concepts
2324
describe('Advanced Concepts', function() {
2425
setupMatrix.call(this, match);
26+
let positiveFixture;
27+
let negativeFixture;
2528
for(const [name, implementation] of match) {
2629
const endpoints = new TestEndpoints({implementation, tag});
2730

@@ -55,20 +58,40 @@ describe('Advanced Concepts', function() {
5558
it('The value of the relatedResource property MUST be one or more ' +
5659
'objects of the following form:', async function() {
5760
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.');
7295
});
7396
it('The identifier for the resource is REQUIRED and conforms to the ' +
7497
'format defined in Section 4.4 Identifiers.', async function() {

tests/fixtures.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ export const envelopedPresentation = {
2222
type: 'EnvelopedVerifiablePresentation',
2323
id: `data:application/vp+jwt,${vp_jwt}`
2424
};
25+
26+
export const relatedResource = {
27+
id: 'https://www.w3.org/ns/credentials/v2',
28+
mediaType: 'application/ld+json',
29+
digestSRI: 'sha256-24a18c90e9856d526111f29376e302d970b2bd10182e33959995b0207d7043b9',
30+
digestMultibase: 'uMjRhMThjOTBlOTg1NmQ1MjYxMTFmMjkzNzZlMzAyZDk3MGIyYmQxMDE4MmUzMzk1OTk5NWIwMjA3ZDcwNDNiOQ',
31+
};

0 commit comments

Comments
 (0)