diff --git a/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java b/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java index bb1a569abf..b34451bcf9 100644 --- a/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java +++ b/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java @@ -30,6 +30,7 @@ import static org.mockito.Mockito.when; import com.google.auth.Credentials; import com.google.auth.RequestMetadataCallback; +import com.google.auth.http.HttpTransportFactory; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.auth.oauth2.OAuth2Credentials; @@ -67,6 +68,7 @@ import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; @@ -252,7 +254,7 @@ public class GoogleAuthLibraryCallCredentialsTest { @Test public void oauth2Credential() { final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE)); - final OAuth2Credentials credentials = new OAuth2Credentials() { + OAuth2Credentials credentials = new OAuth2Credentials() { @Override public AccessToken refreshAccessToken() throws IOException { return token; @@ -323,14 +325,17 @@ public class GoogleAuthLibraryCallCredentialsTest { @Test public void serviceAccountToJwt() throws Exception { KeyPair pair = KeyPairGenerator.getInstance("RSA").generateKeyPair(); - @SuppressWarnings("deprecation") - ServiceAccountCredentials credentials = new ServiceAccountCredentials( - null, "email@example.com", pair.getPrivate(), null, null) { - @Override - public AccessToken refreshAccessToken() { - throw new AssertionError(); - } - }; + + HttpTransportFactory factory = Mockito.mock(HttpTransportFactory.class); + Mockito.when(factory.create()).thenThrow(new AssertionError()); + + ServiceAccountCredentials credentials = + ServiceAccountCredentials.newBuilder() + .setClientEmail("test-email@example.com") + .setPrivateKey(pair.getPrivate()) + .setPrivateKeyId("test-private-key-id") + .setHttpTransportFactory(factory) + .build(); GoogleAuthLibraryCallCredentials callCredentials = new GoogleAuthLibraryCallCredentials(credentials); @@ -346,31 +351,6 @@ public class GoogleAuthLibraryCallCredentialsTest { assertTrue(authorization[0], authorization[0].length() > 300); } - @Test - public void serviceAccountWithScopeNotToJwt() throws Exception { - final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE)); - KeyPair pair = KeyPairGenerator.getInstance("RSA").generateKeyPair(); - @SuppressWarnings("deprecation") - ServiceAccountCredentials credentials = new ServiceAccountCredentials( - null, "email@example.com", pair.getPrivate(), null, Arrays.asList("somescope")) { - @Override - public AccessToken refreshAccessToken() { - return token; - } - }; - - GoogleAuthLibraryCallCredentials callCredentials = - new GoogleAuthLibraryCallCredentials(credentials); - callCredentials.applyRequestMetadata(new RequestInfoImpl(), executor, applier); - assertEquals(1, runPendingRunnables()); - - verify(applier).apply(headersCaptor.capture()); - Metadata headers = headersCaptor.getValue(); - Iterable authorization = headers.getAll(AUTHORIZATION); - assertArrayEquals(new String[]{"Bearer allyourbase"}, - Iterables.toArray(authorization, String.class)); - } - @Test public void oauthClassesNotInClassPath() throws Exception { ListMultimap values = LinkedListMultimap.create(); diff --git a/build.gradle b/build.gradle index 410ce31754..884c5250c1 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ subprojects { javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix" nettyVersion = '4.1.38.Final' - googleauthVersion = '0.13.0' - guavaVersion = '26.0-android' + guavaVersion = '28.1-android' + googleauthVersion = '0.17.1' protobufVersion = '3.9.0' protocVersion = protobufVersion opencensusVersion = '0.21.0' diff --git a/repositories.bzl b/repositories.bzl index 66ed0b9ac5..82f7a59a77 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -196,18 +196,18 @@ def com_google_api_grpc_google_common_protos(): def com_google_auth_google_auth_library_credentials(): jvm_maven_import_external( name = "com_google_auth_google_auth_library_credentials", - artifact = "com.google.auth:google-auth-library-credentials:0.9.0", + artifact = "com.google.auth:google-auth-library-credentials:0.17.1", server_urls = ["http://central.maven.org/maven2"], - artifact_sha256 = "ac9efdd6a930e4df906fa278576fa825d979f74315f2faf5c91fe7e6aabb2788", + artifact_sha256 = "aaeea9333fff9b763715bca0174ec76c4f9551b5731c89a95f263cdc82b4b56e", licenses = ["notice"], # BSD 3-clause ) def com_google_auth_google_auth_library_oauth2_http(): jvm_maven_import_external( name = "com_google_auth_google_auth_library_oauth2_http", - artifact = "com.google.auth:google-auth-library-oauth2-http:0.9.0", + artifact = "com.google.auth:google-auth-library-oauth2-http:0.17.1", server_urls = ["http://central.maven.org/maven2"], - artifact_sha256 = "e55d9722102cc1245c8c43d69acd49d3c9bbfcc1bcf722e971425506b970097e", + artifact_sha256 = "fa9a1589c8bc279416988d437c2636967cd5e4eff70fbddc986b9c5a77b0231b", licenses = ["notice"], # BSD 3-clause ) @@ -241,9 +241,9 @@ def com_google_errorprone_error_prone_annotations(): def com_google_guava(): jvm_maven_import_external( name = "com_google_guava_guava", - artifact = "com.google.guava:guava:26.0-android", + artifact = "com.google.guava:guava:28.1-android", server_urls = ["http://central.maven.org/maven2"], - artifact_sha256 = "1d044ebb866ef08b7d04e998b4260c9b52fab6e6d6b68d207859486bb3686cd5", + artifact_sha256 = "e112ce92c0f0733965eede73d94589c59a72128b06b08bba5ebe2f9ea672ef60", licenses = ["notice"], # Apache 2.0 ) @@ -260,9 +260,9 @@ def com_google_guava_failureaccess(): def com_google_j2objc_j2objc_annotations(): jvm_maven_import_external( name = "com_google_j2objc_j2objc_annotations", - artifact = "com.google.j2objc:j2objc-annotations:1.1", + artifact = "com.google.j2objc:j2objc-annotations:1.3", server_urls = ["http://central.maven.org/maven2"], - artifact_sha256 = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6", + artifact_sha256 = "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", licenses = ["notice"], # Apache 2.0 )