@@ -120,9 +120,14 @@ const mixedCredentials = [
120120 { type : "maven_repository" , host : "maven.pkg.github.com" , token : "def" } ,
121121 { type : "nuget_feed" , host : "nuget.pkg.github.com" , token : "ghi" } ,
122122 { type : "goproxy_server" , host : "goproxy.example.com" , token : "jkl" } ,
123- { type : "git_source" , host : "github.com/github" , token : "mno" } ,
124123] ;
125124
125+ const gitSourceCredential = {
126+ type : "git_source" ,
127+ host : "github.com/github" ,
128+ token : "mno" ,
129+ } ;
130+
126131test ( "getCredentials prefers registriesCredentials over registrySecrets" , async ( t ) => {
127132 const registryCredentials = Buffer . from (
128133 JSON . stringify ( [
@@ -241,7 +246,7 @@ test("getCredentials returns all for a language when specified", async (t) => {
241246 const credentials = startProxyExports . getCredentials (
242247 getRunnerLogger ( true ) ,
243248 undefined ,
244- toEncodedJSON ( mixedCredentials ) ,
249+ toEncodedJSON ( [ ... mixedCredentials , gitSourceCredential ] ) ,
245250 BuiltInLanguage . go ,
246251 ) ;
247252 t . is ( credentials . length , 2 ) ;
@@ -284,7 +289,7 @@ test("getCredentials returns all maven_repositories for Java when specified", as
284289 host : "maven2.pkg.github.com" ,
285290 token : "token2" ,
286291 } ,
287- { type : "git_source " , host : "github.com/github" , token : "mno" } ,
292+ { type : "goproxy_server " , host : "github.com/github" , token : "mno" } ,
288293 ] ;
289294
290295 const credentials = startProxyExports . getCredentials (
@@ -624,16 +629,53 @@ test("getCredentials validates 'replaces-base' correctly", async (t) => {
624629 ) ;
625630} ) ;
626631
627- test ( "getCredentials returns no credentials for Actions" , async ( t ) => {
628- const credentialsInput = toEncodedJSON ( mixedCredentials ) ;
632+ test ( "getCredentials returns only ALWAYS_ENABLED_REGISTRY_TYPE credentials for Actions" , async ( t ) => {
633+ const credentialsInput = toEncodedJSON ( [
634+ ...mixedCredentials ,
635+ gitSourceCredential ,
636+ ] ) ;
629637
630638 const credentials = startProxyExports . getCredentials (
631639 getRunnerLogger ( true ) ,
632640 undefined ,
633641 credentialsInput ,
634642 BuiltInLanguage . actions ,
635643 ) ;
636- t . deepEqual ( credentials , [ ] ) ;
644+
645+ for ( const credential of credentials ) {
646+ t . true (
647+ startProxyExports . ALWAYS_ENABLED_REGISTRY_TYPE . some (
648+ ( ty ) => ty === credential . type ,
649+ ) ,
650+ ) ;
651+ }
652+ } ) ;
653+
654+ test ( "getCredentials always returns ALWAYS_ENABLED_REGISTRY_TYPE credentials for all languages" , async ( t ) => {
655+ const alwaysEnabledCredentials : startProxyExports . Credential [ ] = [ ] ;
656+
657+ for ( const alwaysEnabled of startProxyExports . ALWAYS_ENABLED_REGISTRY_TYPE ) {
658+ alwaysEnabledCredentials . push ( {
659+ type : alwaysEnabled ,
660+ host : `host-${ alwaysEnabled } ` ,
661+ token : `bar-${ alwaysEnabled } ` ,
662+ url : `url-${ alwaysEnabled } ` ,
663+ } ) ;
664+ }
665+
666+ const credentialsInput = toEncodedJSON ( alwaysEnabledCredentials ) ;
667+
668+ // Test all languages.
669+ for ( const language of Object . values ( BuiltInLanguage ) ) {
670+ const credentials = startProxyExports . getCredentials (
671+ getRunnerLogger ( true ) ,
672+ undefined ,
673+ credentialsInput ,
674+ language ,
675+ ) ;
676+
677+ t . deepEqual ( credentials , alwaysEnabledCredentials ) ;
678+ }
637679} ) ;
638680
639681function mockGetApiClient ( endpoints : any ) {
0 commit comments