Skip to content

Commit

Permalink
Fix self asserted test fixtures
Browse files Browse the repository at this point in the history
Signed-off-by: PatStLouis <[email protected]>
  • Loading branch information
PatStLouis committed Nov 11, 2024
1 parent 1b02509 commit a5d79ea
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 26 deletions.
36 changes: 10 additions & 26 deletions tests/4.13-verifiable-presentations.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,12 @@ describe('Verifiable Presentations', function() {
presentationWithHolder
), 'Failed to verify a valid VP with holder.');

// presentation.holder = {id: localIssuer};
const presentationWithHolderObject = await createLocalVp({
presentation: require('./input/presentation-holder-object-ok.json')
});
await assert.doesNotReject(endpoints.verifyVp(
presentationWithHolderObject
), 'Failed to verify a valid VP with holder object.');

const presentationMissingHolderId = await createLocalVp({
presentation: require('./input/presentation-holder-object-fail.json')
});
await assert.rejects(endpoints.verifyVp(
presentationMissingHolderId
), 'Failed to reject a VP with an invalid holder.');

// TODO, how to create negative fixture (bad holder values)
});
});
Expand All @@ -135,14 +126,12 @@ describe('VP - Presentations Including Holder Claims', function() {
'verifiable presentation MUST include a holder property.',
async function() {
this.test.link = `https://w3c.github.io/vc-data-model/#presentations-including-holder-claims:~:text=A%20verifiable%20presentation%20that%20includes%20a%20self%2Dasserted%20verifiable%20credential%20that%20is%20only%20secured%20using%20the%20same%20mechanism%20as%20the%20verifiable%20presentation%20MUST%20include%20a%20holder%20property.`;
const presentation = require('./input/presentation-vc-ok.json');

presentation.verifiableCredential[0].issuer = localIssuer;
const presentationMissingHolder = await createLocalVp({
presentation
const selfAssertedNoHolder = await createLocalVp({
presentation: require(
'./input/presentation-self-asserted-vc-no-holder.json')
});
await assert.rejects(endpoints.verifyVp(
presentationMissingHolder
selfAssertedNoHolder
), 'Failed to reject a VP with self-asserted VC without holder.');
});

Expand All @@ -152,31 +141,26 @@ describe('VP - Presentations Including Holder Claims', function() {
'the holder property of the verifiable presentation.',
async function() {
this.test.link = `https://w3c.github.io/vc-data-model/#presentations-including-holder-claims:~:text=When%20a%20self%2Dasserted%20verifiable%20credential%20is%20secured%20using%20the%20same%20mechanism%20as%20the%20verifiable%20presentation%2C%20the%20value%20of%20the%20issuer%20property%20of%20the%20verifiable%20credential%20MUST%20be%20identical%20to%20the%20holder%20property%20of%20the%20verifiable%20presentation.`;
const presentation = require('./input/presentation-vc-ok.json');

presentation.verifiableCredential[0].issuer = localIssuer;
presentation.holder = localIssuer;
const presentationHolderMatch = await createLocalVp({
presentation
presentation: require(
'./input/presentation-self-asserted-vc-ok.json')
});
await assert.doesNotReject(endpoints.verifyVp(
presentationHolderMatch
), 'Failed to verify a VP containing a self-asserted VC.');

presentation.verifiableCredential[0].issuer = localIssuer;
presentation.holder = 'did:example:acme';
const presentationHolderMismatch = await createLocalVp({
presentation
presentation: require(
'./input/presentation-self-asserted-vc-holder-mismatch.json')
});
await assert.rejects(endpoints.verifyVp(
presentationHolderMismatch
), 'Failed to reject a VP with self-asserted VC ' +
'with a holder/issuer mismatch.');

presentation.verifiableCredential[0].issuer = 'did:example:acme';
presentation.holder = localIssuer;
const presentationIssuerMismatch = await createLocalVp({
presentation
presentation: require(
'./input/presentation-self-asserted-vc-issuer-mismatch.json')
});
await assert.rejects(endpoints.verifyVp(
presentationIssuerMismatch
Expand Down
23 changes: 23 additions & 0 deletions tests/input/presentation-self-asserted-vc-holder-mismatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiablePresentation"
],
"holder": "did:example:alice",
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiableCredential"
],
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
"credentialSubject": {
"id": "did:example:subject"
}
}
]
}
23 changes: 23 additions & 0 deletions tests/input/presentation-self-asserted-vc-issuer-mismatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiablePresentation"
],
"holder": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiableCredential"
],
"issuer": "did:example:alice",
"credentialSubject": {
"id": "did:example:subject"
}
}
]
}
22 changes: 22 additions & 0 deletions tests/input/presentation-self-asserted-vc-no-holder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiablePresentation"
],
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiableCredential"
],
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
"credentialSubject": {
"id": "did:example:subject"
}
}
]
}
23 changes: 23 additions & 0 deletions tests/input/presentation-self-asserted-vc-ok.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiablePresentation"
],
"holder": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiableCredential"
],
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
"credentialSubject": {
"id": "did:example:subject"
}
}
]
}

0 comments on commit a5d79ea

Please sign in to comment.