Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up various negative context tests & add FIXMEs for docLoader is…
Browse files Browse the repository at this point in the history
…sues.
aljones15 committed Aug 4, 2024
1 parent 4a2e4aa commit 11a0a29
Showing 1 changed file with 51 additions and 22 deletions.
73 changes: 51 additions & 22 deletions test/10-verify.spec.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ function _runSuite({
['/issuer', '/issuanceDate'] : ['/issuer'];
const selectivePointers = ['/credentialSubject'];
const generateDefaults = {
credentialFactory,
suites,
issuer: keyDoc.controller,
mandatoryPointers,
@@ -127,77 +126,107 @@ function _runSuite({

describe('negative test', async () => {
it('fails to verify if a context resolves to null', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push(invalidContexts.nullDoc.url);
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
//one with the context resolving to a valid context and the
//other with a context resolving to null
verifiableCredential['@context'].push(invalidContexts.nullDoc.url);
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context contains an invalid id', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push(invalidContexts.invalidId.url);
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
verifiableCredential['@context'].push(invalidContexts.invalidId.url);
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context has a null version', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push(invalidContexts.nullVersion.url);
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
verifiableCredential['@context'].push(
invalidContexts.nullVersion.url);
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context has a null @id', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push(invalidContexts.nullId.url);
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
verifiableCredential['@context'].push(invalidContexts.nullId.url);
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context has a null @type', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push(invalidContexts.nullType.url);
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
verifiableCredential['@context'].push(invalidContexts.nullType.url);
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context links to a missing doc', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push('https://fsad.digitalbazaar.com');
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
//FIXME this should be handled with 2 different document loaders
verifiableCredential['@context'].push('https://fsad.digitalbazaar.com');
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');
results.verified.should.be.false;
});
it('fails to verify if a context has an invalid url', async () => {
const {credential} = await signCredential(generateDefaults);
credential['@context'].push('htps://fsad.digitalbazaar.');
const {verifiableCredential} = await signCredential({
credential: credentialFactory(),
...generateDefaults
});
verifiableCredential['@context'].push('htps://fsad.digitalbazaar.');
const results = await vc.verifyCredential({
suite: verifySuite,
credential,
credential: verifiableCredential,
documentLoader
});
results.verified.should.be.a('boolean');

0 comments on commit 11a0a29

Please sign in to comment.