Search in sources :

Example 1 with ZonkyOAuthApi

use of com.github.robozonky.api.remote.ZonkyOAuthApi in project robozonky by RoboZonky.

the class OAuthTest method refresh.

@Test
void refresh() {
    final String originalTokenId = UUID.randomUUID().toString();
    final ZonkyApiToken originToken = new ZonkyApiToken(UUID.randomUUID().toString(), originalTokenId, OffsetDateTime.now());
    final ZonkyApiToken resultToken = mock(ZonkyApiToken.class);
    final ZonkyOAuthApi api = mock(ZonkyOAuthApi.class);
    when(api.refresh(eq(originalTokenId), anyString(), anyString())).thenReturn(resultToken);
    final Api<ZonkyOAuthApi> wrapper = new Api<>(api);
    final OAuth oauth = new OAuth(wrapper);
    final ZonkyApiToken returnedToken = oauth.refresh(originToken);
    assertThat(returnedToken).isEqualTo(resultToken);
}
Also used : ZonkyOAuthApi(com.github.robozonky.api.remote.ZonkyOAuthApi) ZonkyApiToken(com.github.robozonky.api.remote.entities.ZonkyApiToken) ZonkyOAuthApi(com.github.robozonky.api.remote.ZonkyOAuthApi) Test(org.junit.jupiter.api.Test)

Example 2 with ZonkyOAuthApi

use of com.github.robozonky.api.remote.ZonkyOAuthApi in project robozonky by RoboZonky.

the class OAuthTest method login.

@Test
void login() {
    final ZonkyOAuthApi api = mock(ZonkyOAuthApi.class);
    final Api<ZonkyOAuthApi> wrapper = new Api<>(api);
    final OAuth oauth = new OAuth(wrapper);
    oauth.login(USERNAME, PASSWORD.toCharArray());
    verify(api, times(1)).login(eq(USERNAME), eq(PASSWORD), eq("password"), eq("SCOPE_APP_WEB"));
}
Also used : ZonkyOAuthApi(com.github.robozonky.api.remote.ZonkyOAuthApi) ZonkyOAuthApi(com.github.robozonky.api.remote.ZonkyOAuthApi) Test(org.junit.jupiter.api.Test)

Aggregations

ZonkyOAuthApi (com.github.robozonky.api.remote.ZonkyOAuthApi)2 Test (org.junit.jupiter.api.Test)2 ZonkyApiToken (com.github.robozonky.api.remote.entities.ZonkyApiToken)1