use of com.nexblocks.authguard.emb.model.Message in project AuthGuard by AuthGuard.
the class EmailResetTokenSubscriberTest method onValidMessageNoEmail.
@Test
void onValidMessageNoEmail() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().build();
final ResetTokenMessage messageBody = new ResetTokenMessage(account, accountToken);
final Message message = Messages.passwordlessGenerated(messageBody);
emailResetTokenSubscriber.onMessage(message);
Mockito.verify(emailProvider, Mockito.never()).send(Mockito.any());
}
use of com.nexblocks.authguard.emb.model.Message in project AuthGuard by AuthGuard.
the class EmailResetTokenSubscriberTest method onValidMessage.
@Test
void onValidMessage() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().email(AccountEmailBO.builder().email("user@test.net").build()).firstName("first").lastName("second").build();
final ResetTokenMessage messageBody = new ResetTokenMessage(account, accountToken);
final Message message = Messages.resetTokenGenerated(messageBody);
final ImmutableEmail expectedEmail = ImmutableEmail.builder().template("passwordReset").to(account.getEmail().getEmail()).parameters(ImmutableMap.of("token", accountToken.getToken(), "firstName", account.getFirstName(), "lastName", account.getLastName())).build();
emailResetTokenSubscriber.onMessage(message);
final ArgumentCaptor<ImmutableEmail> sentEmailCaptor = ArgumentCaptor.forClass(ImmutableEmail.class);
Mockito.verify(emailProvider).send(sentEmailCaptor.capture());
assertThat(sentEmailCaptor.getValue()).isEqualTo(expectedEmail);
}
use of com.nexblocks.authguard.emb.model.Message in project AuthGuard by AuthGuard.
the class SmsOtpSubscriberTest method onValidMessage.
@Test
void onValidMessage() {
final OneTimePasswordBO otp = OneTimePasswordBO.builder().password("password").build();
final AccountBO account = AccountBO.builder().phoneNumber(PhoneNumberBO.builder().number("+178945632").build()).firstName("first").lastName("second").build();
final OtpMessageBody messageBody = new OtpMessageBody(otp, account, true, false);
final Message message = Messages.otpGenerated(messageBody);
final ImmutableTextMessage expectedEmail = ImmutableTextMessage.builder().to(account.getPhoneNumber().getNumber()).parameters(ImmutableMap.of("password", otp.getPassword(), "firstName", account.getFirstName(), "lastName", account.getLastName())).build();
otpSubscriber.onMessage(message);
final ArgumentCaptor<ImmutableTextMessage> sentSmsCaptor = ArgumentCaptor.forClass(ImmutableTextMessage.class);
Mockito.verify(smsProvider).send(sentSmsCaptor.capture());
assertThat(sentSmsCaptor.getValue()).isEqualTo(expectedEmail);
}
use of com.nexblocks.authguard.emb.model.Message in project AuthGuard by AuthGuard.
the class SmsOtpSubscriberTest method onWrongMessageType.
@Test
void onWrongMessageType() {
final OneTimePasswordBO otp = OneTimePasswordBO.builder().password("password").build();
final AccountBO account = AccountBO.builder().phoneNumber(PhoneNumberBO.builder().number("+178945632").build()).build();
final OtpMessageBody messageBody = new OtpMessageBody(otp, account, true, false);
final Message message = Messages.otpGenerated(messageBody).withEventType(EventType.ADMIN);
otpSubscriber.onMessage(message);
Mockito.verify(smsProvider, Mockito.never()).send(Mockito.any());
}
use of com.nexblocks.authguard.emb.model.Message in project AuthGuard by AuthGuard.
the class SmsOtpSubscriberTest method onValidMessageNoPhoneNumber.
@Test
void onValidMessageNoPhoneNumber() {
final OneTimePasswordBO otp = OneTimePasswordBO.builder().password("password").build();
final AccountBO account = AccountBO.builder().build();
final OtpMessageBody messageBody = new OtpMessageBody(otp, account, true, false);
final Message message = Messages.otpGenerated(messageBody);
otpSubscriber.onMessage(message);
Mockito.verify(smsProvider, Mockito.never()).send(Mockito.any());
}
Aggregations