From cd3e17e2489ad7138b3ca3b6f37bd5995de00739 Mon Sep 17 00:00:00 2001 From: Eric Christie Date: Wed, 8 Feb 2017 23:20:05 -0500 Subject: [PATCH] test: improve coverage in test-crypto.dh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11253 Reviewed-By: Rich Trott Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/pummel/test-crypto-dh.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js index 268496380f4c3a..064ce3c7f597d8 100644 --- a/test/pummel/test-crypto-dh.js +++ b/test/pummel/test-crypto-dh.js @@ -9,15 +9,32 @@ try { return; } -assert.throws(function() { - crypto.getDiffieHellman('unknown-group'); -}); -assert.throws(function() { - crypto.getDiffieHellman('modp1').setPrivateKey(''); -}); -assert.throws(function() { - crypto.getDiffieHellman('modp1').setPublicKey(''); -}); +assert.throws( + function() { + crypto.getDiffieHellman('unknown-group'); + }, + /^Error: Unknown group$/, + 'crypto.getDiffieHellman(\'unknown-group\') ' + + 'failed to throw the expected error.' +); +assert.throws( + function() { + crypto.getDiffieHellman('modp1').setPrivateKey(''); + }, + new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + + 'setPrivateKey is not a function$'), + 'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' + + 'failed to throw the expected error.' +); +assert.throws( + function() { + crypto.getDiffieHellman('modp1').setPublicKey(''); + }, + new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + + 'setPublicKey is not a function$'), + 'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' + + 'failed to throw the expected error.' +); var hashes = { modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',