test: improve crypto coverage

* call Certificate function directly
* check exception when sign option is undefined

PR-URL: https://github.com/nodejs/node/pull/11280
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Akito Ito 2017-02-10 13:05:45 +09:00 committed by James M Snell
parent e4e7cd5bd2
commit 036eef1003
2 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -70,3 +70,10 @@ const 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$/);
}