@@ -479,6 +479,69 @@ describe('setup-node', () => {
479479 expect ( addPathSpy ) . toHaveBeenCalledWith ( expPath ) ;
480480 } ) ;
481481
482+ it ( 'sends GitHub token to GitHub manifest and release downloads when mirror and mirror-token are set' , async ( ) => {
483+ os . platform = 'linux' ;
484+ os . arch = 'x64' ;
485+
486+ const versionSpec = '12.16.2' ;
487+ inputs [ 'node-version' ] = versionSpec ;
488+ inputs [ 'token' ] = 'github-secret-token' ;
489+ inputs [ 'mirror' ] = 'https://my_mirror_url' ;
490+ inputs [ 'mirror-token' ] = 'mirror-secret-token' ;
491+
492+ findSpy . mockImplementation ( ( ) => '' ) ;
493+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
494+ const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
495+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
496+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
497+
498+ await main . run ( ) ;
499+
500+ expect ( getManifestSpy ) . toHaveBeenCalledWith (
501+ 'actions' ,
502+ 'node-versions' ,
503+ 'token github-secret-token' ,
504+ 'main'
505+ ) ;
506+ expect ( dlSpy ) . toHaveBeenCalledWith (
507+ 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz' ,
508+ undefined ,
509+ 'token github-secret-token'
510+ ) ;
511+ } ) ;
512+
513+ it ( 'sends GitHub token to manifest and mirror-token to mirror when falling back to mirror' , async ( ) => {
514+ os . platform = 'linux' ;
515+ os . arch = 'x64' ;
516+
517+ const versionSpec = '11.15.0' ;
518+ const mirror = 'https://my_mirror_url' ;
519+ inputs [ 'node-version' ] = versionSpec ;
520+ inputs [ 'token' ] = 'github-secret-token' ;
521+ inputs [ 'mirror' ] = mirror ;
522+ inputs [ 'mirror-token' ] = 'mirror-secret-token' ;
523+
524+ findSpy . mockImplementation ( ( ) => '' ) ;
525+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
526+ const toolPath = path . normalize ( '/cache/node/11.15.0/x64' ) ;
527+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
528+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
529+
530+ await main . run ( ) ;
531+
532+ expect ( getManifestSpy ) . toHaveBeenCalledWith (
533+ 'actions' ,
534+ 'node-versions' ,
535+ 'token github-secret-token' ,
536+ 'main'
537+ ) ;
538+ expect ( dlSpy ) . toHaveBeenCalledWith (
539+ `${ mirror } /dist/v11.15.0/node-v11.15.0-linux-x64.tar.gz` ,
540+ undefined ,
541+ 'mirror-secret-token'
542+ ) ;
543+ } ) ;
544+
482545 it ( 'falls back to a version from node dist' , async ( ) => {
483546 os . platform = 'linux' ;
484547 os . arch = 'x64' ;
0 commit comments