Skip to content

Commit

Permalink
add some invalid VCs to test
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-tbd committed Sep 18, 2023
1 parent c9d434a commit 83dc45e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/1872",
"type": ["VerifiableCredential", "AlumniCredential"],
"issuer": "https://example.edu/issuers/565049",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"alumniOf": {
"id": "did:example:c276e12ec21ebfeb1f712ebc6f1",
"name": [
{
"value": "Example University",
"lang": "en"
},
{
"value": "Exemple d'Université",
"lang": "fr"
}
]
}
},
"proof": {
"type": "RsaSignature2018",
"created": "2017-06-18T21:19:10Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "https://example.edu/issuers/565049/keys/1",
"jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
}
}
32 changes: 32 additions & 0 deletions packages/credentials/tests/VCs/invalid/invalid-vc-2-no-issuer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/1872",
"type": ["VerifiableCredential", "AlumniCredential"],
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"alumniOf": {
"id": "did:example:c276e12ec21ebfeb1f712ebc6f1",
"name": [
{
"value": "Example University",
"lang": "en"
},
{
"value": "Exemple d'Université",
"lang": "fr"
}
]
}
},
"proof": {
"type": "RsaSignature2018",
"created": "2017-06-18T21:19:10Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "https://example.edu/issuers/565049/keys/1",
"jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/1872",
"type": ["VerifiableCredential", "AlumniCredential"],
"issuer": "https://example.edu/issuers/565049",
"issuanceDate": "2010-01-01T19:23:24Z",
"proof": {
"type": "RsaSignature2018",
"created": "2017-06-18T21:19:10Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "https://example.edu/issuers/565049/keys/1",
"jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
}
}
5 changes: 1 addition & 4 deletions packages/credentials/tests/VCs/valid/vc-example-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/1872",
"type": [
"VerifiableCredential",
"AlumniCredential"
],
"type": ["VerifiableCredential", "AlumniCredential"],
"issuer": "https://example.edu/issuers/565049",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
Expand Down
5 changes: 1 addition & 4 deletions packages/credentials/tests/VCs/valid/vc-example-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.gov/credentials/3732",
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
Expand Down
5 changes: 1 addition & 4 deletions packages/credentials/tests/VCs/valid/vc-example-20.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/3732",
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
Expand Down
9 changes: 2 additions & 7 deletions packages/credentials/tests/VCs/valid/vc-example-21.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.edu/credentials/3732",
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
Expand All @@ -27,9 +24,7 @@
"assigner": "https://example.edu/issuers/14",
"assignee": "AllVerifiers",
"target": "http://example.edu/credentials/3732",
"action": [
"Archival"
]
"action": ["Archival"]
}
]
}
Expand Down
8 changes: 8 additions & 0 deletions packages/credentials/tests/verifiable-credentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ describe('VerifiableCredentials', () => {
});
}

const invalidVCjsons = globSync('./tests/VCs/invalid/*.json');
for(const filename of invalidVCjsons) {
it('refuses to validate invalid VC ' + filename, () => {
const vc = JSON.parse(fs.readFileSync(filename).toString());
expect(() => VerifiableCredential.validatePayload(vc)).to.throw();
});
}

const validVPjsons = globSync('./tests/VPs/valid/*.json');
for(const filename of validVPjsons) {
it('loads and validates valid VP ' + filename, () => {
Expand Down

0 comments on commit 83dc45e

Please sign in to comment.