use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method isConnected_afterOpenAndClose_shouldReturnFalse.
@Test
public void isConnected_afterOpenAndClose_shouldReturnFalse() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpen(server);
imapConnection.close();
boolean result = imapConnection.isConnected();
assertFalse(result);
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_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnInvalidJsonResponse.
@Test
public void open_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnInvalidJsonResponse() 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("+ " + XOAuth2ChallengeParserTest.INVALID_RESPONSE);
server.expect("");
server.output("2 NO SASL authentication failed");
server.expect("3 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING_RETRY);
server.output("3 OK Success");
requestCapabilities(server, 4);
simplePostAuthenticationDialog(server, 5);
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 hasCapability_withNotYetOpenedConnection_shouldConnectAndFetchCapabilities.
@Test
public void hasCapability_withNotYetOpenedConnection_shouldConnectAndFetchCapabilities() throws Exception {
MockImapServer server = new MockImapServer();
simpleOpenDialog(server, "X-SOMETHING");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
boolean capabilityPresent = imapConnection.hasCapability("X-SOMETHING");
assertTrue(capabilityPresent);
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_afterCloseWasCalled_shouldThrow.
@Test
public void open_afterCloseWasCalled_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server);
server.expect("2 LOGIN \"" + USERNAME + "\" \"" + PASSWORD + "\"");
server.output("2 OK LOGIN completed");
postAuthenticationDialogRequestingCapabilities(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
imapConnection.close();
try {
imapConnection.open();
fail("Expected exception");
} catch (IllegalStateException e) {
assertEquals("open() called after close(). Check wrapped exception to see where close() was called.", e.getMessage());
}
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_withNegativeResponseToListCommand.
@Test
public void open_withNegativeResponseToListCommand() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
simplePreAuthAndLoginDialog(server, "");
server.expect("3 LIST \"\" \"\"");
server.output("3 NO");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
Aggregations