use of com.fsck.k9.mail.Transport in project k-9 by k9mail.
the class SmtpTransportTest method open_withoutAuthExternalExtension_shouldThrow.
@Test
public void open_withoutAuthExternalExtension_shouldThrow() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH");
server.expect("QUIT");
server.output("221 BYE");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.EXTERNAL, ConnectionSecurity.NONE);
try {
transport.open();
fail("Exception expected");
} catch (CertificateValidationException e) {
assertEquals(CertificateValidationException.Reason.MissingCapability, e.getReason());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.Transport in project k-9 by k9mail.
the class MessagingControllerTest method sendPendingMessagesSynchronous_withAuthenticationFailure_shouldNotify.
@Test
public void sendPendingMessagesSynchronous_withAuthenticationFailure_shouldNotify() throws MessagingException {
setupAccountWithMessageToSend();
doThrow(new AuthenticationFailedException("Test")).when(transport).sendMessage(localMessageToSend1);
controller.sendPendingMessagesSynchronous(account);
verify(notificationController).showAuthenticationErrorNotification(account, false);
}
use of com.fsck.k9.mail.Transport in project k-9 by k9mail.
the class MessagingControllerTest method sendPendingMessagesSynchronous_withCertificateFailure_shouldNotify.
@Test
public void sendPendingMessagesSynchronous_withCertificateFailure_shouldNotify() throws MessagingException {
setupAccountWithMessageToSend();
doThrow(new CertificateValidationException("Test")).when(transport).sendMessage(localMessageToSend1);
controller.sendPendingMessagesSynchronous(account);
verify(notificationController).showCertificateErrorNotification(account, false);
}
use of com.fsck.k9.mail.Transport in project k-9 by k9mail.
the class SmtpTransportTest method open_withAutomaticAuthAndNoTransportSecurityAndAuthCramMd5Extension_shouldUseAuthCramMd5.
@Test
public void open_withAutomaticAuthAndNoTransportSecurityAndAuthCramMd5Extension_shouldUseAuthCramMd5() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH CRAM-MD5");
server.expect("AUTH CRAM-MD5");
server.output(Base64.encode("<24609.1047914046@localhost>"));
server.expect("dXNlciA3NmYxNWEzZmYwYTNiOGI1NzcxZmNhODZlNTcyMDk2Zg==");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.AUTOMATIC, ConnectionSecurity.NONE);
transport.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.Transport in project k-9 by k9mail.
the class SmtpTransportTest method open_withXoauth2Extension_shouldInvalidateAndRetryOnMissingStatusJsonResponse.
@Test
public void open_withXoauth2Extension_shouldInvalidateAndRetryOnMissingStatusJsonResponse() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH XOAUTH2");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=");
server.output("334 " + XOAuth2ChallengeParserTest.MISSING_STATUS_RESPONSE);
server.expect("");
server.output("535-5.7.1 Username and Password not accepted. Learn more at");
server.output("535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 hx9sm5317360pbc.68");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG5ld1Rva2VuAQE=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
transport.open();
InOrder inOrder = inOrder(oAuth2TokenProvider);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
Aggregations