@@ -131,6 +131,48 @@ describe('HTTP Node Utils', () => {
131131 } ,
132132 } ) ;
133133 } ) ;
134+
135+ it ( 'should keep a passphrase containing whitespace unchanged' , async ( ) => {
136+ const requestOptions : IRequestOptions = {
137+ method : 'GET' ,
138+ uri : 'https://example.com' ,
139+ } ;
140+
141+ const sslCertificates = {
142+ passphrase : 'my secret key' ,
143+ } ;
144+
145+ setAgentOptions ( requestOptions , sslCertificates ) ;
146+
147+ expect ( requestOptions ) . toStrictEqual ( {
148+ method : 'GET' ,
149+ uri : 'https://example.com' ,
150+ agentOptions : {
151+ passphrase : 'my secret key' ,
152+ } ,
153+ } ) ;
154+ } ) ;
155+
156+ it ( 'should wrap compact PEM certificates but not the passphrase' , async ( ) => {
157+ const requestOptions : IRequestOptions = {
158+ method : 'GET' ,
159+ uri : 'https://example.com' ,
160+ } ;
161+
162+ const sslCertificates = {
163+ cert : `-----BEGIN CERTIFICATE-----${ 'A' . repeat ( 70 ) } -----END CERTIFICATE-----` ,
164+ key : `-----BEGIN PRIVATE KEY-----${ 'B' . repeat ( 70 ) } -----END PRIVATE KEY-----` ,
165+ passphrase : 'my secret key' ,
166+ } ;
167+
168+ setAgentOptions ( requestOptions , sslCertificates ) ;
169+
170+ expect ( requestOptions . agentOptions ) . toStrictEqual ( {
171+ cert : `-----BEGIN CERTIFICATE-----\n${ 'A' . repeat ( 64 ) } \n${ 'A' . repeat ( 6 ) } \n-----END CERTIFICATE-----` ,
172+ key : `-----BEGIN PRIVATE KEY-----\n${ 'B' . repeat ( 64 ) } \n${ 'B' . repeat ( 6 ) } \n-----END PRIVATE KEY-----` ,
173+ passphrase : 'my secret key' ,
174+ } ) ;
175+ } ) ;
134176 } ) ;
135177
136178 describe ( 'sanitizeUiMessage' , ( ) => {
0 commit comments