use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method close_afterOpen_shouldCloseConnection.
@Test
public void close_afterOpen_shouldCloseConnection() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpen(server);
imapConnection.close();
server.verifyConnectionClosed();
server.shutdown();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_authPlainWithAuthenticationFailure_shouldFallbackToLogin.
@Test
public void open_authPlainWithAuthenticationFailure_shouldFallbackToLogin() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=PLAIN");
server.expect("2 AUTHENTICATE PLAIN");
server.output("+");
server.expect(ByteString.encodeUtf8("\000" + USERNAME + "\000" + PASSWORD).base64());
server.output("2 NO Login Failure");
server.expect("3 LOGIN \"" + USERNAME + "\" \"" + PASSWORD + "\"");
server.output("3 OK LOGIN completed");
postAuthenticationDialogRequestingCapabilities(server, 4);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_authXoauthWithSaslIr.
@Test
public void open_authXoauthWithSaslIr() throws Exception {
settings.setAuthType(AuthType.XOAUTH2);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "SASL-IR AUTH=XOAUTH AUTH=XOAUTH2");
server.expect("2 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING);
server.output("2 OK Success");
postAuthenticationDialogRequestingCapabilities(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_authXoauthWithSaslIrWithOldTokenThrowsExceptionIfRetryFails.
@Test
public void open_authXoauthWithSaslIrWithOldTokenThrowsExceptionIfRetryFails() throws Exception {
settings.setAuthType(AuthType.XOAUTH2);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "SASL-IR AUTH=XOAUTH AUTH=XOAUTH2");
server.expect("2 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING);
server.output("+ r3j3krj3irj3oir3ojo");
server.expect("");
server.output("2 NO SASL authentication failed");
server.expect("3 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING_RETRY);
server.output("+ 433ba3a3a");
server.expect("");
server.output("3 NO SASL authentication failed");
postAuthenticationDialogRequestingCapabilities(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail();
} catch (AuthenticationFailedException e) {
assertEquals("Command: AUTHENTICATE XOAUTH2; response: #3# [NO, SASL authentication failed]", e.getMessage());
}
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_withCompressDeflateCapability_shouldEnableCompression.
@Test
public void open_withCompressDeflateCapability_shouldEnableCompression() throws Exception {
settings.setUseCompression(true);
MockImapServer server = new MockImapServer();
simplePreAuthAndLoginDialog(server, "COMPRESS=DEFLATE");
server.expect("3 COMPRESS DEFLATE");
server.output("3 OK");
server.enableCompression();
simplePostAuthenticationDialog(server, 4);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
Aggregations