Skip to content

Commit b849850

Browse files
committed
additional verification for empty domain
1 parent 72a4313 commit b849850

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gax-java/gax/src/test/java/com/google/api/gax/core/GoogleCredentialsProviderTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ void serviceAccountReplacedWithJwtTokens() throws Exception {
7171
assertThat(jwtCreds.getUniverseDomain()).isEqualTo(Credentials.GOOGLE_DEFAULT_UNIVERSE);
7272
}
7373

74+
@Test
75+
void serviceAccountReplacedWithJwtTokens_setEmptyDomain() throws Exception {
76+
ServiceAccountCredentials serviceAccountCredentials =
77+
CreateServiceAccountCredentials().toBuilder().setUniverseDomain("").build();
78+
79+
GoogleCredentialsProvider provider =
80+
GoogleCredentialsProvider.newBuilder()
81+
.setScopesToApply(ImmutableList.of("scope1", "scope2"))
82+
.setJwtEnabledScopes(ImmutableList.of("scope1"))
83+
.setOAuth2Credentials(serviceAccountCredentials)
84+
.build();
85+
86+
Credentials credentials = provider.getCredentials();
87+
assertThat(credentials).isInstanceOf(ServiceAccountJwtAccessCredentials.class);
88+
ServiceAccountJwtAccessCredentials jwtCreds = (ServiceAccountJwtAccessCredentials) credentials;
89+
assertThat(jwtCreds.getClientId()).isEqualTo(serviceAccountCredentials.getClientId());
90+
assertThat(jwtCreds.getClientEmail()).isEqualTo(serviceAccountCredentials.getClientEmail());
91+
assertThat(jwtCreds.getPrivateKeyId()).isEqualTo(serviceAccountCredentials.getPrivateKeyId());
92+
assertThat(jwtCreds.getPrivateKey()).isEqualTo(serviceAccountCredentials.getPrivateKey());
93+
assertThat(jwtCreds.getUniverseDomain()).isEqualTo(Credentials.GOOGLE_DEFAULT_UNIVERSE);
94+
}
95+
7496
@Test
7597
void serviceAccountReplacedWithJwtTokens_customUniverseDomain() throws Exception {
7698
ServiceAccountCredentials serviceAccountCredentials =

0 commit comments

Comments
 (0)