Skip to content

Commit

Permalink
test: improve crypto coverage
Browse files Browse the repository at this point in the history
* call Certificate function directly
* check exception when sign option is undefined

PR-URL: #11280
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
akito0107 authored and MylesBorins committed Mar 9, 2017
1 parent 77f23ec commit d729e52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/parallel/test-crypto-certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ assert.strictEqual(certificate.exportChallenge(spkacFail), '');
function stripLineEndings(obj) {
return obj.replace(/\n/g, '');
}

// direct call Certificate() should return instance
assert(crypto.Certificate() instanceof crypto.Certificate);
7 changes: 7 additions & 0 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
verified = verStream.verify(certPem, s3);
assert.strictEqual(verified, true, 'sign and verify (stream)');
}

// Test throws exception when key options is null
{
assert.throws(() => {
crypto.createSign('RSA-SHA1').update('Test123').sign(null, 'base64');
}, /^Error: No key provided to sign$/);
}

0 comments on commit d729e52

Please sign in to comment.