@@ -631,7 +631,7 @@ void testIsValidUniverseDomain_userUniverseDomainConfig_nonGDUCredentials() thro
631631 }
632632
633633 @ Test
634- void testGetScopedCredentials_enablesSelfSignedJwtForServiceAccount () {
634+ void testGetScopedCredentials_useJwtAccessWithScope_enablesByDefault () {
635635 TestServiceOptions options =
636636 TestServiceOptions .newBuilder ()
637637 .setProjectId ("project-id" )
@@ -643,7 +643,7 @@ void testGetScopedCredentials_enablesSelfSignedJwtForServiceAccount() {
643643 }
644644
645645 @ Test
646- void testGetScopedCredentials_optsOutSelfSignedJwt () {
646+ void testGetScopedCredentials_useJwtAccessWithScope_canBeDisabled () {
647647 TestServiceOptions options =
648648 new TestServiceOptions .Builder ()
649649 .setProjectId ("project-id" )
@@ -655,6 +655,21 @@ void testGetScopedCredentials_optsOutSelfSignedJwt() {
655655 assertThat (((ServiceAccountCredentials ) scoped ).getUseJwtAccessWithScope ()).isFalse ();
656656 }
657657
658+ @ Test
659+ void testGetScopedCredentials_useJwtAccessWithScope_overridesCredentials () {
660+ ServiceAccountCredentials trueCredentials =
661+ ((ServiceAccountCredentials ) credentials ).createWithUseJwtAccessWithScope (true );
662+ TestServiceOptions options =
663+ new TestServiceOptions .Builder ()
664+ .setProjectId ("project-id" )
665+ .setCredentials (trueCredentials )
666+ .setUseJwtAccessWithScope (false )
667+ .build ();
668+ com .google .auth .Credentials scoped = options .getScopedCredentials ();
669+ assertThat (scoped ).isInstanceOf (ServiceAccountCredentials .class );
670+ assertThat (((ServiceAccountCredentials ) scoped ).getUseJwtAccessWithScope ()).isFalse ();
671+ }
672+
658673 private HttpResponse createHttpResponseWithHeader (final Multimap <String , String > headers )
659674 throws Exception {
660675 HttpTransport mockHttpTransport =
0 commit comments