Permalink
Browse files

test: improve coverage in test-crypto.dh

PR-URL: #11253
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
ejchristie authored and jasnell committed Feb 9, 2017
1 parent 389b9e4 commit fcf3cbed281118598751c7c71c5323963f61c5dc
Showing with 26 additions and 9 deletions.
  1. +26 −9 test/pummel/test-crypto-dh.js
@@ -8,15 +8,32 @@ if (!common.hasCrypto) {
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.'
);
const hashes = {
modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',

0 comments on commit fcf3cbe

Please sign in to comment.