Skip to content

Commit

Permalink
feat(Verification): ensure issuer property is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoustachiste committed Nov 13, 2024
1 parent c7ab064 commit b0a2856
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/domain/verifier/useCases/validateVerifiableCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ function validateContext (context: JsonLDContext, type: string[]): void {

function validateIssuer (certificateIssuer: string | Issuer): void {
let hasError = false;

if (typeof certificateIssuer === 'string' && !isValidUrl(certificateIssuer)) {
if (certificateIssuer == null) {
hasError = true;
} else if (typeof certificateIssuer === 'string' && !isValidUrl(certificateIssuer)) {
hasError = true;
} else if (typeof certificateIssuer === 'object' && !isValidUrl(certificateIssuer.id)) {
hasError = true;
Expand Down
8 changes: 4 additions & 4 deletions test/application/certificate/certificate-v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Certificate entity test suite', function () {
const certificate = new Certificate(failingFixture);
await expect(certificate.init())
.rejects
.toThrow('Unable to get issuer profile - no issuer address given');
.toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string');
});
});

Expand All @@ -106,7 +106,7 @@ describe('Certificate entity test suite', function () {
const certificate = new Certificate(failingFixture);
await expect(certificate.init())
.rejects
.toThrow('Unable to get issuer profile - no issuer address given');
.toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string');
});
});

Expand All @@ -117,7 +117,7 @@ describe('Certificate entity test suite', function () {
const certificate = new Certificate(failingFixture);
await expect(certificate.init())
.rejects
.toThrow('Unable to get issuer profile - no issuer address given');
.toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string');
});
});

Expand All @@ -128,7 +128,7 @@ describe('Certificate entity test suite', function () {
const certificate = new Certificate(failingFixture);
await expect(certificate.init())
.rejects
.toThrow('Unable to get issuer profile - no issuer address given');
.toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string');
});
});

Expand Down

0 comments on commit b0a2856

Please sign in to comment.