use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_withIoExceptionDuringCompressionCommand_shouldThrow.
@Test
public void open_withIoExceptionDuringCompressionCommand_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
settings.setUseCompression(true);
MockImapServer server = new MockImapServer();
simplePreAuthAndLoginDialog(server, "COMPRESS=DEFLATE");
server.expect("3 COMPRESS DEFLATE");
server.closeConnection();
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Exception expected");
} catch (IOException ignored) {
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest 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();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_authExternalWithAuthenticationFailure_shouldThrow.
@Test
public void open_authExternalWithAuthenticationFailure_shouldThrow() 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 NO Bad certificate");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
//FIXME: improve exception message
assertThat(e.getMessage(), containsString("Bad certificate"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest 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 ImapConnectionTest method open_withNegativeResponseToStartTlsCommand_shouldThrow.
@Test
public void open_withNegativeResponseToStartTlsCommand_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
settings.setConnectionSecurity(ConnectionSecurity.STARTTLS_REQUIRED);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "STARTTLS");
server.expect("2 STARTTLS");
server.output("2 NO");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (NegativeImapResponseException e) {
assertEquals(e.getMessage(), "Command: STARTTLS; response: #2# [NO]");
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
Aggregations