Skip to content

Commit

Permalink
test: improve coverage in test-crypto.dh
Browse files Browse the repository at this point in the history
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
ejc-main authored and MylesBorins committed Mar 9, 2017
1 parent 6abfcd5 commit cd3e17e
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions test/pummel/test-crypto-dh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit cd3e17e

Please sign in to comment.