Search in sources :

Example 6 with MockHttpTransportFactory

use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.

the class UserCredentialsTest method equals_false_accessToken.

@Test
public void equals_false_accessToken() throws IOException {
    final URI tokenServer1 = URI.create("https://foo1.com/bar");
    AccessToken accessToken = new AccessToken(ACCESS_TOKEN, null);
    AccessToken otherAccessToken = new AccessToken("otherAccessToken", 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(otherAccessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
    assertFalse(credentials.equals(otherCredentials));
    assertFalse(otherCredentials.equals(credentials));
}
Also used : MockHttpTransportFactory(com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory) URI(java.net.URI) Test(org.junit.Test)

Example 7 with MockHttpTransportFactory

use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.

the class UserCredentialsTest method equals_false_clientSecret.

@Test
public void equals_false_clientSecret() throws IOException {
    final URI tokenServer1 = URI.create("https://foo1.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("other client secret").setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
    assertFalse(credentials.equals(otherCredentials));
    assertFalse(otherCredentials.equals(credentials));
}
Also used : MockHttpTransportFactory(com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory) URI(java.net.URI) Test(org.junit.Test)

Example 8 with MockHttpTransportFactory

use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.

the class UserCredentialsTest method fromStream_nullStream_throws.

@Test
public void fromStream_nullStream_throws() throws IOException {
    MockHttpTransportFactory transportFactory = new MockHttpTransportFactory();
    try {
        UserCredentials.fromStream(null, transportFactory);
        fail("Should throw if InputStream is null");
    } catch (NullPointerException expected) {
    // Expected
    }
}
Also used : MockHttpTransportFactory(com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory) Test(org.junit.Test)

Example 9 with MockHttpTransportFactory

use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.

the class UserCredentialsTest method equals_false_refreshToken.

@Test
public void equals_false_refreshToken() throws IOException {
    final URI tokenServer1 = URI.create("https://foo1.com/bar");
    AccessToken accessToken = new AccessToken(ACCESS_TOKEN, null);
    MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
    OAuth2Credentials credentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
    OAuth2Credentials otherCredentials = UserCredentials.newBuilder().setClientId(CLIENT_ID).setClientSecret(CLIENT_SECRET).setRefreshToken("otherRefreshToken").setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
    assertFalse(credentials.equals(otherCredentials));
    assertFalse(otherCredentials.equals(credentials));
}
Also used : MockHttpTransportFactory(com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory) URI(java.net.URI) Test(org.junit.Test)

Example 10 with MockHttpTransportFactory

use of com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory in project google-auth-library-java by google.

the class UserCredentialsTest method equals_false_clientId.

@Test
public void equals_false_clientId() throws IOException {
    final URI tokenServer1 = URI.create("https://foo1.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("other client id").setClientSecret(CLIENT_SECRET).setRefreshToken(REFRESH_TOKEN).setAccessToken(accessToken).setHttpTransportFactory(httpTransportFactory).setTokenServerUri(tokenServer1).build();
    assertFalse(credentials.equals(otherCredentials));
    assertFalse(otherCredentials.equals(credentials));
}
Also used : MockHttpTransportFactory(com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory) URI(java.net.URI) Test(org.junit.Test)

Aggregations

MockHttpTransportFactory (com.google.auth.oauth2.GoogleCredentialsTest.MockHttpTransportFactory)19 Test (org.junit.Test)19 URI (java.net.URI)7 IOException (java.io.IOException)6 MockTokenServerTransportFactory (com.google.auth.oauth2.GoogleCredentialsTest.MockTokenServerTransportFactory)2 InputStream (java.io.InputStream)1