Skip to content

Commit 9218943

Browse files
PatStLouisBigBlueHat
authored andcommitted
Fix self asserted test fixtures
Signed-off-by: PatStLouis <[email protected]>
1 parent 9bab72a commit 9218943

5 files changed

+101
-26
lines changed

tests/4.13-verifiable-presentations.js

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,12 @@ describe('Verifiable Presentations', function() {
100100
presentationWithHolder
101101
), 'Failed to verify a valid VP with holder.');
102102

103-
// presentation.holder = {id: localIssuer};
104103
const presentationWithHolderObject = await createLocalVp({
105104
presentation: require('./input/presentation-holder-object-ok.json')
106105
});
107106
await assert.doesNotReject(endpoints.verifyVp(
108107
presentationWithHolderObject
109108
), 'Failed to verify a valid VP with holder object.');
110-
111-
const presentationMissingHolderId = await createLocalVp({
112-
presentation: require('./input/presentation-holder-object-fail.json')
113-
});
114-
await assert.rejects(endpoints.verifyVp(
115-
presentationMissingHolderId
116-
), 'Failed to reject a VP with an invalid holder.');
117-
118109
// TODO, how to create negative fixture (bad holder values)
119110
});
120111
});
@@ -135,14 +126,12 @@ describe('VP - Presentations Including Holder Claims', function() {
135126
'verifiable presentation MUST include a holder property.',
136127
async function() {
137128
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.`;
138-
const presentation = require('./input/presentation-vc-ok.json');
139-
140-
presentation.verifiableCredential[0].issuer = localIssuer;
141-
const presentationMissingHolder = await createLocalVp({
142-
presentation
129+
const selfAssertedNoHolder = await createLocalVp({
130+
presentation: require(
131+
'./input/presentation-self-asserted-vc-no-holder.json')
143132
});
144133
await assert.rejects(endpoints.verifyVp(
145-
presentationMissingHolder
134+
selfAssertedNoHolder
146135
), 'Failed to reject a VP with self-asserted VC without holder.');
147136
});
148137

@@ -152,31 +141,26 @@ describe('VP - Presentations Including Holder Claims', function() {
152141
'the holder property of the verifiable presentation.',
153142
async function() {
154143
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.`;
155-
const presentation = require('./input/presentation-vc-ok.json');
156-
157-
presentation.verifiableCredential[0].issuer = localIssuer;
158-
presentation.holder = localIssuer;
159144
const presentationHolderMatch = await createLocalVp({
160-
presentation
145+
presentation: require(
146+
'./input/presentation-self-asserted-vc-ok.json')
161147
});
162148
await assert.doesNotReject(endpoints.verifyVp(
163149
presentationHolderMatch
164150
), 'Failed to verify a VP containing a self-asserted VC.');
165151

166-
presentation.verifiableCredential[0].issuer = localIssuer;
167-
presentation.holder = 'did:example:acme';
168152
const presentationHolderMismatch = await createLocalVp({
169-
presentation
153+
presentation: require(
154+
'./input/presentation-self-asserted-vc-holder-mismatch.json')
170155
});
171156
await assert.rejects(endpoints.verifyVp(
172157
presentationHolderMismatch
173158
), 'Failed to reject a VP with self-asserted VC ' +
174159
'with a holder/issuer mismatch.');
175160

176-
presentation.verifiableCredential[0].issuer = 'did:example:acme';
177-
presentation.holder = localIssuer;
178161
const presentationIssuerMismatch = await createLocalVp({
179-
presentation
162+
presentation: require(
163+
'./input/presentation-self-asserted-vc-issuer-mismatch.json')
180164
});
181165
await assert.rejects(endpoints.verifyVp(
182166
presentationIssuerMismatch
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"@context": [
3+
"https://www.w3.org/ns/credentials/v2"
4+
],
5+
"type": [
6+
"VerifiablePresentation"
7+
],
8+
"holder": "did:example:alice",
9+
"verifiableCredential": [
10+
{
11+
"@context": [
12+
"https://www.w3.org/ns/credentials/v2"
13+
],
14+
"type": [
15+
"VerifiableCredential"
16+
],
17+
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
18+
"credentialSubject": {
19+
"id": "did:example:subject"
20+
}
21+
}
22+
]
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"@context": [
3+
"https://www.w3.org/ns/credentials/v2"
4+
],
5+
"type": [
6+
"VerifiablePresentation"
7+
],
8+
"holder": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
9+
"verifiableCredential": [
10+
{
11+
"@context": [
12+
"https://www.w3.org/ns/credentials/v2"
13+
],
14+
"type": [
15+
"VerifiableCredential"
16+
],
17+
"issuer": "did:example:alice",
18+
"credentialSubject": {
19+
"id": "did:example:subject"
20+
}
21+
}
22+
]
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"@context": [
3+
"https://www.w3.org/ns/credentials/v2"
4+
],
5+
"type": [
6+
"VerifiablePresentation"
7+
],
8+
"verifiableCredential": [
9+
{
10+
"@context": [
11+
"https://www.w3.org/ns/credentials/v2"
12+
],
13+
"type": [
14+
"VerifiableCredential"
15+
],
16+
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
17+
"credentialSubject": {
18+
"id": "did:example:subject"
19+
}
20+
}
21+
]
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"@context": [
3+
"https://www.w3.org/ns/credentials/v2"
4+
],
5+
"type": [
6+
"VerifiablePresentation"
7+
],
8+
"holder": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
9+
"verifiableCredential": [
10+
{
11+
"@context": [
12+
"https://www.w3.org/ns/credentials/v2"
13+
],
14+
"type": [
15+
"VerifiableCredential"
16+
],
17+
"issuer": "did:key:z6MkpJySvETLnxhQG9DzEdmKJtysBDjuuTeDfUj1uNNCUqcj",
18+
"credentialSubject": {
19+
"id": "did:example:subject"
20+
}
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)