@@ -440,16 +440,17 @@ test("getCredentials accepts OIDC configurations", (t) => {
440440} ) ;
441441
442442const testPATWarning = test . macro ( {
443- exec : async ( t : ExecutionContext < unknown > ) => {
443+ exec : async (
444+ t : ExecutionContext < unknown > ,
445+ credentials : startProxyExports . RawCredential [ ] ,
446+ checkAccepted : (
447+ t : ExecutionContext < unknown > ,
448+ results : startProxyExports . Credential [ ] ,
449+ ) => void ,
450+ ) => {
444451 const loggedMessages = [ ] ;
445452 const logger = getRecordingLogger ( loggedMessages ) ;
446- const likelyWrongCredentials = toEncodedJSON ( [
447- {
448- type : "git_server" ,
449- host : "https://github.com/" ,
450- password : `ghp_${ makeTestToken ( ) } ` ,
451- } ,
452- ] ) ;
453+ const likelyWrongCredentials = toEncodedJSON ( credentials ) ;
453454
454455 const results = startProxyExports . getCredentials (
455456 logger ,
@@ -458,17 +459,7 @@ const testPATWarning = test.macro({
458459 undefined ,
459460 ) ;
460461
461- // The configuration should be accepted, despite the likely problem.
462- t . assert ( results ) ;
463- t . is ( results . length , 1 ) ;
464- t . is ( results [ 0 ] . type , "git_server" ) ;
465- t . is ( results [ 0 ] . host , "https://github.com/" ) ;
466-
467- if ( startProxyExports . isUsernamePassword ( results [ 0 ] ) ) {
468- t . assert ( results [ 0 ] . password ?. startsWith ( "ghp_" ) ) ;
469- } else {
470- t . fail ( "Expected a `UsernamePassword`-based credential." ) ;
471- }
462+ checkAccepted ( t , results ) ;
472463
473464 // A warning should have been logged.
474465 checkExpectedLogMessages ( t , loggedMessages , [
@@ -480,7 +471,30 @@ const testPATWarning = test.macro({
480471 `getCredentials logs a warning when a PAT is used - ${ providedTitle } ` ,
481472} ) ;
482473
483- test ( "password without a username" , testPATWarning ) ;
474+ test (
475+ "password without a username" ,
476+ testPATWarning ,
477+ [
478+ {
479+ type : "git_server" ,
480+ host : "https://github.com/" ,
481+ password : `ghp_${ makeTestToken ( ) } ` ,
482+ } ,
483+ ] ,
484+ ( t , results ) => {
485+ // The configurations should be accepted, despite the likely problem.
486+ t . assert ( results ) ;
487+ t . is ( results . length , 1 ) ;
488+ t . is ( results [ 0 ] . type , "git_server" ) ;
489+ t . is ( results [ 0 ] . host , "https://github.com/" ) ;
490+
491+ if ( startProxyExports . isUsernamePassword ( results [ 0 ] ) ) {
492+ t . assert ( results [ 0 ] . password ?. startsWith ( "ghp_" ) ) ;
493+ } else {
494+ t . fail ( "Expected a `UsernamePassword`-based credential." ) ;
495+ }
496+ } ,
497+ ) ;
484498
485499test ( "getCredentials returns all credentials for Actions when using LANGUAGE_TO_REGISTRY_TYPE" , async ( t ) => {
486500 const credentialsInput = toEncodedJSON ( mixedCredentials ) ;
0 commit comments