test: more regression tests for minDHSize option

Check that tls.connect() fails in the expected way when passing in
invalid minDHSize options.

PR-URL: https://github.com/nodejs/node/pull/3629
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
Ben Noordhuis 2015-11-02 13:14:14 +01:00
parent cddf358f68
commit 82022a79b0
2 changed files with 10 additions and 1 deletions

View File

@ -974,7 +974,7 @@ exports.connect = function(/* [port, host], options, cb */) {
assert(typeof options.minDHSize === 'number',
'options.minDHSize is not a number: ' + options.minDHSize);
assert(options.minDHSize > 0,
'options.minDHSize is not a posivie number: ' +
'options.minDHSize is not a positive number: ' +
options.minDHSize);
var hostname = options.servername ||

View File

@ -78,6 +78,15 @@ testDHE1024();
assert.throws(() => test(512, true, assert.fail),
/DH parameter is less than 1024 bits/);
[0, -1, -Infinity, NaN].forEach(minDHSize => {
assert.throws(() => tls.connect({ minDHSize }),
/minDHSize is not a positive number/);
});
[true, false, null, undefined, {}, [], '', '1'].forEach(minDHSize => {
assert.throws(() => tls.connect({ minDHSize }), /minDHSize is not a number/);
});
process.on('exit', function() {
assert.equal(nsuccess, 1);
assert.equal(nerror, 1);