@@ -121,7 +121,7 @@ test('Returns user config via alternative environment variables with https proxy
121121 const gitlabApiPathPrefix = '/api/prefix' ;
122122 const assets = [ 'file.js' ] ;
123123 // Testing with 8443 port because HttpsProxyAgent ignores 443 port with https protocol
124- const proxyUrl = 'https ://proxy.test:8443' ;
124+ const proxyUrl = 'http ://proxy.test:8443' ;
125125
126126 const result = resolveConfig (
127127 { assets} ,
@@ -146,8 +146,6 @@ test('Returns user config via alternative environment variables with mismatching
146146 const gitlabApiPathPrefix = '/api/prefix' ;
147147 const assets = [ 'file.js' ] ;
148148 // Testing with 8443 port because HttpsProxyAgent ignores 443 port with https protocol
149- const httpProxyUrl = 'http://proxy.test:8443' ;
150- const proxyUrl = 'https://proxy.test:8443' ;
151149
152150 // HTTP GitLab URL and HTTPS_PROXY set
153151 t . deepEqual (
@@ -158,7 +156,7 @@ test('Returns user config via alternative environment variables with mismatching
158156 GL_TOKEN : gitlabToken ,
159157 GL_URL : httpGitlabUrl ,
160158 GL_PREFIX : gitlabApiPathPrefix ,
161- HTTPS_PROXY : proxyUrl ,
159+ HTTPS_PROXY : 'https://proxy.test:8443' ,
162160 } ,
163161 }
164162 ) ,
@@ -180,7 +178,7 @@ test('Returns user config via alternative environment variables with mismatching
180178 GL_TOKEN : gitlabToken ,
181179 GL_URL : gitlabUrl ,
182180 GL_PREFIX : gitlabApiPathPrefix ,
183- HTTP_PROXY : httpProxyUrl ,
181+ HTTP_PROXY : 'http://proxy.test:8443' ,
184182 } ,
185183 }
186184 ) ,
@@ -193,6 +191,100 @@ test('Returns user config via alternative environment variables with mismatching
193191 }
194192 ) ;
195193} ) ;
194+ test ( 'Returns user config via environment variables with HTTP_PROXY and NO_PROXY set' , t => {
195+ const gitlabToken = 'TOKEN' ;
196+ const gitlabUrl = 'http://host.com' ;
197+ const gitlabApiPathPrefix = '/api/prefix' ;
198+ const assets = [ 'file.js' ] ;
199+ // Testing with 8080 port because HttpsProxyAgent ignores 80 port with http protocol
200+ const proxyUrl = 'http://proxy.test:8080' ;
201+
202+ const result = resolveConfig (
203+ { assets} ,
204+ {
205+ env : {
206+ GL_TOKEN : gitlabToken ,
207+ GL_URL : gitlabUrl ,
208+ GL_PREFIX : gitlabApiPathPrefix ,
209+ HTTP_PROXY : proxyUrl ,
210+ NO_PROXY : '*.host.com, host.com' ,
211+ } ,
212+ }
213+ ) ;
214+
215+ t . deepEqual ( result . proxy , { } ) ;
216+ } ) ;
217+
218+ test ( 'Returns user config via environment variables with HTTPS_PROXY and NO_PROXY set' , t => {
219+ const gitlabToken = 'TOKEN' ;
220+ const gitlabUrl = 'https://host.com' ;
221+ const gitlabApiPathPrefix = '/api/prefix' ;
222+ const assets = [ 'file.js' ] ;
223+ // Testing with 8080 port because HttpsProxyAgent ignores 80 port with http protocol
224+ const proxyUrl = 'http://proxy.test:8080' ;
225+
226+ const result = resolveConfig (
227+ { assets} ,
228+ {
229+ env : {
230+ GL_TOKEN : gitlabToken ,
231+ GL_URL : gitlabUrl ,
232+ GL_PREFIX : gitlabApiPathPrefix ,
233+ HTTPS_PROXY : proxyUrl ,
234+ NO_PROXY : '*.host.com, host.com' ,
235+ } ,
236+ }
237+ ) ;
238+ t . deepEqual ( result . proxy , { } ) ;
239+ } ) ;
240+
241+ test ( 'Returns user config via environment variables with HTTPS_PROXY and non-matching NO_PROXY set' , t => {
242+ const gitlabToken = 'TOKEN' ;
243+ const gitlabUrl = 'https://host.com' ;
244+ const gitlabApiPathPrefix = '/api/prefix' ;
245+ const assets = [ 'file.js' ] ;
246+ // Testing with 8443 port because HttpsProxyAgent ignores 443 port with http protocol
247+ const proxyUrl = 'https://proxy.test:8443' ;
248+ process . env . HTTPS_PROXY = proxyUrl ;
249+ process . env . NO_PROXY = '*.differenthost.com, differenthost.com' ;
250+
251+ const result = resolveConfig (
252+ { assets} ,
253+ {
254+ env : {
255+ GL_TOKEN : gitlabToken ,
256+ GL_URL : gitlabUrl ,
257+ GL_PREFIX : gitlabApiPathPrefix ,
258+ HTTPS_PROXY : proxyUrl ,
259+ NO_PROXY : '*.differenthost.com, differenthost.com' ,
260+ } ,
261+ }
262+ ) ;
263+ t . assert ( result . proxy . agent . https instanceof HttpsProxyAgent ) ;
264+ } ) ;
265+
266+ test ( 'Returns user config via environment variables with HTTP_PROXY and non-matching NO_PROXY set' , t => {
267+ const gitlabToken = 'TOKEN' ;
268+ const gitlabUrl = 'http://host.com' ;
269+ const gitlabApiPathPrefix = '/api/prefix' ;
270+ const assets = [ 'file.js' ] ;
271+ // Testing with 8080 port because HttpsProxyAgent ignores 80 port with http protocol
272+ const proxyUrl = 'http://proxy.test:8080' ;
273+
274+ const result = resolveConfig (
275+ { assets} ,
276+ {
277+ env : {
278+ GL_TOKEN : gitlabToken ,
279+ GL_URL : gitlabUrl ,
280+ GL_PREFIX : gitlabApiPathPrefix ,
281+ HTTP_PROXY : proxyUrl ,
282+ NO_PROXY : '*.differenthost.com, differenthost.com' ,
283+ } ,
284+ }
285+ ) ;
286+ t . assert ( result . proxy . agent . http instanceof HttpProxyAgent ) ;
287+ } ) ;
196288
197289test ( 'Returns default config' , t => {
198290 const gitlabToken = 'TOKEN' ;
0 commit comments