Skip to content

Commit ee963ab

Browse files
committed
Layout first set of tests.
1 parent 5041553 commit ee963ab

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

tests/suites/algorithms-sd.js

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,23 @@ export function sd2023Algorithms({
4848
'selection, this includes any root document identifier.',
4949
async function() {
5050
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#jsonpointertopaths:~:text=If%20source%20has%20an%20id%20that%20is%20not%20a%20blank%20node%20identifier%2C%20set%20selection.id%20to%20its%20value.%20Note%3A%20All%20non%2Dblank%20node%20identifiers%20in%20the%20path%20of%20any%20JSON%20Pointer%20MUST%20be%20included%20in%20the%20selection%2C%20this%20includes%20any%20root%20document%20identifier.';
51+
this.cell.skipMessage = 'Not Implemented';
52+
this.skip();
5153
});
5254
it('If source.type is set, set selection.type to its value. ' +
5355
'Note: The selection MUST include all types in the path of any ' +
5456
'JSON Pointer, including any root document type.', async function() {
5557
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=If%20source.type%20is%20set%2C%20set%20selection.type%20to%20its%20value.%20Note%3A%20The%20selection%20MUST%20include%20all%20types%20in%20the%20path%20of%20any%20JSON%20Pointer%2C%20including%20any%20root%20document%20type.';
58+
this.cell.skipMessage = 'Not Implemented';
59+
this.skip();
5660
});
5761
it('Set value to parentValue.path. If value is now undefined, an ' +
5862
'error MUST be raised and SHOULD convey an error type of ' +
5963
'PROOF_GENERATION_ERROR, indicating that the JSON pointer does ' +
6064
'not match the given document.', async function() {
6165
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=Set%20value%20to%20parentValue.path.%20If%20value%20is%20now%20undefined%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR%2C%20indicating%20that%20the%20JSON%20pointer%20does%20not%20match%20the%20given%20document.';
6266
await assertions.shouldFailIssuance({
63-
credential: structuredClone(credential),
67+
credential: credentials.get('unsecured'),
6468
issuer,
6569
reason: 'Should not issue VC with json pointer that does not ' +
6670
'match credential.',
@@ -73,40 +77,49 @@ export function sd2023Algorithms({
7377
'NOT be used on any of the components. Append the produced encoded ' +
7478
'value to proofValue.', async function() {
7579
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=and%20mandatoryPointers.-,CBOR%2Dencode%20components%20per%20%5BRFC8949%5D%20where%20CBOR%20tagging%20MUST,-NOT%20be%20used';
80+
this.cell.skipMessage = 'Not Implemented';
81+
this.skip();
7682
});
7783
it('If the proofValue string does not start with u, indicating ' +
7884
'that it is a multibase-base64url-no-pad-encoded value, an error ' +
7985
'MUST be raised and SHOULD convey an error type of ' +
8086
'PROOF_VERIFICATION_ERROR.', async function() {
8187
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=produced%20as%20output.-,If%20the%20proofValue%20string%20does%20not%20start%20with%20u%2C%20indicating%20that%20it%20is%20a%20multibase%2Dbase64url%2Dno%2Dpad%2Dencoded%20value%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR.,-Initialize%20decodedProofValue%20to';
88+
await assertions.verificationFail({
89+
verifier,
90+
credential: credentials.get('invalidProofValuePrefix'),
91+
reason: 'Should not verify VC with invalid proofValue prefix'
92+
});
8293
});
8394
it('If the decodedProofValue does not start with the ECDSA-SD ' +
8495
'base proof header bytes 0xd9, 0x5d, and 0x00, an error MUST be ' +
8596
'raised and SHOULD convey an error type of PROOF_VERIFICATION_ERROR.',
8697
async function() {
8798
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=If%20the%20decodedProofValue%20does%20not%20start%20with%20the%20ECDSA%2DSD%20base%20proof%20header%20bytes%200xd9%2C%200x5d%2C%20and%200x00%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR.';
99+
await assertions.verificationFail({
100+
verifier,
101+
credential: credentials.get('invalidBaseProofHeader'),
102+
reason: 'Should not verify VC with invalid base proof header'
103+
});
88104
});
89105
it('CBOR-encode components per [RFC8949] where CBOR tagging MUST ' +
90106
'NOT be used on any of the components. Append the produced ' +
91107
'encoded value to proofValue.', async function() {
92108
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=and%20mandatoryIndexes.-,CBOR%2Dencode%20components%20per%20%5BRFC8949%5D%20where%20CBOR%20tagging%20MUST%20NOT%20be%20used%20on%20any%20of%20the%20components.%20Append%20the%20produced%20encoded%20value%20to%20proofValue.,-Return%20the%20derived';
93-
});
94-
it('If the proofValue string does not start with u, indicating ' +
95-
'that it is a multibase-base64url-no-pad-encoded value, an error ' +
96-
'MUST be raised and SHOULD convey an error type of ' +
97-
'PROOF_VERIFICATION_ERROR.', async function() {
98-
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=labelMap%22%2C%20and%20%22mandatoryIndexes%22.-,If%20the%20proofValue%20string%20does%20not%20start%20with%20u%2C%20indicating%20that%20it%20is%20a%20multibase%2Dbase64url%2Dno%2Dpad%2Dencoded%20value%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR.,-Initialize%20decodedProofValue%20to';
99-
await assertions.verificationFail({
100-
credential,
101-
verifier,
102-
reason: 'Should not verify proofValue not starting with u'
103-
});
109+
this.cell.skipMessage = 'Not Implemented';
110+
this.skip();
104111
});
105112
it('If the decodedProofValue does not start with the ECDSA-SD ' +
106113
'disclosure proof header bytes 0xd9, 0x5d, and 0x01, an error ' +
107114
'MUST be raised and SHOULD convey an error type of ' +
108115
'PROOF_VERIFICATION_ERROR.', async function() {
109116
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=If%20the%20decodedProofValue%20does%20not%20start%20with%20the%20ECDSA%2DSD%20disclosure%20proof%20header%20bytes%200xd9%2C%200x5d%2C%20and%200x01%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR.';
117+
await assertions.verificationFail({
118+
verifier,
119+
credential: credentials.get('invalidDisclosureProofHeader'),
120+
reason: 'Should not verify VC with invalid disclosure proof ' +
121+
'header'
122+
});
110123
});
111124
it('If the result is not an array of the following five elements ' +
112125
'— a byte array of length 64; a byte array of length 36; an array ' +
@@ -115,54 +128,89 @@ export function sd2023Algorithms({
115128
'MUST be raised and SHOULD convey an error type of ' +
116129
'PROOF_VERIFICATION_ERROR.', async function() {
117130
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=array%20of%20integers%20%E2%80%94-,an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR.,-Replace%20the%20fourth';
131+
this.cell.skipMessage = 'Not Implemented';
132+
this.skip();
118133
});
119134
it('The transformation options MUST contain a type identifier for ' +
120135
'the cryptographic suite (type), a cryptosuite identifier ' +
121136
'(cryptosuite), and a verification method (verificationMethod).',
122137
async function() {
123138
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=The%20transformation%20options%20MUST%20contain%20a%20type%20identifier%20for%20the%20cryptographic%20suite%20(type)%2C%20a%20cryptosuite%20identifier%20(cryptosuite)%2C%20and%20a%20verification%20method%20(verificationMethod).';
139+
this.cell.skipMessage = 'Not Implemented';
140+
this.skip();
124141
});
125142
it('The transformation options MUST contain an array of mandatory ' +
126143
'JSON pointers (mandatoryPointers) and MAY contain additional ' +
127144
'options, such as a JSON-LD document loader.', async function() {
128145
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=The%20transformation%20options%20MUST%20contain%20an%20array%20of%20mandatory%20JSON%20pointers%20(mandatoryPointers)%20and%20MAY%20contain%20additional%20options%2C%20such%20as%20a%20JSON%2DLD%20document%20loader.';
146+
await assertions.verificationFail({
147+
credential: credentials.get('noMandatoryPointers'),
148+
verifier,
149+
reason: 'Should not verify VC with no mandatoryPointers'
150+
});
129151
});
130152
it('Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
131153
'encoding.', async function() {
132154
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=produced%20as%20output.-,Whenever%20this%20algorithm%20encodes%20strings%2C%20it%20MUST%20use%20UTF%2D8%20encoding.,-Initialize%20hmac%20to';
155+
this.cell.skipMessage = 'Not Implemented';
156+
this.skip();
133157
});
134158
it('Per the recommendations of [RFC2104], the HMAC key MUST be the ' +
135159
'same length as the digest size; for SHA-256, this is 256 bits or ' +
136160
'32 bytes.', async function() {
137161
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#selective-disclosure-functions:~:text=Per%20the%20recommendations%20of%20%5BRFC2104%5D%2C%20the%20HMAC%20key%20MUST%20be%20the%20same%20length%20as%20the%20digest%20size%3B%20for%20SHA%2D256%2C%20this%20is%20256%20bits%20or%2032%20bytes.';
162+
this.cell.skipMessage = 'Not Implemented';
163+
this.skip();
138164
});
139165
it('The proof options MUST contain a type identifier for the ' +
140166
'cryptographic suite (type) and MUST contain a cryptosuite ' +
141167
'identifier (cryptosuite).', async function() {
142168
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#base-proof-configuration-ecdsa-sd-2023';
169+
await assertions.verificationFail({
170+
verifier,
171+
credential: credentials.get('noTypeCryptosuite'),
172+
reason: 'Should not verify VC with no type or cryptosuite'
173+
});
143174
});
144175
it('If proofConfig.type is not set to DataIntegrityProof and/or ' +
145176
'proofConfig.cryptosuite is not set to ecdsa-sd-2023, an error ' +
146177
'MUST be raised and SHOULD convey an error type of ' +
147178
'PROOF_GENERATION_ERROR.', async function() {
148179
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#base-proof-configuration-ecdsa-sd-2023:~:text=If%20proofConfig.type%20is%20not%20set%20to%20DataIntegrityProof%20and/or%20proofConfig.cryptosuite%20is%20not%20set%20to%20ecdsa%2Dsd%2D2023%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.';
180+
await assertions.verificationFail({
181+
verifier,
182+
credential: credentials.get('noTypeCryptosuite'),
183+
reason: 'Should not verify VC with no type or cryptosuite'
184+
});
149185
});
150186
it('If proofConfig.created is set and if the value is not a valid ' +
151187
'[XMLSCHEMA11-2] datetime, an error MUST be raised and SHOULD ' +
152188
'convey an error type of PROOF_GENERATION_ERROR.', async function() {
153189
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#base-proof-configuration-ecdsa-sd-2023';
190+
await assertions.verificationFail({
191+
credential: credentials.get('invalidCreated'),
192+
verifier,
193+
reason: 'Should not verify VC with invalid created'
194+
});
154195
});
155196
it('The proof options MUST contain a type identifier for the ' +
156197
'cryptographic suite (type) and MAY contain a cryptosuite ' +
157198
'identifier (cryptosuite).', async function() {
158199
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#base-proof-serialization-ecdsa-sd-2023';
200+
await assertions.verificationFail({
201+
verifier,
202+
credential: credentials.get('noTypeCryptosuite'),
203+
reason: 'Should not verify VC with no type or cryptosuite'
204+
});
159205
});
160206
it('If the length of signatures does not match the length of ' +
161207
'nonMandatory, an error MUST be raised and SHOULD convey an ' +
162208
'error type of PROOF_VERIFICATION_ERROR, indicating that the ' +
163209
'signature count does not match the non-mandatory message count.',
164210
async function() {
165211
this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#base-proof-serialization-ecdsa-sd-2023:~:text=If%20the%20length%20of%20signatures%20does%20not%20match%20the%20length%20of%20nonMandatory%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_VERIFICATION_ERROR%2C%20indicating%20that%20the%20signature%20count%20does%20not%20match%20the%20non%2Dmandatory%20message%20count.';
212+
this.cell.skipMessage = 'Not Implemented';
213+
this.skip();
166214
});
167215
});
168216
}

0 commit comments

Comments
 (0)