use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_authPlainWithAuthenticationFailure_shouldFallbackToLogin.
@Test
public void open_authPlainWithAuthenticationFailure_shouldFallbackToLogin() 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 Login Failure");
server.expect("3 LOGIN \"" + USERNAME + "\" \"" + PASSWORD + "\"");
server.output("3 OK LOGIN completed");
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 ImapConnectionTest method open_authCramMd5WithoutAuthCramMd5Capability_shouldThrow.
@Test
public void open_authCramMd5WithoutAuthCramMd5Capability_shouldThrow() throws Exception {
settings.setAuthType(AuthType.CRAM_MD5);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=PLAIN");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (MessagingException e) {
assertEquals("Server doesn't support encrypted passwords using CRAM-MD5.", e.getMessage());
}
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_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnMissingStatusJsonResponse.
@Test
public void open_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnMissingStatusJsonResponse() throws Exception {
settings.setAuthType(AuthType.XOAUTH2);
when(oAuth2TokenProvider.getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT)).thenReturn("token").thenReturn("token2");
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "SASL-IR AUTH=XOAUTH AUTH=XOAUTH2");
server.expect("2 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING);
server.output("+ " + XOAuth2ChallengeParserTest.MISSING_STATUS_RESPONSE);
server.expect("");
server.output("2 NO SASL authentication failed");
server.expect("3 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING_RETRY);
server.output("3 OK Success");
simplePostAuthenticationDialog(server, "4");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
InOrder inOrder = inOrder(oAuth2TokenProvider);
inOrder.verify(oAuth2TokenProvider).getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT);
inOrder.verify(oAuth2TokenProvider).invalidateToken("user");
inOrder.verify(oAuth2TokenProvider).getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT);
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest 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");
simplePostAuthenticationDialog(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 ImapConnectionTest 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();
}
Aggregations