Skip to content

Commit 8152248

Browse files
bnoordhuisrvagg
authored andcommitted
test: more regression tests for minDHSize option
Check that tls.connect() fails in the expected way when passing in invalid minDHSize options. PR-URL: #3629 Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 935b977 commit 8152248

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/_tls_wrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ exports.connect = function(/* [port, host], options, cb */) {
974974
assert(typeof options.minDHSize === 'number',
975975
'options.minDHSize is not a number: ' + options.minDHSize);
976976
assert(options.minDHSize > 0,
977-
'options.minDHSize is not a posivie number: ' +
977+
'options.minDHSize is not a positive number: ' +
978978
options.minDHSize);
979979

980980
var hostname = options.servername ||

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

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ testDHE1024();
7878
assert.throws(() => test(512, true, assert.fail),
7979
/DH parameter is less than 1024 bits/);
8080

81+
[0, -1, -Infinity, NaN].forEach(minDHSize => {
82+
assert.throws(() => tls.connect({ minDHSize }),
83+
/minDHSize is not a positive number/);
84+
});
85+
86+
[true, false, null, undefined, {}, [], '', '1'].forEach(minDHSize => {
87+
assert.throws(() => tls.connect({ minDHSize }), /minDHSize is not a number/);
88+
});
89+
8190
process.on('exit', function() {
8291
assert.equal(nsuccess, 1);
8392
assert.equal(nerror, 1);

0 commit comments

Comments
 (0)