Skip to content

Commit

Permalink
test: more regression tests for minDHSize option
Browse files Browse the repository at this point in the history
Check that tls.connect() fails in the expected way when passing in
invalid minDHSize options.

PR-URL: #3629
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
bnoordhuis authored and rvagg committed Nov 6, 2015
1 parent 935b977 commit 8152248
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-tls-client-mindhsize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8152248

Please sign in to comment.