Search in sources :

Example 61 with MockImapServer

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

the class ImapConnectionTest method open_authCramMd5.

@Test
public void open_authCramMd5() throws Exception {
    settings.setAuthType(AuthType.CRAM_MD5);
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server, "AUTH=CRAM-MD5");
    server.expect("2 AUTHENTICATE CRAM-MD5");
    server.output("+ " + ByteString.encodeUtf8("<0000.000000000@example.org>").base64());
    server.expect("dXNlciA2ZjdiOTcyYjk5YTI4NDk4OTRhN2YyMmE3MGRhZDg0OQ==");
    server.output("2 OK Success");
    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 62 with MockImapServer

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

the class ImapConnectionTest method open_authXoauthWithSaslIr.

@Test
public void open_authXoauthWithSaslIr() throws Exception {
    settings.setAuthType(AuthType.XOAUTH2);
    when(oAuth2TokenProvider.getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT)).thenReturn("token");
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server, "SASL-IR AUTH=XOAUTH AUTH=XOAUTH2");
    server.expect("2 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING);
    server.output("2 OK Success");
    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 63 with MockImapServer

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

the class RealImapConnectionTest method open_authExternal.

@Test
public void open_authExternal() throws Exception {
    settings.setAuthType(AuthType.EXTERNAL);
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server, "AUTH=EXTERNAL");
    server.expect("2 AUTHENTICATE EXTERNAL " + ByteString.encodeUtf8(USERNAME).base64());
    server.output("2 OK Success");
    postAuthenticationDialogRequestingCapabilities(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 64 with MockImapServer

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

the class RealImapConnectionTest method executeSingleCommand_withOkResponse_shouldReturnResult.

@Test
public void executeSingleCommand_withOkResponse_shouldReturnResult() throws Exception {
    MockImapServer server = new MockImapServer();
    simpleOpenDialog(server, "");
    server.expect("4 CREATE Folder");
    server.output("4 OK Folder created");
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    List<ImapResponse> result = imapConnection.executeSimpleCommand("CREATE Folder");
    assertEquals(result.size(), 1);
    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 65 with MockImapServer

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

the class RealImapConnectionTest method isIdleCapable_withoutIdleCapability.

@Test
public void isIdleCapable_withoutIdleCapability() throws Exception {
    MockImapServer server = new MockImapServer();
    ImapConnection imapConnection = simpleOpen(server);
    boolean result = imapConnection.isIdleCapable();
    assertFalse(result);
    server.shutdown();
}
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