Skip to content

Commit 8519753

Browse files
committed
Move shouldBeProofValue to assertions.
1 parent d017e83 commit 8519753

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

assertions.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import chai from 'chai';
55
import jsonld from 'jsonld';
66

77
const should = chai.should();
8+
const {expect} = chai;
89
// RegExp with bs58 characters in it
910
const bs58 =
1011
/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
@@ -298,3 +299,35 @@ export function shouldHaveProofValue({proof, expectedPrefix, encodingName}) {
298299
true,
299300
`Expected "proof.proofValue" to be a valid ${encodingName} value`);
300301
}
302+
303+
export async function shouldBeProofValue({credentials, verifier}) {
304+
expect(credentials, 'Expected test data to be generated.').to.exist;
305+
expect(credentials.clone('issuedVc'), 'Expected a valid Vc to be issued.').
306+
to.exist;
307+
// proofValue is added after signing so we can
308+
// safely delete it for this test
309+
const noProofValue = credentials.clone('issuedVc');
310+
delete noProofValue.proof.proofValue;
311+
await verificationFail({
312+
credential: noProofValue,
313+
verifier,
314+
reason: 'MUST not verify VC with no "proofValue".'
315+
});
316+
// null should be an invalid proofValue for almost any proof
317+
const nullProofValue = credentials.clone('issuedVc');
318+
nullProofValue.proof.proofValue = null;
319+
await verificationFail({
320+
credential: nullProofValue,
321+
verifier,
322+
reason: 'MUST not verify VC with "proofValue" null.'
323+
});
324+
const noProofValueHeader = credentials.clone('issuedVc');
325+
// Remove the multibase header to cause validation error
326+
noProofValueHeader.proof.proofValue = noProofValueHeader.proof.proofValue.
327+
slice(1);
328+
await verificationFail({
329+
credential: noProofValueHeader,
330+
verifier,
331+
reason: 'MUST not verify VC with invalid multibase header on "proofValue"'
332+
});
333+
}

suites/verify.js

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/*!
22
* Copyright (c) 2024 Digital Bazaar, Inc.
33
*/
4-
import {verificationFail, verificationSuccess} from '../assertions.js';
5-
import {expect} from 'chai';
4+
import {
5+
shouldBeProofValue,
6+
verificationFail,
7+
verificationSuccess
8+
} from '../assertions.js';
69

710
export function runDataIntegrityProofVerifyTests({
811
endpoints,
@@ -311,35 +314,3 @@ export function runDataIntegrityProofVerifyTests({
311314
}
312315
});
313316
}
314-
315-
async function shouldBeProofValue({credentials, verifier}) {
316-
expect(credentials, 'Expected test data to be generated.').to.exist;
317-
expect(credentials.clone('issuedVc'), 'Expected a valid Vc to be issued.').
318-
to.exist;
319-
// proofValue is added after signing so we can
320-
// safely delete it for this test
321-
const noProofValue = credentials.clone('issuedVc');
322-
delete noProofValue.proof.proofValue;
323-
await verificationFail({
324-
credential: noProofValue,
325-
verifier,
326-
reason: 'MUST not verify VC with no "proofValue".'
327-
});
328-
// null should be an invalid proofValue for almost any proof
329-
const nullProofValue = credentials.clone('issuedVc');
330-
nullProofValue.proof.proofValue = null;
331-
await verificationFail({
332-
credential: nullProofValue,
333-
verifier,
334-
reason: 'MUST not verify VC with "proofValue" null.'
335-
});
336-
const noProofValueHeader = credentials.clone('issuedVc');
337-
// Remove the multibase header to cause validation error
338-
noProofValueHeader.proof.proofValue = noProofValueHeader.proof.proofValue.
339-
slice(1);
340-
await verificationFail({
341-
credential: noProofValueHeader,
342-
verifier,
343-
reason: 'MUST not verify VC with invalid multibase header on "proofValue"'
344-
});
345-
}

0 commit comments

Comments
 (0)