This repository was archived by the owner on Apr 7, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
google-cloud-spanner/src/test/java/com/google/cloud/spanner Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525import com .google .auth .oauth2 .ServiceAccountCredentials ;
2626import com .google .cloud .spanner .ErrorCode ;
2727import com .google .cloud .spanner .SpannerException ;
28- import java .io .FileInputStream ;
2928import java .io .IOException ;
29+ import java .nio .file .Files ;
30+ import java .nio .file .Paths ;
3031import org .junit .Test ;
3132import org .junit .runner .RunWith ;
3233import org .junit .runners .JUnit4 ;
3637public class CredentialsServiceTest {
3738 private static final String FILE_TEST_PATH =
3839 CredentialsServiceTest .class .getResource ("test-key.json" ).getFile ();
39- private static final String APP_DEFAULT_FILE_TEST_PATH =
40+ private static final String SA_APP_DEFAULT_FILE_TEST_PATH =
4041 CredentialsServiceTest .class .getResource ("test-key-app-default.json" ).getFile ();
4142
4243 private static final String TEST_PROJECT_ID = "test-project" ;
@@ -49,7 +50,8 @@ public class CredentialsServiceTest {
4950 GoogleCredentials internalGetApplicationDefault () throws IOException {
5051 // Read application default credentials directly from a specific file instead of actually
5152 // fetching the default from the environment.
52- return GoogleCredentials .fromStream (new FileInputStream (APP_DEFAULT_FILE_TEST_PATH ));
53+ return ServiceAccountCredentials .fromStream (
54+ Files .newInputStream (Paths .get (SA_APP_DEFAULT_FILE_TEST_PATH )));
5355 }
5456 };
5557
Original file line number Diff line number Diff line change 4848import com .google .common .base .Strings ;
4949import com .google .longrunning .OperationsClient ;
5050import com .google .longrunning .OperationsSettings ;
51- import java .io .FileInputStream ;
5251import java .io .IOException ;
5352import java .util .ArrayList ;
5453import java .util .Collections ;
@@ -352,9 +351,7 @@ public void deniedListBackupOperations() throws IOException {
352351 .setTransportChannelProvider (InstantiatingGrpcChannelProvider .newBuilder ().build ())
353352 .setEndpoint ("spanner.googleapis.com:443" )
354353 .setCredentialsProvider (
355- FixedCredentialsProvider .create (
356- GoogleCredentials .fromStream (
357- new FileInputStream (System .getenv ("GOOGLE_APPLICATION_CREDENTIALS" )))))
354+ FixedCredentialsProvider .create (GoogleCredentials .getApplicationDefault ()))
358355 .build ())) {
359356 client .listOperations (backupId .getName () + "/operations" , "" );
360357 fail ("Expected PermissionDeniedException" );
You can’t perform that action at this time.
0 commit comments