-
Notifications
You must be signed in to change notification settings - Fork 7
Add data model suite #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f79bb5d
Add initial data model suite intended for issuers.
aljones15 b6bc293
Add assertBefore & endpoint check.
aljones15 42d791f
Fill in first VM test & get proofs.
aljones15 36cb201
Add further assertions on proofs to data model suite.
aljones15 0c32e03
Add initial data-model test.
aljones15 280abf8
Remove proofValue test from data model & update links.
aljones15 4edf3a5
Comment out jcs & correct naming in before statement.
aljones15 e7d9a88
Use didResolver to assert on publicKeyMultibase.
aljones15 5748112
Update tests/suites/data-model.js add period to end of sentence.
aljones15 24fe1c9
Update tests/suites/data-model.js add period to bs58 reason.
aljones15 2035e75
Update tests/suites/data-model.js add missing period to end of bs58 r…
aljones15 df7e572
Update tests/suites/data-model.js Remove trailing A from end of sente…
aljones15 c20af05
Handle implemented & multi-key-types.
aljones15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,39 @@ | ||
| /*! | ||
| * Copyright 2024 Digital Bazaar, Inc. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| import {dataModelSuite} from './suites/data-model.js'; | ||
| import {endpoints} from 'vc-test-suite-implementations'; | ||
| import {getSuiteConfig} from './test-config.js'; | ||
|
|
||
| const cryptosuites = [ | ||
| 'ecdsa-rdfc-2019', | ||
| 'ecdsa-sd-2023' | ||
| //FIXME implement jcs 'ecdsa-jcs-2019' | ||
| ]; | ||
|
|
||
| for(const suiteName of cryptosuites) { | ||
| const {tags, credentials, vectors} = getSuiteConfig(suiteName); | ||
| const {match: issuers} = endpoints.filterByTag({ | ||
| tags: [...tags], | ||
| property: 'issuers' | ||
| }); | ||
| for(const vcVersion of vectors.vcTypes) { | ||
| const { | ||
| document, | ||
| mandatoryPointers, | ||
| selectivePointers | ||
| } = credentials.create[vcVersion]; | ||
| for(const keyType of vectors.keyTypes) { | ||
| dataModelSuite({ | ||
| issuers, | ||
| suiteName, | ||
| keyType, | ||
| vcVersion, | ||
| credential: document, | ||
| mandatoryPointers, | ||
| selectivePointers | ||
| }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,122 @@ | ||
| /*! | ||
| * Copyright 2024 Digital Bazaar, Inc. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| import {createInitialVc, endpointCheck} from '../helpers.js'; | ||
| import { | ||
| assertions, | ||
| } from 'data-integrity-test-suite-assertion'; | ||
| import {didResolver} from '../didResolver.js'; | ||
| import {expect} from 'chai'; | ||
|
|
||
| export function dataModelSuite({ | ||
| issuers, | ||
| suiteName, | ||
| keyType, | ||
| vcVersion, | ||
| credential, | ||
| mandatoryPointers | ||
| }) { | ||
| return describe(`${suiteName} - Data Model - VC ${vcVersion}`, function() { | ||
| this.matrix = true; | ||
| this.report = true; | ||
| this.implemented = [...issuers]; | ||
| this.rowLabel = 'Test Name'; | ||
| this.columnLabel = 'Implementation'; | ||
| for(const [name, {endpoints}] of issuers) { | ||
| const [issuer] = endpoints; | ||
| // does the endpoint support this test? | ||
| if(!endpointCheck({endpoint: issuer, keyType, vcVersion})) { | ||
| continue; | ||
| } | ||
| describe(`${name}: ${keyType}`, function() { | ||
| let securedCredential = null; | ||
| let proofs = []; | ||
| before(async function() { | ||
| securedCredential = await createInitialVc({ | ||
| issuer, | ||
| vcVersion, | ||
| vc: credential, | ||
| mandatoryPointers | ||
| }); | ||
| if(securedCredential) { | ||
| proofs = Array.isArray(securedCredential.proof) ? | ||
| securedCredential?.proof : [securedCredential?.proof]; | ||
| // only test proofs that match the relevant cryptosuite | ||
| proofs = proofs.filter(p => p?.cryptosuite === suiteName); | ||
| } | ||
| }); | ||
| beforeEach(function() { | ||
| this.currentTest.cell = { | ||
| rowId: this.currentTest.title, | ||
| columnId: this.currentTest.parent.title | ||
| }; | ||
| }); | ||
| function assertBefore() { | ||
| expect( | ||
| securedCredential, | ||
| `Expected issuer ${name}: ${keyType} to issue a VC.` | ||
| ).to.exist; | ||
| expect( | ||
| securedCredential, | ||
| 'Expected VC to be an object.' | ||
| ).to.be.an('object'); | ||
| } | ||
| it('The publicKeyMultibase value of the verification method MUST ' + | ||
| 'start with the base-58-btc prefix (z), as defined in the ' + | ||
| 'Multibase section of Controller Documents 1.0. A ', | ||
aljones15 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| async function() { | ||
| this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#data-model:~:text=The%20publicKeyMultibase%20value%20of%20the%20verification%20method%20MUST%20start%20with%20the%20base%2D58%2Dbtc%20prefix%20(z)%2C%20as%20defined%20in%20the%20Multibase%20section%20of%20Controller%20Documents%201.0.'; | ||
| assertBefore(); | ||
| for(const proof of proofs) { | ||
| expect(proof.verificationMethod).to.exist; | ||
| expect(proof.verificationMethod).to.be.a('string'); | ||
| const didDoc = await didResolver({url: proof.verificationMethod}); | ||
| expect(didDoc).to.be.an('object'); | ||
| expect(didDoc.publicKeyMultibase).to.be.a('string'); | ||
| expect( | ||
| assertions.shouldBeBs58(didDoc.publicKeyMultibase), | ||
| 'Expected "publicKeyMultibase" to be Base58 encoded.' | ||
| ).to.be.true; | ||
| } | ||
| }); | ||
| it('Any other encoding MUST NOT be allowed. (verificationMethod)', | ||
| async function() { | ||
| this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#multikey'; | ||
| assertBefore(); | ||
| for(const proof of proofs) { | ||
| expect(proof.verificationMethod).to.exist; | ||
| expect(proof.verificationMethod).to.be.a('string'); | ||
| const didDoc = await didResolver({url: proof.verificationMethod}); | ||
| expect(didDoc).to.be.an('object'); | ||
| expect(didDoc.publicKeyMultibase).to.be.a('string'); | ||
| expect( | ||
| assertions.shouldBeBs58(didDoc.publicKeyMultibase), | ||
| 'Expected "publicKeyMultibase" to be Base58 encoded.' | ||
| ).to.be.true; | ||
| } | ||
| }); | ||
| it('The type property MUST be DataIntegrityProof.', async function() { | ||
| this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20type%20property%20MUST%20be%20DataIntegrityProof.'; | ||
| assertBefore(); | ||
| for(const proof of proofs) { | ||
| expect(proof.type).to.exist; | ||
| expect(proof.type).to.be.a('string'); | ||
| expect(proof.type).to.equal('DataIntegrityProof'); | ||
| } | ||
| }); | ||
| it('The cryptosuite property MUST be ecdsa-rdfc-2019, ' + | ||
| 'ecdsa-jcs-2019, or ecdsa-sd-2023.', async function() { | ||
| this.test.link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20cryptosuite%20property%20MUST%20be%20ecdsa%2Drdfc%2D2019%2C%20ecdsa%2Djcs%2D2019%2C%20or%20ecdsa%2Dsd%2D2023.'; | ||
| assertBefore(); | ||
| for(const proof of proofs) { | ||
| expect(proof.cryptosuite).to.exist; | ||
| expect(proof.cryptosuite).to.be.a('string'); | ||
| expect(proof.cryptosuite).to.be.oneOf( | ||
| ['ecdsa-rdfc-2019', 'edcsa-jcs-2019', 'ecdsa-sd-2023']); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what should be written here. Maybe the
Ashould just be dropped? Maybe1.0.Awas meant? For certain, the sentence should end with a..Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TallTed this looks like a typo resulting from my cut and paste job. The line reads: "The publicKeyMultibase value of the verification method MUST start with the base-58-btc prefix (z), as defined in the Multibase section of Controller Documents 1.0" The A belongs to the next sentence: "A Multibase-encoded ECDSA 256-bit public key value or an ECDSA 384-bit public key value follows, as defined in the Multikey section of Controller Documents 1.0. Any other encoding MUST NOT be allowed."
So the A should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TallTed addressed here: df7e572