diff --git a/src/main/java/com/instaclustr/esop/gcp/GCPModule.java b/src/main/java/com/instaclustr/esop/gcp/GCPModule.java index a0a187d4..a1a13ccc 100644 --- a/src/main/java/com/instaclustr/esop/gcp/GCPModule.java +++ b/src/main/java/com/instaclustr/esop/gcp/GCPModule.java @@ -5,6 +5,8 @@ import static java.lang.String.format; import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Optional; @@ -86,7 +88,16 @@ private Storage resolveStorageFromEnvProperties() { throw new GCPModuleException(format("GCP credentials file %s does not exist!", googleAppCredentialsPath)); } - return StorageOptions.getDefaultInstance().getService(); + GoogleCredentials credentials = resolveGoogleCredentialsFromFile(googleAppCredentialsPath); + return StorageOptions.newBuilder().setCredentials(credentials).build().getService(); + } + + private GoogleCredentials resolveGoogleCredentialsFromFile(String googleAppCredentialsPath) { + try (InputStream is = new FileInputStream(googleAppCredentialsPath)) { + return GoogleCredentials.fromStream(is); + } catch (Exception ex) { + throw new RuntimeException("Unable to read credentials from " + googleAppCredentialsPath); + } } private GoogleCredentials resolveGoogleCredentials(final AbstractOperationRequest operationRequest) { diff --git a/src/test/java/com/instaclustr/esop/backup/embedded/gcp/GoogleStorageBackupRestoreTest.java b/src/test/java/com/instaclustr/esop/backup/embedded/gcp/GoogleStorageBackupRestoreTest.java index 68579402..5dff385c 100644 --- a/src/test/java/com/instaclustr/esop/backup/embedded/gcp/GoogleStorageBackupRestoreTest.java +++ b/src/test/java/com/instaclustr/esop/backup/embedded/gcp/GoogleStorageBackupRestoreTest.java @@ -20,14 +20,12 @@ import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; @Test(groups = { "googleTest", "cloudTest", }) -@Ignore public class GoogleStorageBackupRestoreTest extends BaseGoogleStorageBackupRestoreTest { @Inject