File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
javatests/com/google/auth/oauth2
java/com/google/auth/oauth2 Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -311,10 +311,12 @@ private final GoogleCredentials tryGetComputeCredentials(HttpTransportFactory tr
311311 }
312312 boolean runningOnComputeEngine = ComputeEngineCredentials .isOnGce (transportFactory , this );
313313 checkedComputeEngine = true ;
314+ ComputeEngineCredentials .Builder builder =
315+ shouldCheckMDSOnInitialization ()
316+ ? ComputeEngineCredentials .newBuilder ()
317+ : ComputeEngineCredentials .newTestBuilder ();
314318 if (runningOnComputeEngine ) {
315- return ComputeEngineCredentials .newBuilder ()
316- .setHttpTransportFactory (transportFactory )
317- .build ();
319+ return builder .setHttpTransportFactory (transportFactory ).build ();
318320 }
319321 return null ;
320322 }
@@ -363,6 +365,10 @@ InputStream readStream(File file) throws FileNotFoundException {
363365 return new FileInputStream (file );
364366 }
365367
368+ boolean shouldCheckMDSOnInitialization () {
369+ return true ;
370+ }
371+
366372 /*
367373 * End of methods to allow overriding in the test code to isolate from the environment.
368374 */
Original file line number Diff line number Diff line change @@ -977,6 +977,11 @@ InputStream readStream(File file) throws FileNotFoundException {
977977 void setFileSandbox (boolean fileSandbox ) {
978978 this .fileSandbox = fileSandbox ;
979979 }
980+
981+ @ Override
982+ boolean shouldCheckMDSOnInitialization () {
983+ return false ;
984+ }
980985 }
981986
982987 static class MockRequestCountingTransportFactory implements HttpTransportFactory {
You can’t perform that action at this time.
0 commit comments