diff --git a/src/issuerRegistries.ts b/src/issuerRegistries.ts index 4ee1999..6704917 100644 --- a/src/issuerRegistries.ts +++ b/src/issuerRegistries.ts @@ -14,7 +14,7 @@ export async function getTrustedRegistryListForIssuer({ issuer, knownDIDRegistri reloadIssuerRegistry: boolean | null }): Promise { - if (reloadIssuerRegistry ?? registryNotYetLoaded) { + if (reloadIssuerRegistry || registryNotYetLoaded) { await registries.load({ config: knownDIDRegistries }) } const issuerDid = typeof issuer === 'string' ? issuer : issuer.id; diff --git a/test/Verify.spec.ts b/test/Verify.spec.ts index 637b260..8b8d7cc 100644 --- a/test/Verify.spec.ts +++ b/test/Verify.spec.ts @@ -2,7 +2,7 @@ import chai from 'chai' import deepEqualInAnyOrder from 'deep-equal-in-any-order' import { strict as assert } from 'assert'; import { verifyCredential } from '../src/Verify.js' -import { getVCv2Expired, getVCv1Tampered, getVCv1Expired, getVCv1Revoked, getVCv1ValidStatus, getVCv2ValidStatus, getVCv2Tampered } from '../src/test-fixtures/vc.js' +import { getVCv2Expired, getVCv1Tampered, getVCv1Expired, getVCv1Revoked, getVCv2Revoked, getVCv1ValidStatus, getVCv2ValidStatus, getVCv2Tampered } from '../src/test-fixtures/vc.js' import { knownDIDRegistries } from '../.knownDidRegistries.js'; import { getExpectedVerifiedResult, getExpectedUnverifiedResult } from '../src/test-fixtures/expectedResults.js'; @@ -18,7 +18,7 @@ describe('Verify', () => { describe('returns fatal error', () => { it('when tampered with', async () => { const tamperedVC1 : any = getVCv1Tampered() - const result = await verifyCredential({credential: tamperedVC1, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential: tamperedVC1, reloadIssuerRegistry: false, knownDIDRegistries}) assert.ok(result.verified === false); }) }) @@ -27,7 +27,7 @@ describe('Verify', () => { it('when status is valid', async () => { const credential : any = getVCv1ValidStatus() const expectedResult = getExpectedVerifiedResult({credential, withStatus: true}) - const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) expect(result).to.deep.equalInAnyOrder(expectedResult) // eslint-disable-line no-use-before-define }) }) @@ -35,12 +35,12 @@ describe('Verify', () => { describe('returns as unverified', () => { it('when expired', async () => { const credential : any = getVCv1Expired() - const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) assert.ok(result.log); }) it('when revoked', async () => { const credential : any = getVCv1Revoked() - const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) assert.ok(result.log); }) }) @@ -53,7 +53,7 @@ describe('Verify', () => { describe('returns fatal error', () => { it('when tampered with', async () => { const tamperedVC2 : any = getVCv2Tampered() - const result = await verifyCredential({credential: tamperedVC2, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential: tamperedVC2, reloadIssuerRegistry: false, knownDIDRegistries}) }) }) @@ -61,7 +61,7 @@ describe('Verify', () => { it('when status is valid', async () => { const credential : any = getVCv2ValidStatus() const expectedResult = getExpectedVerifiedResult({credential, withStatus: true}) - const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) expect(result).to.deep.equalInAnyOrder(expectedResult) // eslint-disable-line no-use-before-define }) }) @@ -70,9 +70,14 @@ describe('Verify', () => { it('when expired', async () => { const credential : any = getVCv2Expired() const expectedResult = getExpectedUnverifiedResult({credential, unVerifiedStep: 'expiration', withStatus:false}) - const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries}) + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) expect(result).to.deep.equalInAnyOrder(expectedResult) }) + it('when revoked', async () => { + const credential : any = getVCv2Revoked() + const result = await verifyCredential({credential, reloadIssuerRegistry: false, knownDIDRegistries}) + assert.ok(result.log); + }) }) }) })