@@ -210,7 +210,55 @@ describe('Testing binary wrapper', () => {
210
210
} ) ;
211
211
212
212
describe ( 'Testing binary bootstrapper' , ( ) => {
213
- it ( 'downloadExecutable() succesfull' , async ( ) => {
213
+ let originalEnv ;
214
+
215
+ beforeEach ( ( ) => {
216
+ jest . resetModules ( ) ;
217
+ originalEnv = { ...process . env } ; // Shallow copy is usually sufficient
218
+ } ) ;
219
+
220
+ afterEach ( ( ) => {
221
+ process . env = originalEnv ; // Restore original
222
+ } ) ;
223
+
224
+ it ( 'considers proxy settings during download' , async ( ) => {
225
+ const binaryName = 'snyk-macos' ;
226
+ const shafileExtension = '.sha256' ;
227
+ const config = new common . WrapperConfiguration ( '1.1080.0' , binaryName , '' ) ;
228
+ const shasumFile =
229
+ config . getLocalLocation ( ) + Math . random ( ) + shafileExtension ;
230
+
231
+ // case: no proxy specified
232
+ const shasumDownloadNoProxy = await common . downloadExecutable (
233
+ config . getDownloadLocations ( ) . downloadUrl + shafileExtension ,
234
+ shasumFile ,
235
+ '' ,
236
+ ) ;
237
+ expect ( shasumDownloadNoProxy ) . toBeUndefined ( ) ;
238
+
239
+ // case: proxy specified
240
+ // setting a non-existing proxy should make the download fail
241
+ process . env [ 'HTTPS_PROXY' ] = 'http://127.0.0.1:1234' ;
242
+ const shasumDownloadProxy = await common . downloadExecutable (
243
+ config . getDownloadLocations ( ) . downloadUrl + shafileExtension ,
244
+ shasumFile ,
245
+ '' ,
246
+ ) ;
247
+ expect ( shasumDownloadProxy ) . toBeDefined ( ) ;
248
+
249
+ // case: proxy specified but no_proxy as well
250
+ // setting a non-existing proxy should make the download fail
251
+ process . env [ 'HTTPS_PROXY' ] = 'http://127.0.0.1:1234' ;
252
+ process . env [ 'NO_PROXY' ] = '*.snyk.io' ;
253
+ const shasumDownloadProxyNoProxy = await common . downloadExecutable (
254
+ config . getDownloadLocations ( ) . downloadUrl + shafileExtension ,
255
+ shasumFile ,
256
+ '' ,
257
+ ) ;
258
+ expect ( shasumDownloadProxyNoProxy ) . toBeUndefined ( ) ;
259
+ } ) ;
260
+
261
+ it ( 'downloadExecutable() successful' , async ( ) => {
214
262
const binaryName = 'snyk-macos' ;
215
263
const shafileExtension = '.sha256' ;
216
264
const config = new common . WrapperConfiguration ( '1.1080.0' , binaryName , '' ) ;
@@ -252,7 +300,7 @@ describe('Testing binary bootstrapper', () => {
252
300
fs . unlinkSync ( shasumFile ) ;
253
301
fs . unlinkSync ( config . getLocalLocation ( ) ) ;
254
302
} ) ;
255
- it ( 'downloadWithBackup() succesfull ' , async ( ) => {
303
+ it ( 'downloadWithBackup() successful ' , async ( ) => {
256
304
const binaryName = 'snyk-macos' ;
257
305
const shafileExtension = '.sha256' ;
258
306
const config = new common . WrapperConfiguration ( '1.1080.0' , binaryName , '' ) ;
@@ -305,7 +353,7 @@ describe('Testing binary bootstrapper', () => {
305
353
config . getLocalLocation ( ) + Math . random ( ) + shafileExtension ;
306
354
const { downloadUrl } = config . getDownloadLocations ( ) ;
307
355
308
- // download just any file and state a shasum expectation that never can be fullfilled
356
+ // download just any file and state a shasum expectation that never can be fulfilled
309
357
const shasumDownload = await common . downloadExecutable (
310
358
downloadUrl + shafileExtension ,
311
359
shasumFile ,
@@ -336,7 +384,7 @@ describe('Testing binary bootstrapper', () => {
336
384
} ) ;
337
385
338
386
it ( 'downloadExecutable() fails due to an error in the https connection' , async ( ) => {
339
- // download the just any file and state a shasum expectation that never can be fullfilled
387
+ // download the just any file and state a shasum expectation that never can be fulfilled
340
388
const shasumDownload = await common . downloadExecutable (
341
389
'https://notaurl' ,
342
390
'' ,
0 commit comments