Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared gens section & invalid cryptosuite generator #41

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# data-integrity-test-suite-assertion Changelog

## 1.2.0 -

### Added
- A new section shared in generators with shared generators.

## 1.1.0 - 2024-06-13

### Added
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function checkDataIntegrityProofVerifyErrors({
}); // end describe
}

export {generators} from './vc-generator/generators.js';
export {generators, issueCloned} from './vc-generator/generators.js';
export {
createInitialVc, dateRegex, expectedMultibasePrefix,
isObjectOrArrayOfObjects,
Expand Down
42 changes: 36 additions & 6 deletions vc-generator/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@ const {CredentialIssuancePurpose} = vc;

// generator categories
export const generators = {
// creates test vectors for `proof.created`
created: {
noCreated,
invalidCreated,
vcCreatedOneYearAgo
},
// creates test vectors for Authentication Purpose tests
authentication: {
invalidDomain,
invalidChallenge
},
// these generators are needed for DI specific tests
// and maybe be needed in suite specific tests
mandatory: {
noVerificationMethod,
noProofPurpose,
issuedVc,
invalidCryptosuite,
invalidProofPurpose,
invalidProofType,
noVerificationMethod,
invalidVm,
noProofPurpose,
invalidProofPurpose
}
},
// creates a set of shared test vector generators
// not necessarily used in DI Assertion itself, but used
// in multiple suites
shared: {}
};

/**
Expand Down Expand Up @@ -116,12 +125,33 @@ function noCreated({suite, selectiveSuite, credential}) {
}

// both base and derived will have an invalid proof.type
function invalidProofType({suite, selectiveSuite, credential}) {
suite.type = 'UnknownProofType';
function invalidProofType({
suite,
selectiveSuite,
credential,
proofType = 'UnknownProofType'
}) {
suite.type = proofType;
if(selectiveSuite) {
const proofId = 'urn:uuid:no-proof-type-test';
suite.proof = {id: proofId};
selectiveSuite._cryptosuite.options.proofId = proofId;
selectiveSuite.type = proofType;
}
return {suite, selectiveSuite, credential};
}

// chances the cryptosuite name to something else for
// invalid cryptosuite tests
function invalidCryptosuite({
suite,
selectiveSuite,
credential,
cryptosuiteName = 'UnknownCryptosuite'
}) {
suite.cryptosuite = cryptosuiteName;
if(selectiveSuite) {
selectiveSuite.cryptosuite = cryptosuiteName;
}
return {suite, selectiveSuite, credential};
}
Expand Down
Loading