Skip to content

Commit c9c70e5

Browse files
committed
add verification to reproduce exception
1 parent 97b73e7 commit c9c70e5

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

gax-java/gax/src/main/java/com/google/api/gax/rpc/internal/QuotaProjectIdHidingCredentials.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public void refresh() throws IOException {
9090
this.wrappedCredentials.refresh();
9191
}
9292

93-
@Override
94-
public String getUniverseDomain() throws IOException {
95-
return this.wrappedCredentials.getUniverseDomain();
96-
}
93+
// @Override
94+
// public String getUniverseDomain() throws IOException {
95+
// return this.wrappedCredentials.getUniverseDomain();
96+
// }
9797
}

showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java

+25
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,29 @@ void endpointResolution_builderBuilderBackToBuilder() throws IOException {
444444
echoStubSettingsBuilder = echoStubSettings.toBuilder();
445445
Truth.assertThat(echoStubSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint);
446446
}
447+
448+
@Test
449+
void universeDomainValidation_quotaProjectId_credentialsNonGDUMatchesUserConfiguration()
450+
throws IOException {
451+
String universeDomain = "random.com";
452+
EchoSettings echoSettings =
453+
ExtendedEchoSettings.newBuilder()
454+
.setQuotaProjectId("exampleProject")
455+
.setCredentialsProvider(UniverseDomainCredentialsProvider.create(universeDomain))
456+
.setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT)
457+
.setUniverseDomain(universeDomain)
458+
.setTransportChannelProvider(
459+
EchoSettings.defaultGrpcTransportProviderBuilder()
460+
.setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
461+
.build())
462+
.build();
463+
echoClient = EchoClient.create(echoSettings);
464+
465+
UnauthenticatedException exception =
466+
assertThrows(UnauthenticatedException.class, () -> echoClient.echo(DEFAULT_REQUEST));
467+
Truth.assertThat(exception.getMessage())
468+
.contains(
469+
"The configured universe domain (random.com) does not match the universe domain found in the credentials (googleapis.com).");
470+
// Truth.assertThat(echoClient.echo(DEFAULT_REQUEST).getContent()).isEqualTo("echo");
471+
}
447472
}

0 commit comments

Comments
 (0)