Skip to content

Commit

Permalink
Add credentialStatus tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
msporny committed Jan 7, 2019
1 parent fc3f51d commit 7f4efa1
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/vc-data-model-1.0/05-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const uriRegex = /\w+:(\/?\/?)[^\s]+/;
const iso8601Regex = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/

// configure chai
chai.should();
const should = chai.should();
chai.use(require('chai-as-promised'));

describe('Document', () => {
Expand Down Expand Up @@ -165,4 +165,25 @@ describe('Document', () => {
});
});

describe('`credentialStatus` property', () => {

it('MUST include `id` and `type`', async () => {
const doc = await util.generate('example-7.jsonld', generatorOptions);
doc.credentialStatus.id.should.be.a('string');
should.exist(doc.credentialStatus.type);
});

it('MUST include `id` and `type` (negative - missing `id`)', async () => {
expect(util.generate(
'example-7-bad-missing-id.jsonld', generatorOptions))
.to.be.rejectedWith(Error);
});

it('MUST include `id` and `type` (negative - missing `type`)', async () => {
expect(util.generate(
'example-7-bad-missing-type.jsonld', generatorOptions))
.to.be.rejectedWith(Error);
});
});

});
21 changes: 21 additions & 0 deletions test/vc-data-model-1.0/input/example-7-bad-missing-id.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@context": [
"https://w3.org/2018/credentials/v1",
"https://example.com/examples/v1"
],
"id": "http://example.edu/credentials/3732",
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science in Mechanical Engineering"
}
},
"credentialStatus": {
"type": "CredentialStatusList2017"
},
"proof": {}
}
21 changes: 21 additions & 0 deletions test/vc-data-model-1.0/input/example-7-bad-missing-type.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@context": [
"https://w3.org/2018/credentials/v1",
"https://example.com/examples/v1"
],
"id": "http://example.edu/credentials/3732",
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science in Mechanical Engineering"
}
},
"credentialStatus": {
"id": "https://example.edu/status/24
},
"proof": {}
}
22 changes: 22 additions & 0 deletions test/vc-data-model-1.0/input/example-7.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@context": [
"https://w3.org/2018/credentials/v1",
"https://example.com/examples/v1"
],
"id": "http://example.edu/credentials/3732",
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science in Mechanical Engineering"
}
},
"credentialStatus": {
"id": "https://example.edu/status/24",
"type": "CredentialStatusList2017"
},
"proof": {}
}

0 comments on commit 7f4efa1

Please sign in to comment.