use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class ImapConnectionTest method open_withStartTlsButWithoutStartTlsCapability_shouldThrow.
@Test
public void open_withStartTlsButWithoutStartTlsCapability_shouldThrow() throws Exception {
settings.setConnectionSecurity(ConnectionSecurity.STARTTLS_REQUIRED);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
//FIXME: CertificateValidationException seems wrong
assertEquals("STARTTLS connection security not available", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.CertificateValidationException in project k-9 by k9mail.
the class ImapConnectionTest method open_authExternalWithAuthenticationFailure_shouldThrow.
@Test
public void open_authExternalWithAuthenticationFailure_shouldThrow() throws Exception {
settings.setAuthType(AuthType.EXTERNAL);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=EXTERNAL");
server.expect("2 AUTHENTICATE EXTERNAL " + ByteString.encodeUtf8(USERNAME).base64());
server.output("2 NO Bad certificate");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
//FIXME: improve exception message
assertThat(e.getMessage(), containsString("Bad certificate"));
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.CertificateValidationException 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.CertificateValidationException 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.CertificateValidationException in project k-9 by k9mail.
the class ImapConnectionTest method open_authExternalWithoutAuthExternalCapability_shouldThrow.
@Test
public void open_authExternalWithoutAuthExternalCapability_shouldThrow() throws Exception {
settings.setAuthType(AuthType.EXTERNAL);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "AUTH=PLAIN");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (CertificateValidationException e) {
assertEquals(Reason.MissingCapability, e.getReason());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
Aggregations