-
Notifications
You must be signed in to change notification settings - Fork 15
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
Enveloped proofs helper functions #114
Changes from 5 commits
3263950
b1998aa
6adcf7e
40d91bd
0c6c9ad
e1ecf46
77d8bd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,17 @@ | |
*/ | ||
|
||
import {addPerTestMetadata, setupMatrix} from './helpers.js'; | ||
import {checkRequiredProperties, shouldBeSecured} from './assertions.js'; | ||
import assert from 'node:assert/strict'; | ||
import chai from 'chai'; | ||
import {createRequire} from 'module'; | ||
import {filterByTag} from 'vc-test-suite-implementations'; | ||
import {TestEndpoints} from './TestEndpoints.js'; | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const should = chai.should(); | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
const tag = 'vc2.0'; | ||
const {match} = filterByTag({tags: [tag]}); | ||
|
||
|
@@ -23,16 +26,60 @@ describe('Basic Conformance', function() { | |
const endpoints = new TestEndpoints({implementation, tag}); | ||
|
||
describe(name, function() { | ||
let issuedVc; | ||
before(async function() { | ||
try { | ||
issuedVc = await endpoints.issue(require( | ||
'./input/credential-ok.json')); | ||
} catch(e) { | ||
console.error( | ||
`Issuer: ${name} failed to issue "credential-ok.json".`, | ||
e | ||
); | ||
} | ||
}); | ||
beforeEach(addPerTestMetadata); | ||
it('Conforming document (compliance): VCDM "MUST be enforced." ' + | ||
'("all relevant normative statements in Sections 4. Basic Concepts, ' + | ||
'5. Advanced Concepts, and 6. Syntaxes")', async function() { | ||
this.test.link = `https://w3c.github.io/vc-data-model/#identifiers:~:text=of%20this%20document-,MUST%20be%20enforced.,-A%20conforming%20document`; | ||
it('A conforming document MUST be secured by at least one securing ' + | ||
'mechanism as described in Section 4.12 Securing Mechanisms.', | ||
async function() { | ||
this.test.link = `https://w3c.github.io/vc-data-model/#securing-mechanisms:~:text=A%20conforming%20document%20MUST%20be%20secured%20by%20at%20least%20one%20securing%20mechanism%20as%20described%20in%20Section%204.12%20Securing%20Mechanisms.`; | ||
// covers both embedded and enveloped dynamically | ||
should.exist(issuedVc, `Expected ${name} to have issued a VC.`); | ||
shouldBeSecured(name, issuedVc); | ||
}); | ||
it('A conforming issuer implementation MUST include all ' + | ||
'required properties in the conforming documents it produces.', | ||
async function() { | ||
this.test.link = `https://www.w3.org/TR/vc-data-model-2.0/#conformance:~:text=MUST%20include%20all%20required%20properties%20in%20the%20conforming%20documents%20it%20produces`; | ||
should.exist(issuedVc, `Expected ${name} to have issued a VC.`); | ||
checkRequiredProperties(name, issuedVc); | ||
}); | ||
it('A conforming issuer implementation MUST secure the ' + | ||
'conforming documents it produces using a securing mechanism' + | ||
'described in Section 4.12 Securing Mechanisms.', | ||
async function() { | ||
this.test.link = `https://www.w3.org/TR/vc-data-model-2.0/#conformance:~:text=MUST%20include%20all%20required%20properties%20in%20the%20conforming%20documents%20it%20produces`; | ||
should.exist(issuedVc, `Expected ${name} to have issued a VC.`); | ||
shouldBeSecured(name, issuedVc); | ||
}); | ||
it('A conforming verifier implementation MUST perform ' + | ||
'verification on a conforming document as described in' + | ||
'Section 4.12 Securing Mechanisms.', | ||
async function() { | ||
this.test.link = `https://www.w3.org/TR/vc-data-model-2.0/#conformance:~:text=MUST%20include%20all%20required%20properties%20in%20the%20conforming%20documents%20it%20produces`; | ||
await assert.doesNotReject(endpoints.verify(issuedVc), | ||
'Failed to verify credential.'); | ||
}); | ||
it('A conforming verifier implementation MUST check ' + | ||
'that each required property satisfies the normative requirements' + | ||
'for that property.', | ||
async function() { | ||
this.test.link = `https://www.w3.org/TR/vc-data-model-2.0/#conformance:~:text=MUST%20include%20all%20required%20properties%20in%20the%20conforming%20documents%20it%20produces`; | ||
this.test.cell.skipMessage = 'Tested by other tests in this suite.'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be handled by awaiting a previous call, you can do something like this async function testSomething(){
return endpoints.post('goo');
}
// store a promise here
const somethingTest = testSomething();
// await the promise
it('assertion 1', async function() {
await somethingTest;
})
// await the promise again
it('assertion 2', async function() {
await somethingTest;
}) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't go that far. In fact, I realized when going back through the MUSTs just now that all of Section 1 Introduction (of which 1.3 Conformance is a part) is non-normative...so we can remove the Let's merge this PR first, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, since you've brought them all in the way you have, we could do what @aljones15 is suggesting. It'll make the code read a little strangely (all the test's will get called outside of any Just still on the fence as to whether the await approach is worth the effort. Maybe let's discuss it soon. |
||
this.skip(); | ||
}); | ||
it('verifiers MUST produce errors when non-conforming documents ' + | ||
'are detected.', async function() { | ||
it('A conforming verifier implementation MUST produce errors ' + | ||
'when non-conforming documents are detected.', async function() { | ||
this.test.link = `https://w3c.github.io/vc-data-model/#types:~:text=MUST%20produce%20errors%20when%20non%2Dconforming%20documents%20are%20detected.`; | ||
const doc = { | ||
type: ['NonconformingDocument'] | ||
|
This file was deleted.
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.
we should probably store this error and ensure it shows up in the report so they know that the issuance failed.