Skip to content

Commit

Permalink
Add default reason for invalid statusCode check.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Jul 10, 2024
1 parent 23a7ccb commit 1f1c642
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ import {getMultikeys} from './vc-generator/key-gen.js';
import {parseBaseProofValue} from './vc-generator/stubMethods.js';

const should = chai.should();
// various reasons for failures
const reasons = {
verificationFail: 'Expected no result from verifier.',
statusCodeFail: 'Expected HTTP Status code 400 or 422 for invalid input!'
};

export const verificationFail = async ({
credential,
verifier,
reason = 'Expected no result from verifier.'
reason = reasons.verificationFail
}) => {
const body = {
verifiableCredential: credential,
Expand All @@ -29,8 +34,11 @@ export const verificationFail = async ({
const {result, error} = await verifier.post({json: body});
should.not.exist(result, reason);
should.exist(error, 'Expected verifier to error.');
should.exist(error.status, 'Expected verifier to return an HTTP Status code');
error.status.should.be.oneOf([400, 422], reason);
should.exist(error.status,
'Expected verifier Response to have an HTTP Status code.');
const statusReason = (reason === reasons.verificationFail) ?
reasons.statusCodeFail : reason;
error.status.should.be.oneOf([400, 422], statusReason);
};

export const verificationSuccess = async ({credential, verifier}) => {
Expand Down

0 comments on commit 1f1c642

Please sign in to comment.