Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 75179755 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #7380 from thunderbird/more_AuthenticationFailedException

Use `AuthenticationFailedException` when appropriate
parents 168a59bc 122eac0b
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -521,14 +521,7 @@ internal class RealImapConnection(
            val command = Commands.AUTHENTICATE_EXTERNAL + " " + Base64.encode(settings.username)
            executeSimpleCommand(command, false)
        } catch (e: NegativeImapResponseException) {
            /*
             * Provide notification to the user of a problem authenticating
             * using client certificates. We don't use an
             * AuthenticationFailedException because that would trigger a
             * "Username or password incorrect" notification in
             * AccountSetupCheckSettings.
             */
            throw CertificateValidationException(e.message)
            throw handleAuthenticationFailure(e)
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -520,11 +520,11 @@ class RealImapConnectionTest {
        }
        val imapConnection = startServerAndCreateImapConnection(server, authType = AuthType.EXTERNAL)

        // FIXME: improve exception message
        assertFailure {
            imapConnection.open()
        }.isInstanceOf<CertificateValidationException>()
            .message().isNotNull().contains("Bad certificate")
        }.isInstanceOf<AuthenticationFailedException>()
            .prop(AuthenticationFailedException::messageFromServer)
            .isEqualTo("Bad certificate")

        server.verifyConnectionClosed()
        server.verifyInteractionCompleted()
+1 −9
Original line number Diff line number Diff line
@@ -312,15 +312,7 @@ class Pop3Connection {
                    String.format("AUTH EXTERNAL %s",
                            Base64.encode(settings.getUsername())), false);
        } catch (Pop3ErrorResponse e) {
            /*
             * Provide notification to the user of a problem authenticating
             * using client certificates. We don't use an
             * AuthenticationFailedException because that would trigger a
             * "Username or password incorrect" notification in
             * AccountSetupCheckSettings.
             */
            throw new CertificateValidationException(
                    "POP3 client certificate authentication failed: " + e.getMessage(), e);
            throw new AuthenticationFailedException("AUTH EXTERNAL failed", e, e.getResponseText());
        }
    }

+1 −3
Original line number Diff line number Diff line
package com.fsck.k9.mail.store.pop3

import assertk.assertFailure
import assertk.assertions.hasMessage
import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import assertk.assertions.prop
@@ -319,8 +318,7 @@ class Pop3ConnectionTest {

        assertFailure {
            createAndOpenPop3Connection(settings)
        }.isInstanceOf<CertificateValidationException>()
            .hasMessage("POP3 client certificate authentication failed: -ERR Invalid certificate")
        }.isInstanceOf<AuthenticationFailedException>()

        server.verifyInteractionCompleted()
    }