use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method isIdleCapable_withIdleCapability.
@Test
public void isIdleCapable_withIdleCapability() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpenWithCapabilities(server, "IDLE");
boolean result = imapConnection.isIdleCapable();
assertTrue(result);
server.shutdown();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest 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 RealImapConnectionTest method isConnected_afterOpen_shouldReturnTrue.
@Test
public void isConnected_afterOpen_shouldReturnTrue() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpen(server);
boolean result = imapConnection.isConnected();
assertTrue(result);
server.verifyConnectionStillOpen();
server.shutdown();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_authCramMd5WithAuthenticationFailure_shouldThrow.
@Test
public void open_authCramMd5WithAuthenticationFailure_shouldThrow() 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 NO Who are you?");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (AuthenticationFailedException e) {
//FIXME: improve exception message
assertThat(e.getMessage(), containsString("Who are you?"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_authPlainWithByeResponseAndConnectionClose_shouldThrowAuthenticationFailedException.
@Test
public void open_authPlainWithByeResponseAndConnectionClose_shouldThrowAuthenticationFailedException() 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("* BYE Go away");
server.output("2 NO Login Failure");
server.closeConnection();
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (AuthenticationFailedException e) {
//FIXME: improve exception message
assertThat(e.getMessage(), containsString("Login Failure"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
Aggregations