diff --git a/tests/413.2-envelopes.js b/tests/413.2-envelopes.js index 22709616..72610f31 100644 --- a/tests/413.2-envelopes.js +++ b/tests/413.2-envelopes.js @@ -18,7 +18,7 @@ const should = chai.should(); const require = createRequire(import.meta.url); -const tag = 'EnvelopingProof'; +const tag = 'vc2.0'; const {match} = filterByTag({tags: [tag]}); // 4.12.1 Enveloped Verifiable Credentials https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials @@ -26,18 +26,28 @@ describe('VP - Enveloped Verifiable Credentials', function() { setupMatrix.call(this, match); for(const [name, implementation] of match) { const endpoints = new TestEndpoints({implementation, tag}); + const issuerEnvelopeSupport = + endpoints.issuer.settings.tags.includes( + 'EnvelopingProof'); + const vpVerifierEnvelopeSupport = + endpoints.vpVerifier.settings.tags.includes( + 'EnvelopingProof'); describe(name, function() { let issuedVc; before(async function() { - try { - issuedVc = await endpoints.issue(require( - './input/credential-ok.json')); - } catch(e) { - console.error( - `Issuer: ${name} failed to issue "credential-ok.json".`, - e - ); + if(issuerEnvelopeSupport) { + try { + issuedVc = await endpoints.issue(require( + './input/credential-ok.json')); + } catch(e) { + console.error( + `Issuer: ${name} failed to issue "credential-ok.json".`, + e + ); + } + } else { + issuedVc = null; } }); beforeEach(addPerTestMetadata); @@ -48,14 +58,19 @@ describe('VP - Enveloped Verifiable Credentials', function() { 'terms as defined by the base context provided by this specification.', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials:~:text=The%20%40context%20property%20of%20the%20object%20MUST%20be%20present%20and%20include%20a%20context%2C%20such%20as%20the%20base%20context%20for%20this%20specification%2C%20that%20defines%20at%20least%20the%20id%2C%20type%2C%20and%20EnvelopedVerifiableCredential%20terms%20as%20defined%20by%20the%20base%20context%20provided%20by%20this%20specification.`; - await assert.doesNotReject(endpoints.verifyVp(require( - './input/presentation-enveloped-vc-ok.json')), - 'Failed to accept a VP containing a enveloped VC.'); - // TODO: add more `@context` variations to test handling? - await assert.rejects(endpoints.verifyVp(require( - './input/presentation-enveloped-vc-missing-required-type-fail.json')), - 'Failed to reject a VP containing an enveloped VC with a missing ' + - '`type`.'); + if(!vpVerifierEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + await assert.doesNotReject(endpoints.verifyVp(require( + './input/presentation-enveloped-vc-ok.json')), + 'Failed to accept a VP containing a enveloped VC.'); + // TODO: add more `@context` variations to test handling? + await assert.rejects(endpoints.verifyVp(require( + './input/presentation-enveloped-vc-missing-type-fail.json')), + 'Failed to reject a VP containing an enveloped VC with a missing ' + + '`type`.'); + } }); it('The id value of the object MUST be a data: URL [RFC2397] that ' + @@ -63,19 +78,29 @@ describe('VP - Enveloped Verifiable Credentials', function() { 'security scheme, such as Securing Verifiable Credentials using JOSE ' + 'and COSE [VC-JOSE-COSE].', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials:~:text=The%20id%20value%20of%20the%20object%20MUST%20be%20a%20data%3A%20URL%20%5BRFC2397%5D%20that%20expresses%20a%20secured%20verifiable%20credential%20using%20an%20enveloping%20security%20scheme%2C%20such%20as%20Securing%20Verifiable%20Credentials%20using%20JOSE%20and%20COSE%20%5BVC%2DJOSE%2DCOSE%5D.`; - issuedVc.should.have.property('id').that.does - .include('data:', - `Expecting id field to be a 'data:' scheme URL [RFC2397].`); - const extractedCredential = extractIfEnveloped(issuedVc); - shouldBeCredential(extractedCredential); + if(!issuerEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + issuedVc.should.have.property('id').that.does + .include('data:', + `Expecting id field to be a 'data:' scheme URL [RFC2397].`); + const extractedCredential = extractIfEnveloped(issuedVc); + shouldBeCredential(extractedCredential); + } }); it('The type value of the object MUST be EnvelopedVerifiableCredential.', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials:~:text=The%20type%20value%20of%20the%20object%20MUST%20be%20EnvelopedVerifiableCredential.`; - issuedVc.should.have.property('type').that.does - .include('EnvelopedVerifiableCredential', - `Expecting type field to be EnvelopedVerifiableCredential`); + if(!issuerEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + issuedVc.should.have.property('type').that.does + .include('EnvelopedVerifiableCredential', + `Expecting type field to be EnvelopedVerifiableCredential`); + } }); }); } @@ -86,6 +111,9 @@ describe('VP - Enveloped Verifiable Presentations', function() { setupMatrix.call(this, match); for(const [name, implementation] of match) { const endpoints = new TestEndpoints({implementation, tag}); + const vpVerifierEnvelopeSupport = + endpoints.vpVerifier.settings.tags.includes( + 'EnvelopingProof'); describe(name, function() { beforeEach(addPerTestMetadata); @@ -96,11 +124,16 @@ describe('VP - Enveloped Verifiable Presentations', function() { 'terms as defined by the base context provided by this specification.', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-presentations:~:text=The%20%40context%20property%20of%20the%20object%20MUST%20be%20present%20and%20include%20a%20context%2C%20such%20as%20the%20base%20context%20for%20this%20specification%2C%20that%20defines%20at%20least%20the%20id%2C%20type%2C%20and%20EnvelopedVerifiablePresentation%20terms%20as%20defined%20by%20the%20base%20context%20provided%20by%20this%20specification.`; - await assert.rejects( - endpoints.verifyVp(require( - './input/enveloped-presentation-context-fail.json')), - {name: 'HTTPError'}, - 'Failed to reject Enveloped VP missing contexts.'); + if(!vpVerifierEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + await assert.rejects( + endpoints.verifyVp(require( + './input/enveloped-presentation-context-fail.json')), + {name: 'HTTPError'}, + 'Failed to reject Enveloped VP missing contexts.'); + } }); it('The id value of the object MUST be a data: URL [RFC2397] that ' + @@ -108,21 +141,31 @@ describe('VP - Enveloped Verifiable Presentations', function() { 'securing mechanism, such as Securing Verifiable Credentials using ' + 'JOSE and COSE [VC-JOSE-COSE].', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-presentations:~:text=The%20id%20value%20of%20the%20object%20MUST%20be%20a%20data%3A%20URL%20%5BRFC2397%5D%20that%20expresses%20a%20secured%20verifiable%20presentation%20using%20an%20enveloping%20securing%20mechanism%2C%20such%20as%20Securing%20Verifiable%20Credentials%20using%20JOSE%20and%20COSE%20%5BVC%2DJOSE%2DCOSE%5D.`; - await assert.rejects( - endpoints.verifyVp(require( - './input/enveloped-presentation-id-fail.json')), - {name: 'HTTPError'}, - 'Failed to reject Enveloped VP with an id that is not a data url.'); + if(!vpVerifierEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + await assert.rejects( + endpoints.verifyVp(require( + './input/enveloped-presentation-id-fail.json')), + {name: 'HTTPError'}, + 'Failed to reject Enveloped VP with an id that is not a data url.'); + } }); it('The type value of the object MUST be ' + 'EnvelopedVerifiablePresentation.', async function() { this.test.link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-presentations:~:text=The%20type%20value%20of%20the%20object%20MUST%20be%20EnvelopedVerifiablePresentation.`; - await assert.rejects( - endpoints.verifyVp(require( - './input/enveloped-presentation-type-fail.json')), - {name: 'HTTPError'}, - 'Failed to reject VP w/o type "EnvelopedVerifiablePresentation".'); + if(!vpVerifierEnvelopeSupport) { + this.test.cell.skipMessage = 'No envelope support.'; + this.skip(); + } else { + await assert.rejects( + endpoints.verifyVp(require( + './input/enveloped-presentation-type-fail.json')), + {name: 'HTTPError'}, + 'Failed to reject VP w/o type "EnvelopedVerifiablePresentation".'); + } }); }); } diff --git a/tests/input/presentation-enveloped-vc-missing-required-type-fail.json b/tests/input/presentation-enveloped-vc-missing-type-fail.json similarity index 100% rename from tests/input/presentation-enveloped-vc-missing-required-type-fail.json rename to tests/input/presentation-enveloped-vc-missing-type-fail.json