use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.
the class UserCredentialsTest method equals_false_transportFactory.
@Test
public void equals_false_transportFactory() throws IOException {
final URI tokenServer1 = URI.create("https://foo1.com/bar");
AccessToken accessToken = new AccessToken(ACCESS_TOKEN, null);
MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
MockTokenServerTransportFactory serverTransportFactory = new MockTokenServerTransportFactory();
UserCredentials credentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
UserCredentials otherCredentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(serverTransportFactory).setTokenServerUri(tokenServer1).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 UserCredentialsTest method equals_false_tokenServer.
@Test
public void equals_false_tokenServer() throws IOException {
final URI tokenServer1 = URI.create("https://foo1.com/bar");
final URI tokenServer2 = URI.create("https://foo2.com/bar");
AccessToken accessToken = new AccessToken(ACCESS_TOKEN, null);
MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
UserCredentials credentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
UserCredentials otherCredentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer2).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 ServiceAccountCredentialsTest method equals_false_transportFactory.
@Test
public void equals_false_transportFactory() throws IOException {
final URI tokenServer1 = URI.create("https://foo1.com/bar");
MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
MockTokenServerTransportFactory serverTransportFactory = new MockTokenServerTransportFactory();
OAuth2Credentials credentials = ServiceAccountCredentials.fromPkcs8(SA_CLIENT_ID, SA_CLIENT_EMAIL, SA_PRIVATE_KEY_PKCS8, SA_PRIVATE_KEY_ID, SCOPES, serverTransportFactory, tokenServer1);
OAuth2Credentials otherCredentials = ServiceAccountCredentials.fromPkcs8(SA_CLIENT_ID, SA_CLIENT_EMAIL, SA_PRIVATE_KEY_PKCS8, SA_PRIVATE_KEY_ID, SCOPES, httpTransportFactory, tokenServer1);
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 ServiceAccountCredentialsTest method fromStream_nullStream_throws.
@Test
public void fromStream_nullStream_throws() throws IOException {
MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
try {
ServiceAccountCredentials.fromStream(null, transportFactory);
fail("Should throw if InputStream is null");
} catch (NullPointerException expected) {
// Expected
}
}
Aggregations