-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1920 from blockchain-certificates/feat/proof-domain
Feat/proof domain
- Loading branch information
Showing
14 changed files
with
86 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
test/e2e/verifier/mocknet-vc-v2-proofDomain-invalid.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { Certificate, VERIFICATION_STATUSES } from '../../../src'; | ||
import MocknetVCV2ValidFromValid from '../../fixtures/v3/mocknet-vc-v2-validFrom-valid.json'; | ||
import fixtureBlockcertsIssuerProfile from '../../fixtures/issuer-blockcerts.json'; | ||
|
||
describe('given the proofPurpose of the certificate\'s proof does not match the verifier\'s purpose', function () { | ||
// this test will expire in 2039 | ||
it('should fail verification', async function () { | ||
vi.mock('@blockcerts/explorer-lookup', async (importOriginal) => { | ||
const explorerLookup = await importOriginal(); | ||
return { | ||
...explorerLookup, | ||
request: async function ({ url }) { | ||
if (url === 'https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json') { | ||
return JSON.stringify(fixtureBlockcertsIssuerProfile); | ||
} | ||
} | ||
}; | ||
}); | ||
|
||
const fixture = { | ||
...MocknetVCV2ValidFromValid, | ||
proof: { | ||
...MocknetVCV2ValidFromValid.proof, | ||
domain: 'blockcerts.org' | ||
} | ||
}; | ||
|
||
const certificate = new Certificate(fixture, { domain: ['example.org', 'another-example.org'] }); | ||
await certificate.init(); | ||
const result = await certificate.verify(); | ||
expect(result.status).toBe(VERIFICATION_STATUSES.FAILURE); | ||
expect(result.message).toBe('The proof is not authorized for this domain'); | ||
vi.restoreAllMocks(); | ||
}); | ||
}); |