use of com.nexblocks.authguard.service.model.ActionTokenBO in project AuthGuard by AuthGuard.
the class ActionTokenServiceImplTest method generateFromBasicAuth.
@Test
void generateFromBasicAuth() {
final AuthRequestBO authRequest = AuthRequestBO.builder().identifier("username").password("password").build();
final AccountBO account = AccountBO.builder().id("account").build();
Mockito.when(basicAuthProvider.getAccount(authRequest)).thenReturn(Either.right(account));
Mockito.when(accountTokensRepository.save(Mockito.any())).thenReturn(CompletableFuture.completedFuture(null));
final Try<ActionTokenBO> actual = actionTokenService.generateFromBasicAuth(authRequest, "something");
final ActionTokenBO expected = ActionTokenBO.builder().accountId(account.getId()).validFor(Duration.ofMinutes(5).toSeconds()).build();
assertThat(actual.isSuccess());
assertThat(actual.get()).isEqualToIgnoringGivenFields(expected, "token");
assertThat(actual.get().getToken()).isNotNull();
}
Aggregations