Search in sources :

Example 1 with AuthenticationHandlerFactory

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());
}
Also used : EasyAuthenticationHandlerFactory(org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory) SMTPServer(org.subethamail.smtp.server.SMTPServer) FakeSmtpConfigurationProperties(de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties) AuthenticationHandlerFactory(org.subethamail.smtp.AuthenticationHandlerFactory) EasyAuthenticationHandlerFactory(org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory) Test(org.junit.Test)

Aggregations

FakeSmtpConfigurationProperties (de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties)1 Test (org.junit.Test)1 AuthenticationHandlerFactory (org.subethamail.smtp.AuthenticationHandlerFactory)1 EasyAuthenticationHandlerFactory (org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory)1 SMTPServer (org.subethamail.smtp.server.SMTPServer)1