Update to Guava 28.1

Remove serviceAccountWithScopeNotToJwt as test no longer makes sense
and it is hard to adapt to the new cred API.
This commit is contained in:
Elliotte Rusty Harold 2019-09-13 14:16:08 -04:00 committed by Eric Anderson
parent 2b945774b6
commit 858a1f8fb9
3 changed files with 24 additions and 44 deletions

View File

@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import com.google.auth.Credentials; import com.google.auth.Credentials;
import com.google.auth.RequestMetadataCallback; import com.google.auth.RequestMetadataCallback;
import com.google.auth.http.HttpTransportFactory;
import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials; import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.OAuth2Credentials; import com.google.auth.oauth2.OAuth2Credentials;
@ -67,6 +68,7 @@ import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule; import org.mockito.junit.MockitoRule;
@ -252,7 +254,7 @@ public class GoogleAuthLibraryCallCredentialsTest {
@Test @Test
public void oauth2Credential() { public void oauth2Credential() {
final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE)); final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE));
final OAuth2Credentials credentials = new OAuth2Credentials() { OAuth2Credentials credentials = new OAuth2Credentials() {
@Override @Override
public AccessToken refreshAccessToken() throws IOException { public AccessToken refreshAccessToken() throws IOException {
return token; return token;
@ -323,14 +325,17 @@ public class GoogleAuthLibraryCallCredentialsTest {
@Test @Test
public void serviceAccountToJwt() throws Exception { public void serviceAccountToJwt() throws Exception {
KeyPair pair = KeyPairGenerator.getInstance("RSA").generateKeyPair(); KeyPair pair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
@SuppressWarnings("deprecation")
ServiceAccountCredentials credentials = new ServiceAccountCredentials( HttpTransportFactory factory = Mockito.mock(HttpTransportFactory.class);
null, "email@example.com", pair.getPrivate(), null, null) { Mockito.when(factory.create()).thenThrow(new AssertionError());
@Override
public AccessToken refreshAccessToken() { ServiceAccountCredentials credentials =
throw new AssertionError(); ServiceAccountCredentials.newBuilder()
} .setClientEmail("test-email@example.com")
}; .setPrivateKey(pair.getPrivate())
.setPrivateKeyId("test-private-key-id")
.setHttpTransportFactory(factory)
.build();
GoogleAuthLibraryCallCredentials callCredentials = GoogleAuthLibraryCallCredentials callCredentials =
new GoogleAuthLibraryCallCredentials(credentials); new GoogleAuthLibraryCallCredentials(credentials);
@ -346,31 +351,6 @@ public class GoogleAuthLibraryCallCredentialsTest {
assertTrue(authorization[0], authorization[0].length() > 300); 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<String> authorization = headers.getAll(AUTHORIZATION);
assertArrayEquals(new String[]{"Bearer allyourbase"},
Iterables.toArray(authorization, String.class));
}
@Test @Test
public void oauthClassesNotInClassPath() throws Exception { public void oauthClassesNotInClassPath() throws Exception {
ListMultimap<String, String> values = LinkedListMultimap.create(); ListMultimap<String, String> values = LinkedListMultimap.create();

View File

@ -44,8 +44,8 @@ subprojects {
javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix" javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
nettyVersion = '4.1.38.Final' nettyVersion = '4.1.38.Final'
googleauthVersion = '0.13.0' guavaVersion = '28.1-android'
guavaVersion = '26.0-android' googleauthVersion = '0.17.1'
protobufVersion = '3.9.0' protobufVersion = '3.9.0'
protocVersion = protobufVersion protocVersion = protobufVersion
opencensusVersion = '0.21.0' opencensusVersion = '0.21.0'

View File

@ -196,18 +196,18 @@ def com_google_api_grpc_google_common_protos():
def com_google_auth_google_auth_library_credentials(): def com_google_auth_google_auth_library_credentials():
jvm_maven_import_external( jvm_maven_import_external(
name = "com_google_auth_google_auth_library_credentials", 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"], server_urls = ["http://central.maven.org/maven2"],
artifact_sha256 = "ac9efdd6a930e4df906fa278576fa825d979f74315f2faf5c91fe7e6aabb2788", artifact_sha256 = "aaeea9333fff9b763715bca0174ec76c4f9551b5731c89a95f263cdc82b4b56e",
licenses = ["notice"], # BSD 3-clause licenses = ["notice"], # BSD 3-clause
) )
def com_google_auth_google_auth_library_oauth2_http(): def com_google_auth_google_auth_library_oauth2_http():
jvm_maven_import_external( jvm_maven_import_external(
name = "com_google_auth_google_auth_library_oauth2_http", 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"], server_urls = ["http://central.maven.org/maven2"],
artifact_sha256 = "e55d9722102cc1245c8c43d69acd49d3c9bbfcc1bcf722e971425506b970097e", artifact_sha256 = "fa9a1589c8bc279416988d437c2636967cd5e4eff70fbddc986b9c5a77b0231b",
licenses = ["notice"], # BSD 3-clause licenses = ["notice"], # BSD 3-clause
) )
@ -241,9 +241,9 @@ def com_google_errorprone_error_prone_annotations():
def com_google_guava(): def com_google_guava():
jvm_maven_import_external( jvm_maven_import_external(
name = "com_google_guava_guava", 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"], server_urls = ["http://central.maven.org/maven2"],
artifact_sha256 = "1d044ebb866ef08b7d04e998b4260c9b52fab6e6d6b68d207859486bb3686cd5", artifact_sha256 = "e112ce92c0f0733965eede73d94589c59a72128b06b08bba5ebe2f9ea672ef60",
licenses = ["notice"], # Apache 2.0 licenses = ["notice"], # Apache 2.0
) )
@ -260,9 +260,9 @@ def com_google_guava_failureaccess():
def com_google_j2objc_j2objc_annotations(): def com_google_j2objc_j2objc_annotations():
jvm_maven_import_external( jvm_maven_import_external(
name = "com_google_j2objc_j2objc_annotations", 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"], server_urls = ["http://central.maven.org/maven2"],
artifact_sha256 = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6", artifact_sha256 = "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b",
licenses = ["notice"], # Apache 2.0 licenses = ["notice"], # Apache 2.0
) )