Browse Source

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>
v6
Akito Ito 8 years ago
committed by James M Snell
parent
commit
036eef1003
  1. 3
      test/parallel/test-crypto-certificate.js
  2. 7
      test/parallel/test-crypto-sign-verify.js

3
test/parallel/test-crypto-certificate.js

@ -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
test/parallel/test-crypto-sign-verify.js

@ -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$/);
}

Loading…
Cancel
Save