-
Notifications
You must be signed in to change notification settings - Fork 87
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 #1900 from blockchain-certificates/feat/multiple-c…
…redential-subjects Feat/multiple credential subjects
- Loading branch information
Showing
6 changed files
with
116 additions
and
30 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
test/e2e/verifier/mocknet-vc-v2-credential-subject-array.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,40 @@ | ||
import { describe, it, expect, beforeAll, vi, afterAll } from 'vitest'; | ||
import { Certificate, VERIFICATION_STATUSES } from '../../../src'; | ||
import MocknetVCV2CredentialSubjectArray from '../../fixtures/v3/mocknet-vc-v2-credential-subject-array.json'; | ||
import fixtureBlockcertsIssuerProfile from '../../fixtures/issuer-blockcerts.json'; | ||
import fixtureCredentialSchema from '../../fixtures/credential-schema-example-id-card.json'; | ||
|
||
describe('given the certificate is a valid mocknet (v3.2)', function () { | ||
beforeAll(function () { | ||
vi.mock('@blockcerts/explorer-lookup', async (importOriginal) => { | ||
const explorerLookup = await importOriginal(); | ||
return { | ||
...explorerLookup, | ||
// replace some exports | ||
request: async function ({ url }) { | ||
if (url === 'https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json') { | ||
return JSON.stringify(fixtureBlockcertsIssuerProfile); | ||
} | ||
|
||
if (url === 'https://www.blockcerts.org/samples/3.0/example-id-card-schema.json') { | ||
return JSON.stringify(fixtureCredentialSchema); | ||
} | ||
} | ||
}; | ||
}); | ||
}); | ||
|
||
afterAll(function () { | ||
vi.restoreAllMocks(); | ||
}); | ||
|
||
describe('and complies with its json schema definition', function () { | ||
// this test will expire in 2039 | ||
it('should verify successfully', async function () { | ||
const certificate = new Certificate(MocknetVCV2CredentialSubjectArray); | ||
await certificate.init(); | ||
const result = await certificate.verify(); | ||
expect(result.status).toBe(VERIFICATION_STATUSES.SUCCESS); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
{"@context": ["https://www.w3.org/ns/credentials/v2", {"DOB": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/DOB", "@type": "https://schema.org/Text"}, "nationality": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/nationality", "@type": "https://schema.org/Text"}, "height": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/height", "@type": "https://schema.org/Text"}, "residentialAddressStreet": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressStreet", "@type": "https://schema.org/Text"}, "residentialAddressTown": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressTown", "@type": "https://schema.org/Text"}, "residentialAddressPostCode": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressPostCode", "@type": "https://schema.org/Text"}, "IdCardCredential": {"@id": "https://schemas.learningmachine.com/2017/blockcerts/IdCardCredential", "@type": "https://schema.org/DataType"}}, "https://w3id.org/security/data-integrity/v2", "https://w3id.org/blockcerts/v3.2"], "type": ["VerifiableCredential", "BlockcertsCredential", "IdCardCredential"], "name": [{"@value": "Canadian Id Card", "@language": "en"}, {"@value": "Carte d'Identit\u00e9 Canadienne", "@language": "fr"}, {"@value": "\u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0647\u0648\u064a\u0629 \u0627\u0644\u0643\u0646\u062f\u064a\u0629", "@language": "ar", "@direction": "rtl"}], "description": [{"@value": "A Blockcerts example (not an official document) highlighting various VC v2 spec items", "@language": "en"}, {"@value": "Un example Blockcerts (document non officiel) d\u00e9montrant diff\u00e9rents \u00e9l\u00e9ments de la sp\u00e9cification VC v2", "@language": "fr"}, {"@value": "\u0645\u062b\u0627\u0644 \u0639\u0644\u0649 Blockcerts (\u0644\u064a\u0633 \u0645\u0633\u062a\u0646\u062f\u064b\u0627 \u0631\u0633\u0645\u064a\u064b\u0627) \u064a\u0633\u0644\u0637 \u0627\u0644\u0636\u0648\u0621 \u0639\u0644\u0649 \u0639\u0646\u0627\u0635\u0631 \u0645\u0648\u0627\u0635\u0641\u0627\u062a VC v2 \u0627\u0644\u0645\u062e\u062a\u0644\u0641\u0629", "@language": "ar", "@direction": "rtl"}], "issuer": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json", "validFrom": "2024-03-01T00:00:00Z", "validUntil": "2039-02-28T23:59:59Z", "id": "urn:uuid:4f5f0100-ccbf-4ca9-9cfc-4f5fc3052d28", "credentialSchema": [{"id": "https://www.blockcerts.org/samples/3.0/example-id-card-schema.json", "type": "JsonSchema"}], "credentialSubject": [{"id": "did:example:ebfeb1f712ebc6f1c276e12ec21", "@language": "en", "name": "John Smith", "nationality": "Canada", "DOB": "05/10/1983", "height": "1.80m", "residentialAddressStreet": "6 Maple Tree street", "residentialAddressTown": "Toronto", "residentialAddressPostCode": "YYZYUL"}, {"id": "did:example:ebfeb1f712ebc6f1c276e12ec21", "@language": "fr", "name": "Jean Forgeron", "nationality": "Canada", "DOB": "05/10/1983", "height": "1.80m", "residentialAddressStreet": "6 rue des \u00c9rables", "residentialAddressTown": "Montr\u00e9al", "residentialAddressPostCode": "YYZYUL"}], "display": {"contentMediaType": "text/html", "content": "<div style=\"background-color:transparent;padding:6px;display:inline-flex;align-items:center;flex-direction:column\">Yo</div>"}, "proof": {"id": "urn:uuid:277f7b2a-3567-4182-b0e1-199441fae5fb", "type": "DataIntegrityProof", "cryptosuite": "merkle-proof-2019", "proofPurpose": "assertionMethod", "created": "2024-11-07T15:51:05Z", "proofValue": "zEuZQLZTYrdsDv2EpwzQGUBe6PfabCRBgw919pBUVimNgpE5188vhyTySWTDvFLMDKMgLNdi3RQouwP5UrjLJkPSLb6JSBao3zi7nXAUFs8pKvv1AS4FC38QicsCL7oihbLLTG3dgkfjoVZAgNujrGfVTbJU3vw5QmViEEMFzupwA4vXF5zentFinyoELzpZGwDGTHVtgSEwGGFXaxDNNUMw6d3cbDNRvZT5mBneyG6GEZMtaccQ4f9PoPFi8Wac5rXje15UmMQfPuzoX6QyVvDZjCofhGBogYBSZAyG2rNqRT6", "verificationMethod": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json#key-1"}} |