@@ -639,6 +639,76 @@ test(
639639 } ,
640640) ;
641641
642+ test ( "getCredentials validates 'replaces-base' correctly" , async ( t ) => {
643+ // Valid cases.
644+ const credentialsInput = toEncodedJSON ( [
645+ {
646+ type : "maven_repository" ,
647+ host : "maven1.pkg.github.com" ,
648+ token : "abc" ,
649+ "replaces-base" : false ,
650+ } ,
651+ {
652+ type : "maven_repository" ,
653+ host : "maven2.pkg.github.com" ,
654+ token : "def" ,
655+ "replaces-base" : true ,
656+ } ,
657+ {
658+ type : "maven_repository" ,
659+ host : "maven3.pkg.github.com" ,
660+ token : "ghi" ,
661+ } ,
662+ ] ) ;
663+
664+ const credentials = startProxyExports . getCredentials (
665+ getRunnerLogger ( true ) ,
666+ undefined ,
667+ credentialsInput ,
668+ BuiltInLanguage . java ,
669+ false ,
670+ ) ;
671+
672+ t . is ( credentials . length , 3 ) ;
673+ t . true ( credentials . some ( ( c ) => c [ "replaces-base" ] === true ) ) ;
674+ t . true ( credentials . some ( ( c ) => c [ "replaces-base" ] === false ) ) ;
675+ t . true ( credentials . some ( ( c ) => c [ "replaces-base" ] === undefined ) ) ;
676+
677+ // Invalid cases.
678+ const baseInvalid = {
679+ type : "maven_repository" ,
680+ host : "maven4.pkg.github.com" ,
681+ token : "jkl" ,
682+ } ;
683+ t . throws ( ( ) =>
684+ startProxyExports . getCredentials (
685+ getRunnerLogger ( true ) ,
686+ undefined ,
687+ toEncodedJSON ( [ { ...baseInvalid , "replaces-base" : null } ] ) ,
688+ BuiltInLanguage . actions ,
689+ false ,
690+ ) ,
691+ ) ;
692+ t . throws ( ( ) =>
693+ startProxyExports . getCredentials (
694+ getRunnerLogger ( true ) ,
695+ undefined ,
696+ toEncodedJSON ( [ { ...baseInvalid , "replaces-base" : 123 } ] ) ,
697+ BuiltInLanguage . actions ,
698+ false ,
699+ ) ,
700+ ) ;
701+ t . throws ( ( ) =>
702+ startProxyExports . getCredentials (
703+ getRunnerLogger ( true ) ,
704+ undefined ,
705+ toEncodedJSON ( [ { ...baseInvalid , "replaces-base" : "true" } ] ) ,
706+ BuiltInLanguage . actions ,
707+ false ,
708+ ) ,
709+ ) ;
710+ } ) ;
711+
642712test ( "getCredentials returns all credentials for Actions when using LANGUAGE_TO_REGISTRY_TYPE" , async ( t ) => {
643713 const credentialsInput = toEncodedJSON ( mixedCredentials ) ;
644714
0 commit comments