Search in sources :

Example 11 with SMTPServer

use of org.subethamail.smtp.server.SMTPServer in project fake-smtp-server by gessnerfl.

the class SmtpServerConfiguratorTest method shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString.

@Test
public void shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString() {
    final String username = "username";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn(username);
    when(authentication.getPassword()).thenReturn("");
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
    final SMTPServer smtpServer = mock(SMTPServer.class);
    sut.configure(smtpServer);
    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Password"));
}
Also used : 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)

Example 12 with SMTPServer

use of org.subethamail.smtp.server.SMTPServer in project fake-smtp-server by gessnerfl.

the class SmtpServerConfiguratorTest method shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString.

@Test
public void shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString() {
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn("");
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
    final SMTPServer smtpServer = mock(SMTPServer.class);
    sut.configure(smtpServer);
    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Username"));
}
Also used : 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)

Example 13 with SMTPServer

use of org.subethamail.smtp.server.SMTPServer in project fake-smtp-server by gessnerfl.

the class SmtpServerImplTest method shouldCreateNewInstanceAndDelegateCallsToRealImplementation.

@Test
public void shouldCreateNewInstanceAndDelegateCallsToRealImplementation() {
    SMTPServer delegate = mock(SMTPServer.class);
    SmtpServerImpl sut = new SmtpServerImpl(delegate);
    sut.start();
    verify(delegate).start();
    sut.stop();
    verify(delegate).stop();
}
Also used : SMTPServer(org.subethamail.smtp.server.SMTPServer) Test(org.junit.Test)

Aggregations

SMTPServer (org.subethamail.smtp.server.SMTPServer)13 Test (org.junit.Test)8 AuthenticationHandlerFactory (org.subethamail.smtp.AuthenticationHandlerFactory)6 EasyAuthenticationHandlerFactory (org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory)6 FakeSmtpConfigurationProperties (de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties)5 SimpleMessageListenerAdapter (org.subethamail.smtp.helper.SimpleMessageListenerAdapter)4 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 Socket (java.net.Socket)1 HashMap (java.util.HashMap)1 SSLContext (javax.net.ssl.SSLContext)1 SSLSocket (javax.net.ssl.SSLSocket)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1 SmtpConsumer (org.apache.nifi.processors.email.smtp.SmtpConsumer)1 RestrictedSSLContextService (org.apache.nifi.ssl.RestrictedSSLContextService)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1 MotechEvent (org.motechproject.event.MotechEvent)1