use of com.nexblocks.authguard.service.model.AccountBO 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();
}
use of com.nexblocks.authguard.service.model.AccountBO in project AuthGuard by AuthGuard.
the class SmsPasswordlessSubscriber method onMessage.
@Override
public void onMessage(final Message message) {
if (message.getEventType() == EventType.PASSWORDLESS_GENERATED) {
final PasswordlessMessageBody messageBody = (PasswordlessMessageBody) message.getMessageBody();
final AccountBO account = messageBody.getAccount();
final AccountTokenDO accountToken = messageBody.getAccountToken();
sendEmail(account, accountToken);
}
}
use of com.nexblocks.authguard.service.model.AccountBO in project AuthGuard by AuthGuard.
the class EmailPasswordlessSubscriber method onMessage.
@Override
public void onMessage(final Message message) {
if (message.getEventType() == EventType.PASSWORDLESS_GENERATED) {
final PasswordlessMessageBody messageBody = (PasswordlessMessageBody) message.getMessageBody();
final AccountBO account = messageBody.getAccount();
final AccountTokenDO accountToken = messageBody.getAccountToken();
sendEmail(account, accountToken);
}
}
use of com.nexblocks.authguard.service.model.AccountBO in project AuthGuard by AuthGuard.
the class EmailPasswordlessSubscriberTest method onWrongMessageType.
@Test
void onWrongMessageType() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().email(AccountEmailBO.builder().email("user@test.net").build()).build();
final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody).withEventType(EventType.ADMIN);
emailPasswordlessSubscriber.onMessage(message);
Mockito.verify(emailProvider, Mockito.never()).send(Mockito.any());
}
use of com.nexblocks.authguard.service.model.AccountBO in project AuthGuard by AuthGuard.
the class EmailResetTokenSubscriberTest method onWrongMessageType.
@Test
void onWrongMessageType() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().email(AccountEmailBO.builder().email("user@test.net").build()).build();
final ResetTokenMessage messageBody = new ResetTokenMessage(account, accountToken);
final Message message = Messages.passwordlessGenerated(messageBody).withEventType(EventType.ADMIN);
emailResetTokenSubscriber.onMessage(message);
Mockito.verify(emailProvider, Mockito.never()).send(Mockito.any());
}
Aggregations