Use AuthenticationFailedException
when appropriate
This commit is contained in:
parent
58155066e6
commit
122eac0b57
4 changed files with 6 additions and 23 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,7 +1,6 @@
|
|||
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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue