Switch from GoogleApacheHttpTransport to NetHttpTransport.
GoogleApacheHttpTransport breaks with the current 4.5.x HttpClient dependency so we're switching to NetHttpTransport that uses HttpURLConnection. Closes gh-463.
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import com.google.api.client.googleapis.apache.GoogleApacheHttpTransport;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.services.iam.v1.Iam;
|
||||
@@ -88,7 +89,7 @@ public class GcpIamAuthentication extends GcpJwtAuthenticationSupport
|
||||
*/
|
||||
public GcpIamAuthentication(GcpIamAuthenticationOptions options,
|
||||
RestOperations restOperations) throws GeneralSecurityException, IOException {
|
||||
this(options, restOperations, GoogleApacheHttpTransport.newTrustedTransport());
|
||||
this(options, restOperations, new NetHttpTransport());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.vault.authentication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.PrivateKey;
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -100,4 +102,21 @@ class GcpIamAuthenticationUnitTests {
|
||||
assertThat(loginToken.isRenewable()).isTrue();
|
||||
assertThat(loginToken.getLeaseDuration()).isEqualTo(Duration.ofSeconds(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCreateNewGcpIamObjectInstance()
|
||||
throws GeneralSecurityException, IOException {
|
||||
|
||||
PrivateKey privateKeyMock = mock(PrivateKey.class);
|
||||
GoogleCredential credential = new Builder().setServiceAccountId("hello@world")
|
||||
.setServiceAccountProjectId("foobar")
|
||||
.setServiceAccountPrivateKey(privateKeyMock)
|
||||
.setServiceAccountPrivateKeyId("key-id").build();
|
||||
credential.setAccessToken("foobar");
|
||||
|
||||
GcpIamAuthenticationOptions options = GcpIamAuthenticationOptions.builder()
|
||||
.role("dev-role").credential(credential).build();
|
||||
|
||||
new GcpIamAuthentication(options, restTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user