Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Disable automatically retrieving Universe Domain from Metadata Server #3272

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.api.core.InternalApi;
import com.google.api.gax.rpc.mtls.MtlsProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.ComputeEngineCredentials;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
Expand Down Expand Up @@ -145,6 +146,11 @@ public void validateUniverseDomain(
// GDC-H has no universe domain, return
return;
}
// (TODO: b/349488459) - Disable automatic requests to MDS until 01/2025
// If MDS is required for Universe Domain, do not do any validation
if (credentials instanceof ComputeEngineCredentials) {
return;
}
String credentialsUniverseDomain = Credentials.GOOGLE_DEFAULT_UNIVERSE;
// If credentials is not NoCredentialsProvider, use the Universe Domain inside Credentials
if (credentials != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
*/
package com.google.api.gax.rpc;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.rpc.mtls.MtlsProvider;
import com.google.api.gax.rpc.testing.FakeMtlsProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.ComputeEngineCredentials;
import com.google.common.truth.Truth;
import io.grpc.Status;
import java.io.IOException;
Expand Down Expand Up @@ -437,4 +439,19 @@ void hasValidUniverseDomain_credentialsInGDU_configNonGDU() throws IOException {
UnauthenticatedException.class,
() -> endpointContext.validateUniverseDomain(credentials, statusCode));
}

// (TODO: b/349488459) - Disable automatic requests to MDS until 01/2025
// Test is to ensure that no validation is being run for ComputeEngineCredentials
@Test
void hasValidUniverseDomain_computeEngineCredentials_noValidationOnUniverseDomain()
throws IOException {
Credentials credentials = Mockito.mock(ComputeEngineCredentials.class);
Mockito.when(credentials.getUniverseDomain()).thenReturn(Credentials.GOOGLE_DEFAULT_UNIVERSE);
EndpointContext endpointContext =
defaultEndpointContextBuilder
// Set a custom Universe Domain that doesn't match
.setUniverseDomain("test.com")
.build();
assertDoesNotThrow(() -> endpointContext.validateUniverseDomain(credentials, statusCode));
}
}
Loading