Search in sources :

Example 1 with MockImapServer

use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.

the class ImapConnectionTest method sendContinuation.

@Test
public void sendContinuation() throws Exception {
    settings.setAuthType(AuthType.PLAIN);
    MockImapServer server = new MockImapServer();
    simpleOpenDialog(server, "IDLE");
    server.expect("4 IDLE");
    server.output("+ idling");
    server.expect("DONE");
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    imapConnection.open();
    imapConnection.sendCommand("IDLE", false);
    imapConnection.readResponse();
    imapConnection.sendContinuation("DONE");
    server.waitForInteractionToComplete();
    server.verifyConnectionStillOpen();
    server.verifyInteractionCompleted();
}
Also used : MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 2 with MockImapServer

use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.

the class ImapConnectionTest method open_withIoExceptionDuringListCommand_shouldThrow.

@Test
public void open_withIoExceptionDuringListCommand_shouldThrow() throws Exception {
    settings.setAuthType(AuthType.PLAIN);
    settings.setUseCompression(true);
    MockImapServer server = new MockImapServer();
    simplePreAuthAndLoginDialog(server, "");
    server.expect("3 LIST \"\" \"\"");
    server.output("* Now what?");
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    try {
        imapConnection.open();
        fail("Exception expected");
    } catch (IOException ignored) {
    }
    server.verifyConnectionClosed();
    server.verifyInteractionCompleted();
}
Also used : MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) IOException(java.io.IOException) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 3 with MockImapServer

use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.

the class ImapConnectionTest method open_authPlainWithoutAuthPlainCapability_shouldUseLoginMethod.

@Test
public void open_authPlainWithoutAuthPlainCapability_shouldUseLoginMethod() throws Exception {
    settings.setAuthType(AuthType.PLAIN);
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server);
    server.expect("2 LOGIN \"" + USERNAME + "\" \"" + PASSWORD + "\"");
    server.output("2 OK LOGIN completed");
    simplePostAuthenticationDialog(server);
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    imapConnection.open();
    server.verifyConnectionStillOpen();
    server.verifyInteractionCompleted();
}
Also used : MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 4 with MockImapServer

use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.

the class ImapConnectionTest method open_withStartTlsButWithoutStartTlsCapability_shouldThrow.

@Test
public void open_withStartTlsButWithoutStartTlsCapability_shouldThrow() throws Exception {
    settings.setConnectionSecurity(ConnectionSecurity.STARTTLS_REQUIRED);
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server);
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    try {
        imapConnection.open();
        fail("Expected exception");
    } catch (CertificateValidationException e) {
        //FIXME: CertificateValidationException seems wrong
        assertEquals("STARTTLS connection security not available", e.getMessage());
    }
    server.verifyConnectionClosed();
    server.verifyInteractionCompleted();
}
Also used : MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) CertificateValidationException(com.fsck.k9.mail.CertificateValidationException) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 5 with MockImapServer

use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.

the class ImapConnectionTest method open_withNegativeResponseToListCommand.

@Test
public void open_withNegativeResponseToListCommand() throws Exception {
    settings.setAuthType(AuthType.PLAIN);
    settings.setUseCompression(true);
    MockImapServer server = new MockImapServer();
    simplePreAuthAndLoginDialog(server, "");
    server.expect("3 LIST \"\" \"\"");
    server.output("3 NO");
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    imapConnection.open();
    server.verifyConnectionStillOpen();
    server.verifyInteractionCompleted();
}
Also used : MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Aggregations

XOAuth2ChallengeParserTest (com.fsck.k9.mail.XOAuth2ChallengeParserTest)81 MockImapServer (com.fsck.k9.mail.store.imap.mockserver.MockImapServer)81 Test (org.junit.Test)81 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)10 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)6 MessagingException (com.fsck.k9.mail.MessagingException)4 IOException (java.io.IOException)4 InOrder (org.mockito.InOrder)3