use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class ComputeEngineCredentialsTest method equals_false_transportFactory.
@Test
public void equals_false_transportFactory() throws IOException {
MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
MockMetadataServerTransportFactory serverTransportFactory = new MockMetadataServerTransportFactory();
ComputeEngineCredentials credentials = ComputeEngineCredentials.newBuilder().setHttpTransportFactory(serverTransportFactory).build();
ComputeEngineCredentials otherCredentials = ComputeEngineCredentials.newBuilder().setHttpTransportFactory(httpTransportFactory).build();
assertFalse(credentials.equals(otherCredentials));
assertFalse(otherCredentials.equals(credentials));
}
use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class DefaultCredentialsProviderTest method getDefaultCredentials_envMissingFile_throws.
@Test
public void getDefaultCredentials_envMissingFile_throws() {
final String invalidPath = "/invalid/path";
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
testProvider.setEnv(DefaultCredentialsProvider.CREDENTIAL_ENV_VAR, invalidPath);
try {
testProvider.getDefaultCredentials(transportFactory);
fail("Non existent credential should throw exception");
} catch (IOException e) {
String message = e.getMessage();
assertTrue(message.contains(DefaultCredentialsProvider.CREDENTIAL_ENV_VAR));
assertTrue(message.contains(invalidPath));
}
}
use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class DefaultCredentialsProviderTest method getDefaultCredentials_appEngineRuntimeWithoutClass_throwsHelpfulLoadError.
@Test
public void getDefaultCredentials_appEngineRuntimeWithoutClass_throwsHelpfulLoadError() {
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
testProvider.addType(DefaultCredentialsProvider.APP_ENGINE_SIGNAL_CLASS, MockAppEngineSystemProperty.class);
testProvider.setProperty("isOnGAEStandard7", "true");
try {
testProvider.getDefaultCredentials(transportFactory);
fail("Credential expected to fail to load if credential class not present.");
} catch (IOException e) {
String message = e.getMessage();
assertFalse(message.contains(DefaultCredentialsProvider.HELP_PERMALINK));
assertTrue(message.contains("Check that the App Engine SDK is deployed."));
}
}
use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class DefaultCredentialsProviderTest method getDefaultCredentials_appEngineClassWithoutRuntime_NotFoundError.
@Test
public void getDefaultCredentials_appEngineClassWithoutRuntime_NotFoundError() {
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
testProvider.addType(DefaultCredentialsProvider.APP_ENGINE_SIGNAL_CLASS, MockOffAppEngineSystemProperty.class);
testProvider.setProperty("isOnGAEStandard7", "true");
try {
testProvider.getDefaultCredentials(transportFactory);
fail("No credential expected when not on App Engine.");
} catch (IOException e) {
String message = e.getMessage();
assertTrue(message.contains(DefaultCredentialsProvider.HELP_PERMALINK));
}
}
use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class DefaultCredentialsProviderTest method getDefaultCredentials_noCredentials_throws.
@Test
public void getDefaultCredentials_noCredentials_throws() throws Exception {
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
TestDefaultCredentialsProvider testProvider = new TestDefaultCredentialsProvider();
try {
testProvider.getDefaultCredentials(transportFactory);
fail("No credential expected.");
} catch (IOException e) {
String message = e.getMessage();
assertTrue(message.contains(DefaultCredentialsProvider.HELP_PERMALINK));
}
}
Aggregations