Skip to content

Commit

Permalink
add verification to reproduce exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeddada1 committed Oct 2, 2024
1 parent 97b73e7 commit c9c70e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void refresh() throws IOException {
this.wrappedCredentials.refresh();
}

@Override
public String getUniverseDomain() throws IOException {
return this.wrappedCredentials.getUniverseDomain();
}
// @Override
// public String getUniverseDomain() throws IOException {
// return this.wrappedCredentials.getUniverseDomain();
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,29 @@ void endpointResolution_builderBuilderBackToBuilder() throws IOException {
echoStubSettingsBuilder = echoStubSettings.toBuilder();
Truth.assertThat(echoStubSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint);
}

@Test
void universeDomainValidation_quotaProjectId_credentialsNonGDUMatchesUserConfiguration()
throws IOException {
String universeDomain = "random.com";
EchoSettings echoSettings =
ExtendedEchoSettings.newBuilder()
.setQuotaProjectId("exampleProject")
.setCredentialsProvider(UniverseDomainCredentialsProvider.create(universeDomain))
.setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT)
.setUniverseDomain(universeDomain)
.setTransportChannelProvider(
EchoSettings.defaultGrpcTransportProviderBuilder()
.setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
.build())
.build();
echoClient = EchoClient.create(echoSettings);

UnauthenticatedException exception =
assertThrows(UnauthenticatedException.class, () -> echoClient.echo(DEFAULT_REQUEST));
Truth.assertThat(exception.getMessage())
.contains(
"The configured universe domain (random.com) does not match the universe domain found in the credentials (googleapis.com).");
// Truth.assertThat(echoClient.echo(DEFAULT_REQUEST).getContent()).isEqualTo("echo");
}
}

0 comments on commit c9c70e5

Please sign in to comment.