@@ -64,12 +64,9 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
64
64
[ false , [ certStr , certStr2 ] ] ,
65
65
[ [ { pem : keyBuff } ] , false ] ,
66
66
[ [ { pem : keyBuff } , { pem : keyBuff } ] , false ]
67
- ] . map ( ( params ) => {
67
+ ] . map ( ( [ key , cert ] ) => {
68
68
assert . doesNotThrow ( ( ) => {
69
- tls . createServer ( {
70
- key : params [ 0 ] ,
71
- cert : params [ 1 ]
72
- } ) ;
69
+ tls . createServer ( { key, cert } ) ;
73
70
} ) ;
74
71
} ) ;
75
72
@@ -100,16 +97,13 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
100
97
[ [ keyStr , keyStr2 ] , [ true , false ] , invalidCertRE ] ,
101
98
[ [ keyStr , keyStr2 ] , true , invalidCertRE ] ,
102
99
[ true , [ certBuff , certBuff2 ] , invalidKeyRE ]
103
- ] . map ( ( params ) => {
100
+ ] . map ( ( [ key , cert , message ] ) => {
104
101
assert . throws ( ( ) => {
105
- tls . createServer ( {
106
- key : params [ 0 ] ,
107
- cert : params [ 1 ]
108
- } ) ;
102
+ tls . createServer ( { key, cert } ) ;
109
103
} , common . expectsError ( {
110
104
code : 'ERR_INVALID_ARG_TYPE' ,
111
105
type : TypeError ,
112
- message : params [ 2 ]
106
+ message
113
107
} ) ) ;
114
108
} ) ;
115
109
@@ -123,13 +117,9 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
123
117
[ keyBuff , certBuff , caArrBuff ] ,
124
118
[ keyBuff , certBuff , caArrDataView ] ,
125
119
[ keyBuff , certBuff , false ] ,
126
- ] . map ( ( params ) => {
120
+ ] . map ( ( [ key , cert , ca ] ) => {
127
121
assert . doesNotThrow ( ( ) => {
128
- tls . createServer ( {
129
- key : params [ 0 ] ,
130
- cert : params [ 1 ] ,
131
- ca : params [ 2 ]
132
- } ) ;
122
+ tls . createServer ( { key, cert, ca } ) ;
133
123
} ) ;
134
124
} ) ;
135
125
@@ -141,16 +131,44 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
141
131
[ keyBuff , certBuff , 1 ] ,
142
132
[ keyBuff , certBuff , true ] ,
143
133
[ keyBuff , certBuff , [ caCert , true ] ]
144
- ] . map ( ( params ) => {
134
+ ] . map ( ( [ key , cert , ca ] ) => {
145
135
assert . throws ( ( ) => {
146
- tls . createServer ( {
147
- key : params [ 0 ] ,
148
- cert : params [ 1 ] ,
149
- ca : params [ 2 ]
150
- } ) ;
136
+ tls . createServer ( { key, cert, ca } ) ;
151
137
} , common . expectsError ( {
152
138
code : 'ERR_INVALID_ARG_TYPE' ,
153
139
type : TypeError ,
154
140
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 $ /
155
141
} ) ) ;
156
142
} ) ;
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