diff --git a/tests/80-algorithms-rdfc.js b/tests/80-algorithms-rdfc.js index 847c3ed..f179ac5 100644 --- a/tests/80-algorithms-rdfc.js +++ b/tests/80-algorithms-rdfc.js @@ -37,28 +37,31 @@ describe('Algorithms - Transformation (eddsa-rdfc-2022)', function() { const [issuer] = endpoints; let issuedVc; let proofs; - let eddsa2022Proofs; + let eddsa2022Proofs = []; before(async function() { issuedVc = await createInitialVc({issuer, vc: validVc}); proofs = getProofs(issuedVc); + if(proofs?.length) { + eddsa2022Proofs = proofs.filter( + proof => proof?.cryptosuite === cryptosuite); + } }); - - beforeEach(async function() { + const assertBefore = () => { should.exist(issuedVc, 'Expected issuer to have issued a credential.'); should.exist(proofs, 'Expected credential to have a proof.'); - eddsa2022Proofs = proofs.filter( - proof => proof?.cryptosuite === cryptosuite); eddsa2022Proofs.length.should.be.gte(1, 'Expected at least one eddsa-rdfc-2022 cryptosuite.'); - }); + + }; beforeEach(setupRow); it('The transformation options MUST contain a type identifier for ' + 'the cryptographic suite (type) and a cryptosuite identifier ' + '(cryptosuite).', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#transformation-eddsa-rdfc-2022'; + assertBefore(); for(const proof of eddsa2022Proofs) { should.exist(proof.type, 'Expected a type identifier on the proof.'); @@ -68,7 +71,8 @@ describe('Algorithms - Transformation (eddsa-rdfc-2022)', function() { }); it('Whenever this algorithm encodes strings, it MUST use UTF-8 encoding.', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#transformation-eddsa-rdfc-2022'; + assertBefore(); for(const proof of eddsa2022Proofs) { should.exist(proof?.proofValue, 'Expected proofValue to exist.'); @@ -84,7 +88,8 @@ describe('Algorithms - Transformation (eddsa-rdfc-2022)', function() { 'error MUST be raised that SHOULD convey an error type of ' + 'PROOF_TRANSFORMATION_ERROR.', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#transformation-eddsa-rdfc-2022'; + assertBefore(); for(const proof of eddsa2022Proofs) { should.exist(proof.type, 'Expected a type identifier on the proof.'); @@ -95,7 +100,6 @@ describe('Algorithms - Transformation (eddsa-rdfc-2022)', function() { proof.cryptosuite.should.equal('eddsa-jcs-2022', 'Expected eddsa-jcs-2022 cryptosuite.'); } - }); }); } @@ -113,28 +117,30 @@ describe('Algorithms - Proof Configuration (eddsa-rdfc-2022)', function() { const [issuer] = endpoints; let issuedVc; let proofs; - let eddsa2022Proofs; + let eddsa2022Proofs = []; before(async function() { issuedVc = await createInitialVc({issuer, vc: validVc}); proofs = getProofs(issuedVc); + if(proofs?.length) { + eddsa2022Proofs = proofs.filter( + proof => proof?.cryptosuite === cryptosuite); + } }); - - beforeEach(async function() { + const assertBefore = () => { should.exist(issuedVc, 'Expected issuer to have issued a credential.'); should.exist(proofs, 'Expected credential to have a proof.'); - eddsa2022Proofs = proofs.filter( - proof => proof?.cryptosuite === cryptosuite); eddsa2022Proofs.length.should.be.gte(1, 'Expected at least one eddsa-rdfc-2022 cryptosuite.'); - }); + }; beforeEach(setupRow); it('The proof options MUST contain a type identifier for the ' + 'cryptographic suite (type) and MUST contain a cryptosuite ' + 'identifier (cryptosuite).', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#proof-configuration-eddsa-rdfc-2022:~:text=the%20proof%20options%20(options).-,The%20proof%20options%20MUST%20contain%20a%20type%20identifier%20for%20the%20cryptographic%20suite%20(type)%20and%20MUST%20contain%20a%20cryptosuite%20identifier%20(cryptosuite).,-A%20proof%20configuration%20object%20is%20produced'; + assertBefore(); for(const proof of eddsa2022Proofs) { should.exist(proof.type, 'Expected a type identifier on the proof.'); @@ -148,7 +154,8 @@ describe('Algorithms - Proof Configuration (eddsa-rdfc-2022)', function() { 'an error MUST be raised and SHOULD convey an error type of ' + 'PROOF_GENERATION_ERROR.', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#proof-configuration-eddsa-rdfc-2022:~:text=If%20proofConfig.type%20is%20not%20set%20to%20DataIntegrityProof%20and/or%20proofConfig.cryptosuite%20is%20not%20set%20to%20eddsa%2Drdfc%2D2022%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.'; + assertBefore(); for(const proof of eddsa2022Proofs) { should.exist(proof.type, 'Expected a type identifier on the proof.'); @@ -161,14 +168,14 @@ describe('Algorithms - Proof Configuration (eddsa-rdfc-2022)', function() { 'is not a valid [XMLSCHEMA11-2] datetime, an error MUST be ' + 'raised and SHOULD convey an error type of PROOF_GENERATION_ERROR.', async function() { - this.test.link = ''; + this.test.link = 'https://w3c.github.io/vc-di-eddsa/#proof-configuration-eddsa-rdfc-2022:~:text=and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.-,If%20proofConfig.created%20is%20present%20and%20set%20to%20a%20value%20that%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.,-Set%20proofConfig.%40context%20to%20unsecuredDocument.%40context.'; + assertBefore(); for(const proof of eddsa2022Proofs) { if(proof?.created) { isValidDatetime(proof.created).should.equal( true, 'Expected created value to be a valid datetime string.' ); - } else { } } });