use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class RealImapConnectionTest method open_authPlain.
@Test
public void open_authPlain() 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 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_withNoCapabilitiesInInitialResponse_shouldIssuePreAuthCapabilitiesCommand.
@Test
public void open_withNoCapabilitiesInInitialResponse_shouldIssuePreAuthCapabilitiesCommand() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
server.output("* OK example.org server");
server.expect("1 CAPABILITY");
server.output("* CAPABILITY IMAP4 IMAP4REV1 AUTH=PLAIN");
server.output("1 OK CAPABILITY Completed");
server.expect("2 AUTHENTICATE PLAIN");
server.output("+");
server.expect(ByteString.encodeUtf8("\000" + USERNAME + "\000" + PASSWORD).base64());
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_withPostAuthCapabilityResponse_shouldNotIssueCapabilityCommand.
@Test
public void open_withPostAuthCapabilityResponse_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("2 OK [CAPABILITY IDLE]");
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 open_withNegativeResponseToCompressionCommand_shouldContinue.
@Test
public void open_withNegativeResponseToCompressionCommand_shouldContinue() throws Exception {
settings.setAuthType(AuthType.PLAIN);
settings.setUseCompression(true);
MockImapServer server = new MockImapServer();
simplePreAuthAndLoginDialog(server, "COMPRESS=DEFLATE");
server.expect("3 COMPRESS DEFLATE");
server.output("3 NO");
simplePostAuthenticationDialog(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_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