@@ -210,7 +210,55 @@ describe('Testing binary wrapper', () => {
210210} ) ;
211211
212212describe ( '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 ( 'Test that proxy settings are considered 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 ( ) => {
214262 const binaryName = 'snyk-macos' ;
215263 const shafileExtension = '.sha256' ;
216264 const config = new common . WrapperConfiguration ( '1.1080.0' , binaryName , '' ) ;
@@ -252,7 +300,7 @@ describe('Testing binary bootstrapper', () => {
252300 fs . unlinkSync ( shasumFile ) ;
253301 fs . unlinkSync ( config . getLocalLocation ( ) ) ;
254302 } ) ;
255- it ( 'downloadWithBackup() succesfull ' , async ( ) => {
303+ it ( 'downloadWithBackup() successful ' , async ( ) => {
256304 const binaryName = 'snyk-macos' ;
257305 const shafileExtension = '.sha256' ;
258306 const config = new common . WrapperConfiguration ( '1.1080.0' , binaryName , '' ) ;
@@ -305,7 +353,7 @@ describe('Testing binary bootstrapper', () => {
305353 config . getLocalLocation ( ) + Math . random ( ) + shafileExtension ;
306354 const { downloadUrl } = config . getDownloadLocations ( ) ;
307355
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
309357 const shasumDownload = await common . downloadExecutable (
310358 downloadUrl + shafileExtension ,
311359 shasumFile ,
@@ -336,7 +384,7 @@ describe('Testing binary bootstrapper', () => {
336384 } ) ;
337385
338386 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
340388 const shasumDownload = await common . downloadExecutable (
341389 'https://notaurl' ,
342390 '' ,
0 commit comments