Browse Source

test: improve coverage in test-crypto.dh

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Eric Christie 8 years ago
committed by James M Snell
parent
commit
fcf3cbed28
  1. 35
      test/pummel/test-crypto-dh.js

35
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',

Loading…
Cancel
Save