Browse Source

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>
process-exit-stdio-flushing
Ben Noordhuis 9 years ago
parent
commit
82022a79b0
  1. 2
      lib/_tls_wrap.js
  2. 9
      test/parallel/test-tls-client-mindhsize.js

2
lib/_tls_wrap.js

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

9
test/parallel/test-tls-client-mindhsize.js

@ -78,6 +78,15 @@ testDHE1024();
assert.throws(() => test(512, true, assert.fail), assert.throws(() => test(512, true, assert.fail),
/DH parameter is less than 1024 bits/); /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() { process.on('exit', function() {
assert.equal(nsuccess, 1); assert.equal(nsuccess, 1);
assert.equal(nerror, 1); assert.equal(nerror, 1);

Loading…
Cancel
Save