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);
}
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"));
}
Aggregations