use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_withUntaggedPostAuthCapabilityResponse_shouldNotIssueCapabilityCommand.
@Test
public void open_withUntaggedPostAuthCapabilityResponse_shouldNotIssueCapabilityCommand() 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("* CAPABILITY IMAP4rev1 UNSELECT IDLE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS " + "ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE " + "APPENDLIMIT=35651584");
server.output("2 OK");
simplePostAuthenticationDialog(server, 3);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
assertTrue(imapConnection.isIdleCapable());
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest 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();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest 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();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_authPlainFailureAndDisconnect_shouldThrow.
@Test
public void open_authPlainFailureAndDisconnect_shouldThrow() 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 [UNAVAILABLE] Maximum number of connections from user+IP exceeded");
server.closeConnection();
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (NegativeImapResponseException e) {
assertThat(e.getMessage(), containsString("Maximum number of connections from user+IP exceeded"));
}
assertFalse(imapConnection.isConnected());
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_withIoExceptionDuringListCommand_shouldThrow.
@Test
public void open_withIoExceptionDuringListCommand_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
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();
}
Aggregations