Search in sources :

Example 36 with MockSmtpServer

use of com.fsck.k9.mail.transport.mockServer.MockSmtpServer in project k-9 by k9mail.

the class SmtpTransportTest method open_withAutomaticAuthAndNoTransportSecurityAndAuthPlainExtension_shouldThrow.

@Test
public void open_withAutomaticAuthAndNoTransportSecurityAndAuthPlainExtension_shouldThrow() throws Exception {
    MockSmtpServer server = new MockSmtpServer();
    server.output("220 localhost Simple Mail Transfer Service Ready");
    server.expect("EHLO [127.0.0.1]");
    server.output("250-localhost Hello client.localhost");
    server.output("250 AUTH PLAIN LOGIN");
    server.expect("QUIT");
    server.output("221 BYE");
    SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.AUTOMATIC, ConnectionSecurity.NONE);
    try {
        transport.open();
        fail("Exception expected");
    } catch (MessagingException e) {
        assertEquals("Update your outgoing server authentication setting. AUTOMATIC auth. is unavailable.", e.getMessage());
    }
    server.verifyConnectionClosed();
    server.verifyInteractionCompleted();
}
Also used : MessagingException(com.fsck.k9.mail.MessagingException) MockSmtpServer(com.fsck.k9.mail.transport.mockServer.MockSmtpServer) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Aggregations

MockSmtpServer (com.fsck.k9.mail.transport.mockServer.MockSmtpServer)35 XOAuth2ChallengeParserTest (com.fsck.k9.mail.XOAuth2ChallengeParserTest)34 Test (org.junit.Test)34 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)12 Message (com.fsck.k9.mail.Message)11 MessagingException (com.fsck.k9.mail.MessagingException)5 InOrder (org.mockito.InOrder)5 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)1 ServerSettings (com.fsck.k9.mail.ServerSettings)1