@@ -64,12 +64,9 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
6464 [ false , [ certStr , certStr2 ] ] ,
6565 [ [ { pem : keyBuff } ] , false ] ,
6666 [ [ { pem : keyBuff } , { pem : keyBuff } ] , false ]
67- ] . map ( ( params ) => {
67+ ] . map ( ( [ key , cert ] ) => {
6868 assert . doesNotThrow ( ( ) => {
69- tls . createServer ( {
70- key : params [ 0 ] ,
71- cert : params [ 1 ]
72- } ) ;
69+ tls . createServer ( { key, cert } ) ;
7370 } ) ;
7471} ) ;
7572
@@ -100,16 +97,13 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
10097 [ [ keyStr , keyStr2 ] , [ true , false ] , invalidCertRE ] ,
10198 [ [ keyStr , keyStr2 ] , true , invalidCertRE ] ,
10299 [ true , [ certBuff , certBuff2 ] , invalidKeyRE ]
103- ] . map ( ( params ) => {
100+ ] . map ( ( [ key , cert , message ] ) => {
104101 assert . throws ( ( ) => {
105- tls . createServer ( {
106- key : params [ 0 ] ,
107- cert : params [ 1 ]
108- } ) ;
102+ tls . createServer ( { key, cert } ) ;
109103 } , common . expectsError ( {
110104 code : 'ERR_INVALID_ARG_TYPE' ,
111105 type : TypeError ,
112- message : params [ 2 ]
106+ message
113107 } ) ) ;
114108} ) ;
115109
@@ -123,13 +117,9 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
123117 [ keyBuff , certBuff , caArrBuff ] ,
124118 [ keyBuff , certBuff , caArrDataView ] ,
125119 [ keyBuff , certBuff , false ] ,
126- ] . map ( ( params ) => {
120+ ] . map ( ( [ key , cert , ca ] ) => {
127121 assert . doesNotThrow ( ( ) => {
128- tls . createServer ( {
129- key : params [ 0 ] ,
130- cert : params [ 1 ] ,
131- ca : params [ 2 ]
132- } ) ;
122+ tls . createServer ( { key, cert, ca } ) ;
133123 } ) ;
134124} ) ;
135125
@@ -141,16 +131,44 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
141131 [ keyBuff , certBuff , 1 ] ,
142132 [ keyBuff , certBuff , true ] ,
143133 [ keyBuff , certBuff , [ caCert , true ] ]
144- ] . map ( ( params ) => {
134+ ] . map ( ( [ key , cert , ca ] ) => {
145135 assert . throws ( ( ) => {
146- tls . createServer ( {
147- key : params [ 0 ] ,
148- cert : params [ 1 ] ,
149- ca : params [ 2 ]
150- } ) ;
136+ tls . createServer ( { key, cert, ca } ) ;
151137 } , common . expectsError ( {
152138 code : 'ERR_INVALID_ARG_TYPE' ,
153139 type : TypeError ,
154140 message : / ^ T h e " c a " a r g u m e n t m u s t b e o n e o f t y p e s t r i n g , B u f f e r , T y p e d A r r a y , o r D a t a V i e w $ /
155141 } ) ) ;
156142} ) ;
143+
144+ // Checks to ensure tls.createServer throws an error for CA assignment
145+ // Format ['key', 'cert', 'ca']
146+ [
147+ [ keyBuff , certBuff , true ] ,
148+ [ keyBuff , certBuff , { } ] ,
149+ [ keyBuff , certBuff , 1 ] ,
150+ [ keyBuff , certBuff , true ] ,
151+ [ keyBuff , certBuff , [ caCert , true ] ]
152+ ] . map ( ( [ key , cert , ca ] ) => {
153+ assert . throws ( ( ) => {
154+ tls . createServer ( { key, cert, ca } ) ;
155+ } , common . expectsError ( {
156+ code : 'ERR_INVALID_ARG_TYPE' ,
157+ type : TypeError ,
158+ message : / ^ T h e " c a " a r g u m e n t m u s t b e o n e o f t y p e s t r i n g , B u f f e r , T y p e d A r r a y , o r D a t a V i e w $ /
159+ } ) ) ;
160+ } ) ;
161+
162+ // Checks to ensure tls.createSecureContext works with false-y input
163+ // Format ['key', 'cert', 'ca']
164+ [
165+ [ null , null , null ] ,
166+ [ false , false , false ] ,
167+ [ undefined , undefined , undefined ] ,
168+ [ '' , '' , '' ] ,
169+ [ 0 , 0 , 0 ]
170+ ] . map ( ( [ key , cert , ca ] ) => {
171+ assert . doesNotThrow ( ( ) => {
172+ tls . createSecureContext ( { key, cert, ca } ) ;
173+ } ) ;
174+ } ) ;
0 commit comments