Loading mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapConnection.kt +15 −0 Original line number Diff line number Diff line Loading @@ -449,7 +449,22 @@ internal class RealImapConnection( throw e } loginOrThrow(e) } } @Suppress("ThrowsCount") private fun loginOrThrow(originalException: AuthenticationFailedException): List<ImapResponse> { return try { login() } catch (e: AuthenticationFailedException) { throw e } catch (e: IOException) { Timber.d(e, "LOGIN fallback failed") throw originalException } catch (e: MessagingException) { Timber.d(e, "LOGIN fallback failed") throw originalException } } Loading mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapConnectionTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -990,6 +990,33 @@ class RealImapConnectionTest { server.verifyInteractionCompleted() } @Test fun `disconnect during LOGIN fallback should throw AuthenticationFailedException`() { val server = MockImapServer().apply { output("* OK example.org server") expect("1 CAPABILITY") output("* CAPABILITY IMAP4 IMAP4REV1 AUTH=PLAIN") output("1 OK CAPABILITY Completed") expect("2 AUTHENTICATE PLAIN") output("+") expect("\u0000$USERNAME\u0000$PASSWORD".base64()) output("2 NO AUTHENTICATE failed") expect("3 LOGIN \"$USERNAME\" \"$PASSWORD\"") output("* BYE IMAP server terminating connection") closeConnection() } val imapConnection = startServerAndCreateImapConnection(server) try { imapConnection.open() fail("Expected exception") } catch (e: AuthenticationFailedException) { assertThat(e.messageFromServer).isEqualTo("AUTHENTICATE failed") } server.verifyInteractionCompleted() } private fun createImapConnection( settings: ImapSettings, socketFactory: TrustedSocketFactory, Loading Loading
mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapConnection.kt +15 −0 Original line number Diff line number Diff line Loading @@ -449,7 +449,22 @@ internal class RealImapConnection( throw e } loginOrThrow(e) } } @Suppress("ThrowsCount") private fun loginOrThrow(originalException: AuthenticationFailedException): List<ImapResponse> { return try { login() } catch (e: AuthenticationFailedException) { throw e } catch (e: IOException) { Timber.d(e, "LOGIN fallback failed") throw originalException } catch (e: MessagingException) { Timber.d(e, "LOGIN fallback failed") throw originalException } } Loading
mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapConnectionTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -990,6 +990,33 @@ class RealImapConnectionTest { server.verifyInteractionCompleted() } @Test fun `disconnect during LOGIN fallback should throw AuthenticationFailedException`() { val server = MockImapServer().apply { output("* OK example.org server") expect("1 CAPABILITY") output("* CAPABILITY IMAP4 IMAP4REV1 AUTH=PLAIN") output("1 OK CAPABILITY Completed") expect("2 AUTHENTICATE PLAIN") output("+") expect("\u0000$USERNAME\u0000$PASSWORD".base64()) output("2 NO AUTHENTICATE failed") expect("3 LOGIN \"$USERNAME\" \"$PASSWORD\"") output("* BYE IMAP server terminating connection") closeConnection() } val imapConnection = startServerAndCreateImapConnection(server) try { imapConnection.open() fail("Expected exception") } catch (e: AuthenticationFailedException) { assertThat(e.messageFromServer).isEqualTo("AUTHENTICATE failed") } server.verifyInteractionCompleted() } private fun createImapConnection( settings: ImapSettings, socketFactory: TrustedSocketFactory, Loading