use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.
the class EmailPasswordlessSubscriberTest 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 PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody);
final ImmutableEmail expectedEmail = ImmutableEmail.builder().template("passwordless").to(account.getEmail().getEmail()).parameters(ImmutableMap.of("token", accountToken.getToken(), "firstName", account.getFirstName(), "lastName", account.getLastName())).build();
emailPasswordlessSubscriber.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.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.
the class EmailPasswordlessSubscriberTest method onValidMessageNoEmail.
@Test
void onValidMessageNoEmail() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().build();
final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody);
emailPasswordlessSubscriber.onMessage(message);
Mockito.verify(emailProvider, Mockito.never()).send(Mockito.any());
}
use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.
the class SmsPasswordlessSubscriberTest method onWrongMessageType.
@Test
void onWrongMessageType() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().phoneNumber(PhoneNumberBO.builder().number("+178945632").build()).build();
final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody).withEventType(EventType.ADMIN);
smsPasswordlessSubscriber.onMessage(message);
Mockito.verify(smsProvider, Mockito.never()).send(Mockito.any());
}
use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.
the class SmsPasswordlessSubscriberTest method onValidMessage.
@Test
void onValidMessage() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().phoneNumber(PhoneNumberBO.builder().number("+178945632").build()).firstName("first").lastName("second").build();
final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody);
final ImmutableTextMessage expectedSms = ImmutableTextMessage.builder().to(account.getPhoneNumber().getNumber()).parameters(ImmutableMap.of("token", accountToken.getToken(), "firstName", account.getFirstName(), "lastName", account.getLastName())).build();
smsPasswordlessSubscriber.onMessage(message);
final ArgumentCaptor<ImmutableTextMessage> sentSmsCaptor = ArgumentCaptor.forClass(ImmutableTextMessage.class);
Mockito.verify(smsProvider).send(sentSmsCaptor.capture());
assertThat(sentSmsCaptor.getValue()).isEqualTo(expectedSms);
}
use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.
the class SmsPasswordlessSubscriberTest method onValidMessageNoPhoneNumber.
@Test
void onValidMessageNoPhoneNumber() {
final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
final AccountBO account = AccountBO.builder().build();
final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
final Message message = Messages.passwordlessGenerated(messageBody);
smsPasswordlessSubscriber.onMessage(message);
Mockito.verify(smsProvider, Mockito.never()).send(Mockito.any());
}
Aggregations