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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ exports.connect = function(/* [port, host], options, cb */){
974974
assert(typeofoptions.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
varhostname=options.servername||

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ testDHE1024();
7878
assert.throws(()=>test(512,true,assert.fail),
7979
/DHparameterislessthan1024bits/);
8080

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

0 commit comments

Comments
(0)