use of org.subethamail.smtp.AuthenticationHandlerFactory in project fake-smtp-server by gessnerfl.
the class SmtpServerConfiguratorTest method shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly.
@Test
public void shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly() {
final String username = "username";
final String password = "password";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn(username);
when(authentication.getPassword()).thenReturn(password);
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
ArgumentCaptor<AuthenticationHandlerFactory> argumentCaptor = ArgumentCaptor.forClass(AuthenticationHandlerFactory.class);
verify(smtpServer).setAuthenticationHandlerFactory(argumentCaptor.capture());
AuthenticationHandlerFactory authenticationHandlerFactory = argumentCaptor.getValue();
assertNotNull(authenticationHandlerFactory);
assertThat(authenticationHandlerFactory, instanceOf(EasyAuthenticationHandlerFactory.class));
EasyAuthenticationHandlerFactory easyAuthenticationHandlerFactory = (EasyAuthenticationHandlerFactory) authenticationHandlerFactory;
assertSame(basicUsernamePasswordValidator, easyAuthenticationHandlerFactory.getValidator());
}
Aggregations