From d729e52ef34f7ea1f981102470e6ce16290ec973 Mon Sep 17 00:00:00 2001 From: Akito Ito Date: Fri, 10 Feb 2017 13:05:45 +0900 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell --- test/parallel/test-crypto-certificate.js | 3 +++ test/parallel/test-crypto-sign-verify.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index 1dfb2c73b0eca5..8dba530fc54a45 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/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); diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 29f6683e2ee162..d0c91f9082357e 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -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$/); +}