@@ -18,26 +18,37 @@ const should = chai.should();
1818
1919const require = createRequire ( import . meta. url ) ;
2020
21- const tag = 'EnvelopingProof' ;
21+ const tag = 'vc2.0' ;
22+ // const tag = 'EnvelopingProof';
2223const { match} = filterByTag ( { tags : [ tag ] } ) ;
2324
2425// 4.12.1 Enveloped Verifiable Credentials https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials
2526describe ( 'VP - Enveloped Verifiable Credentials' , function ( ) {
2627 setupMatrix . call ( this , match ) ;
2728 for ( const [ name , implementation ] of match ) {
2829 const endpoints = new TestEndpoints ( { implementation, tag} ) ;
30+ const issuer_envelope_support =
31+ endpoints . issuer . settings . tags . includes (
32+ 'EnvelopingProof' ) ;
33+ const vpVerifier_envelope_support =
34+ endpoints . vpVerifier . settings . tags . includes (
35+ 'EnvelopingProof' ) ;
2936
3037 describe ( name , function ( ) {
3138 let issuedVc ;
3239 before ( async function ( ) {
33- try {
34- issuedVc = await endpoints . issue ( require (
35- './input/credential-ok.json' ) ) ;
36- } catch ( e ) {
37- console . error (
38- `Issuer: ${ name } failed to issue "credential-ok.json".` ,
39- e
40- ) ;
40+ if ( issuer_envelope_support ) {
41+ try {
42+ issuedVc = await endpoints . issue ( require (
43+ './input/credential-ok.json' ) ) ;
44+ } catch ( e ) {
45+ console . error (
46+ `Issuer: ${ name } failed to issue "credential-ok.json".` ,
47+ e
48+ ) ;
49+ }
50+ } else {
51+ issuedVc = null ;
4152 }
4253 } ) ;
4354 beforeEach ( addPerTestMetadata ) ;
@@ -48,34 +59,49 @@ describe('VP - Enveloped Verifiable Credentials', function() {
4859 'terms as defined by the base context provided by this specification.' ,
4960 async function ( ) {
5061 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.` ;
51- await assert . doesNotReject ( endpoints . verifyVp ( require (
52- './input/presentation-enveloped-vc-ok.json' ) ) ,
53- 'Failed to accept a VP containing a enveloped VC.' ) ;
54- // TODO: add more `@context` variations to test handling?
55- await assert . rejects ( endpoints . verifyVp ( require (
56- './input/presentation-enveloped-vc-missing-required-type-fail.json' ) ) ,
57- 'Failed to reject a VP containing an enveloped VC with a missing ' +
58- '`type`.' ) ;
62+ if ( ! vpVerifier_envelope_support ) {
63+ this . test . cell . skipMessage = 'No envelope support.' ;
64+ this . skip ( ) ;
65+ } else {
66+ await assert . doesNotReject ( endpoints . verifyVp ( require (
67+ './input/presentation-enveloped-vc-ok.json' ) ) ,
68+ 'Failed to accept a VP containing a enveloped VC.' ) ;
69+ // TODO: add more `@context` variations to test handling?
70+ await assert . rejects ( endpoints . verifyVp ( require (
71+ './input/presentation-enveloped-vc-missing-type-fail.json' ) ) ,
72+ 'Failed to reject a VP containing an enveloped VC with a missing ' +
73+ '`type`.' ) ;
74+ }
5975 } ) ;
6076
6177 it ( 'The id value of the object MUST be a data: URL [RFC2397] that ' +
6278 'expresses a secured verifiable credential using an enveloping ' +
6379 'security scheme, such as Securing Verifiable Credentials using JOSE ' +
6480 'and COSE [VC-JOSE-COSE].' , async function ( ) {
6581 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.` ;
66- issuedVc . should . have . property ( 'id' ) . that . does
67- . include ( 'data:' ,
68- `Expecting id field to be a 'data:' scheme URL [RFC2397].` ) ;
69- const extractedCredential = extractIfEnveloped ( issuedVc ) ;
70- shouldBeCredential ( extractedCredential ) ;
82+ if ( ! issuer_envelope_support ) {
83+ this . test . cell . skipMessage = 'No envelope support.' ;
84+ this . skip ( ) ;
85+ } else {
86+ issuedVc . should . have . property ( 'id' ) . that . does
87+ . include ( 'data:' ,
88+ `Expecting id field to be a 'data:' scheme URL [RFC2397].` ) ;
89+ const extractedCredential = extractIfEnveloped ( issuedVc ) ;
90+ shouldBeCredential ( extractedCredential ) ;
91+ }
7192 } ) ;
7293
7394 it ( 'The type value of the object MUST be EnvelopedVerifiableCredential.' ,
7495 async function ( ) {
7596 this . test . link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-credentials:~:text=The%20type%20value%20of%20the%20object%20MUST%20be%20EnvelopedVerifiableCredential.` ;
76- issuedVc . should . have . property ( 'type' ) . that . does
77- . include ( 'EnvelopedVerifiableCredential' ,
78- `Expecting type field to be EnvelopedVerifiableCredential` ) ;
97+ if ( ! issuer_envelope_support ) {
98+ this . test . cell . skipMessage = 'No envelope support.' ;
99+ this . skip ( ) ;
100+ } else {
101+ issuedVc . should . have . property ( 'type' ) . that . does
102+ . include ( 'EnvelopedVerifiableCredential' ,
103+ `Expecting type field to be EnvelopedVerifiableCredential` ) ;
104+ }
79105 } ) ;
80106 } ) ;
81107 }
@@ -86,6 +112,9 @@ describe('VP - Enveloped Verifiable Presentations', function() {
86112 setupMatrix . call ( this , match ) ;
87113 for ( const [ name , implementation ] of match ) {
88114 const endpoints = new TestEndpoints ( { implementation, tag} ) ;
115+ const vpVerifier_envelope_support =
116+ endpoints . vpVerifier . settings . tags . includes (
117+ 'EnvelopingProof' ) ;
89118
90119 describe ( name , function ( ) {
91120 beforeEach ( addPerTestMetadata ) ;
@@ -96,33 +125,48 @@ describe('VP - Enveloped Verifiable Presentations', function() {
96125 'terms as defined by the base context provided by this specification.' ,
97126 async function ( ) {
98127 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.` ;
99- await assert . rejects (
100- endpoints . verifyVp ( require (
101- './input/enveloped-presentation-context-fail.json' ) ) ,
102- { name : 'HTTPError' } ,
103- 'Failed to reject Enveloped VP missing contexts.' ) ;
128+ if ( ! vpVerifier_envelope_support ) {
129+ this . test . cell . skipMessage = 'No envelope support.' ;
130+ this . skip ( ) ;
131+ } else {
132+ await assert . rejects (
133+ endpoints . verifyVp ( require (
134+ './input/enveloped-presentation-context-fail.json' ) ) ,
135+ { name : 'HTTPError' } ,
136+ 'Failed to reject Enveloped VP missing contexts.' ) ;
137+ }
104138 } ) ;
105139
106140 it ( 'The id value of the object MUST be a data: URL [RFC2397] that ' +
107141 'expresses a secured verifiable presentation using an enveloping ' +
108142 'securing mechanism, such as Securing Verifiable Credentials using ' +
109143 'JOSE and COSE [VC-JOSE-COSE].' , async function ( ) {
110144 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.` ;
111- await assert . rejects (
112- endpoints . verifyVp ( require (
113- './input/enveloped-presentation-id-fail.json' ) ) ,
114- { name : 'HTTPError' } ,
115- 'Failed to reject Enveloped VP with an id that is not a data url.' ) ;
145+ if ( ! vpVerifier_envelope_support ) {
146+ this . test . cell . skipMessage = 'No envelope support.' ;
147+ this . skip ( ) ;
148+ } else {
149+ await assert . rejects (
150+ endpoints . verifyVp ( require (
151+ './input/enveloped-presentation-id-fail.json' ) ) ,
152+ { name : 'HTTPError' } ,
153+ 'Failed to reject Enveloped VP with an id that is not a data url.' ) ;
154+ }
116155 } ) ;
117156
118157 it ( 'The type value of the object MUST be ' +
119158 'EnvelopedVerifiablePresentation.' , async function ( ) {
120159 this . test . link = `https://w3c.github.io/vc-data-model/#enveloped-verifiable-presentations:~:text=The%20type%20value%20of%20the%20object%20MUST%20be%20EnvelopedVerifiablePresentation.` ;
121- await assert . rejects (
122- endpoints . verifyVp ( require (
123- './input/enveloped-presentation-type-fail.json' ) ) ,
124- { name : 'HTTPError' } ,
125- 'Failed to reject VP w/o type "EnvelopedVerifiablePresentation".' ) ;
160+ if ( ! vpVerifier_envelope_support ) {
161+ this . test . cell . skipMessage = 'No envelope support.' ;
162+ this . skip ( ) ;
163+ } else {
164+ await assert . rejects (
165+ endpoints . verifyVp ( require (
166+ './input/enveloped-presentation-type-fail.json' ) ) ,
167+ { name : 'HTTPError' } ,
168+ 'Failed to reject VP w/o type "EnvelopedVerifiablePresentation".' ) ;
169+ }
126170 } ) ;
127171 } ) ;
128172 }
0 commit comments