@@ -415,6 +415,92 @@ void refreshAccessToken_workforceWithServiceAccountImpersonation() throws IOExce
415415 assertEquals (expectedInternalOptions .toString (), query .get ("options" ));
416416 }
417417
418+ @ Test
419+ void identityPoolCredentialSource_validFormats () {
420+ Map <String , Object > credentialSourceMapWithFileTextSource = new HashMap <>();
421+ Map <String , Object > credentialSourceMapWithFileJsonTextSource = new HashMap <>();
422+ Map <String , Object > credentialSourceMapWithUrlTextSource = new HashMap <>();
423+ Map <String , Object > credentialSourceMapWithUrlJsonTextSource = new HashMap <>();
424+
425+ credentialSourceMapWithFileTextSource .put ("file" , "/path/to/file" );
426+ credentialSourceMapWithFileJsonTextSource .put ("file" , "/path/to/file" );
427+
428+ credentialSourceMapWithUrlTextSource .put ("url" , "https://google.com" );
429+ credentialSourceMapWithUrlJsonTextSource .put ("url" , "https://google.com" );
430+ Map <String , String > headersMap = new HashMap <>();
431+ headersMap .put ("header1" , "value1" );
432+ headersMap .put ("header2" , "value2" );
433+ credentialSourceMapWithUrlTextSource .put ("headers" , headersMap );
434+ credentialSourceMapWithUrlJsonTextSource .put ("headers" , headersMap );
435+
436+ Map <String , String > textFormat = new HashMap <>();
437+ textFormat .put ("type" , "text" );
438+
439+ Map <String , String > jsonTextFormat = new HashMap <>();
440+ jsonTextFormat .put ("type" , "json" );
441+ jsonTextFormat .put ("subject_token_field_name" , "access_token" );
442+
443+ credentialSourceMapWithFileTextSource .put ("format" , textFormat );
444+ credentialSourceMapWithFileJsonTextSource .put ("format" , jsonTextFormat );
445+
446+ credentialSourceMapWithUrlTextSource .put ("format" , textFormat );
447+ credentialSourceMapWithUrlJsonTextSource .put ("format" , jsonTextFormat );
448+
449+ List <Map <String , Object >> sources =
450+ Arrays .asList (
451+ credentialSourceMapWithFileTextSource ,
452+ credentialSourceMapWithFileJsonTextSource ,
453+ credentialSourceMapWithUrlTextSource ,
454+ credentialSourceMapWithUrlJsonTextSource );
455+ for (Map <String , Object > source : sources ) {
456+ // Should not throw.
457+ new IdentityPoolCredentialSource (source );
458+ }
459+ }
460+
461+ @ Test
462+ void identityPoolCredentialSource_caseInsensitive () {
463+ Map <String , Object > credentialSourceMapWithFileTextSource = new HashMap <>();
464+ Map <String , Object > credentialSourceMapWithFileJsonTextSource = new HashMap <>();
465+ Map <String , Object > credentialSourceMapWithUrlTextSource = new HashMap <>();
466+ Map <String , Object > credentialSourceMapWithUrlJsonTextSource = new HashMap <>();
467+
468+ credentialSourceMapWithFileTextSource .put ("file" , "/path/to/file" );
469+ credentialSourceMapWithFileJsonTextSource .put ("file" , "/path/to/file" );
470+
471+ credentialSourceMapWithUrlTextSource .put ("url" , "https://google.com" );
472+ credentialSourceMapWithUrlJsonTextSource .put ("url" , "https://google.com" );
473+ Map <String , String > headersMap = new HashMap <>();
474+ headersMap .put ("HeaDer1" , "Value1" );
475+ headersMap .put ("HeaDer2" , "Value2" );
476+ credentialSourceMapWithUrlTextSource .put ("headers" , headersMap );
477+ credentialSourceMapWithUrlJsonTextSource .put ("headers" , headersMap );
478+
479+ Map <String , String > textFormat = new HashMap <>();
480+ textFormat .put ("type" , "TEXT" );
481+
482+ Map <String , String > jsonTextFormat = new HashMap <>();
483+ jsonTextFormat .put ("type" , "JSON" );
484+ jsonTextFormat .put ("subject_token_field_name" , "access_token" );
485+
486+ credentialSourceMapWithFileTextSource .put ("format" , textFormat );
487+ credentialSourceMapWithFileJsonTextSource .put ("format" , jsonTextFormat );
488+
489+ credentialSourceMapWithUrlTextSource .put ("format" , textFormat );
490+ credentialSourceMapWithUrlJsonTextSource .put ("format" , jsonTextFormat );
491+
492+ List <Map <String , Object >> sources =
493+ Arrays .asList (
494+ credentialSourceMapWithFileTextSource ,
495+ credentialSourceMapWithFileJsonTextSource ,
496+ credentialSourceMapWithUrlTextSource ,
497+ credentialSourceMapWithUrlJsonTextSource );
498+ for (Map <String , Object > source : sources ) {
499+ // Should not throw.
500+ new IdentityPoolCredentialSource (source );
501+ }
502+ }
503+
418504 @ Test
419505 void identityPoolCredentialSource_invalidSourceType () {
420506 IllegalArgumentException exception =
0 commit comments