From 918d784c69484eb2e6b759bdd08c7a2e6c197e46 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 7 Jun 2024 15:57:17 +0000 Subject: [PATCH] Add filterVerifiers for DI verifier tests. --- tests/15-di-bbs-verify.js | 9 ++++----- tests/helpers.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/15-di-bbs-verify.js b/tests/15-di-bbs-verify.js index d9620e2..77f2680 100644 --- a/tests/15-di-bbs-verify.js +++ b/tests/15-di-bbs-verify.js @@ -8,20 +8,19 @@ import { checkDataIntegrityProofVerifyErrors } from 'data-integrity-test-suite-assertion'; import {endpoints} from 'vc-test-suite-implementations'; +import {filterVerifiers} from './helpers.js'; import {getMultiKey} from './vc-generator/key-gen.js'; import {getSuiteConfig} from './test-config.js'; const tag = 'bbs-2023'; const {tags, credentials, vectors} = getSuiteConfig(tag); -// only use implementations with `bbs-2023` verifiers. -const {match} = endpoints.filterByTag({ - tags: [...tags], - property: 'verifiers' -}); const key = await getMultiKey({keyType: 'P-381'}); const {subjectNestedObjects} = credentials.verify; for(const vcVersion of vectors.vcTypes) { + const {match} = endpoints.filter({ + filter: filterVerifiers.bind({vcVersion, tags}) + }); checkDataIntegrityProofVerifyErrors({ implemented: match, testDescription: `Data Integrity (bbs-2023 verifiers) VC ${vcVersion}`, diff --git a/tests/helpers.js b/tests/helpers.js index 13fe0a3..c460f00 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -29,6 +29,25 @@ export const supportsVc = ({vcVersion, endpoint}) => { return supports.vc.includes(vcVersion); }; +/** + * Filters Verifiers for the Data Integrity Verifier tests. + * Needs to have tags and vcVersion binded to it. + * + * @param {object} options - Options to use. + * @param {object} options.implementation - An impelementation. + * + * @returns {Array} Filtered endpoints. + */ +export function filterVerifiers({implementation}) { + const endpoints = implementation.verifiers; + return endpoints.filter(endpoint => { + if(this.tags.every(tag => endpoint.tags.has(tag))) { + return supportsVc({vcVersion: this.vcVersion, endpoint}); + } + return false; + }); +} + export const createInitialVc = async ({ issuer, vc,