List of usage examples for com.google.api.client.googleapis.testing.auth.oauth2 MockTokenServerTransport MockTokenServerTransport
public MockTokenServerTransport(String tokenServerUrl)
From source file:com.netflix.spinnaker.igor.gcb.GoogleCloudBuildTestConfig.java
License:Apache License
@Bean @Primary/*from w w w .j a va 2 s. c o m*/ GoogleCredentialService googleCredentialService() { return new GoogleCredentialService() { @Override GoogleCredential getFromKey(String jsonPath) { if (!jsonPath.equals("/path/to/some/file")) { return null; } // Create a mock credential whose bearer token is always "test-token" try { InputStream is = GoogleCloudBuildAccountFactory.class .getResourceAsStream("/gcb/gcb-test-account.json"); MockTokenServerTransport mockTransport = new MockTokenServerTransport( "https://accounts.google.com/o/oauth2/auth"); mockTransport.addServiceAccount("test-account@spinnaker-gcb-test.iam.gserviceaccount.com", "test-token"); return GoogleCredential.fromStream(is, mockTransport, JacksonFactory.getDefaultInstance()) .createScoped(CloudBuildScopes.all()); } catch (IOException e) { throw new RuntimeException(e); } } }; }