mirror of
https://github.com/thunderbird/thunderbird-android.git
synced 2024-09-19 19:52:14 +02:00
Remove AuthType.AUTOMATIC
and AuthType.LOGIN
This commit is contained in:
parent
6d5abf3461
commit
69282c9bc4
@ -411,7 +411,7 @@ public class StoreSchemaDefinitionTest extends K9RobolectricTest {
|
||||
when(account.getLocalStorageProviderId()).thenReturn(StorageManager.InternalStorageProvider.ID);
|
||||
|
||||
ServerSettings incomingServerSettings = new ServerSettings("dummy", "", -1, ConnectionSecurity.NONE,
|
||||
AuthType.AUTOMATIC, "", "", null);
|
||||
AuthType.PLAIN, "", "", null);
|
||||
when(account.getIncomingServerSettings()).thenReturn(incomingServerSettings);
|
||||
return account;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ object DemoServerSettings : IncomingServerSettings, OutgoingServerSettings {
|
||||
host = "irrelevant",
|
||||
port = 23,
|
||||
connectionSecurity = ConnectionSecurity.SSL_TLS_REQUIRED,
|
||||
authenticationType = AuthType.AUTOMATIC,
|
||||
authenticationType = AuthType.PLAIN,
|
||||
username = "irrelevant",
|
||||
password = "irrelevant",
|
||||
clientCertificateAlias = null,
|
||||
|
@ -22,13 +22,4 @@ public enum AuthType {
|
||||
* https://developers.google.com/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism
|
||||
*/
|
||||
XOAUTH2,
|
||||
|
||||
/*
|
||||
* The following are obsolete authentication settings that were used with
|
||||
* SMTP. They are no longer presented to the user as options, but they may
|
||||
* still exist in a user's settings from a previous version or may be found
|
||||
* when importing settings.
|
||||
*/
|
||||
AUTOMATIC,
|
||||
LOGIN
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import assertk.assertions.prop
|
||||
import com.fsck.k9.mail.AuthType
|
||||
import com.fsck.k9.mail.AuthType.CRAM_MD5
|
||||
import com.fsck.k9.mail.AuthType.EXTERNAL
|
||||
import com.fsck.k9.mail.AuthType.LOGIN
|
||||
import com.fsck.k9.mail.AuthType.PLAIN
|
||||
import com.fsck.k9.mail.AuthenticationFailedException
|
||||
import com.fsck.k9.mail.CertificateChainException
|
||||
@ -384,7 +383,7 @@ class Pop3ConnectionTest {
|
||||
}
|
||||
|
||||
private fun MockPop3Server.createSettings(
|
||||
authType: AuthType = LOGIN,
|
||||
authType: AuthType = PLAIN,
|
||||
connectionSecurity: ConnectionSecurity = NONE,
|
||||
): Pop3Settings {
|
||||
return SimplePop3Settings().apply {
|
||||
|
@ -152,7 +152,7 @@ class SmtpTransport(
|
||||
(!password.isNullOrEmpty() || AuthType.EXTERNAL == authType || AuthType.XOAUTH2 == authType)
|
||||
) {
|
||||
when (authType) {
|
||||
AuthType.LOGIN, AuthType.PLAIN -> {
|
||||
AuthType.PLAIN -> {
|
||||
// try saslAuthPlain first, because it supports UTF-8 explicitly
|
||||
if (authPlainSupported) {
|
||||
saslAuthPlain()
|
||||
@ -187,32 +187,6 @@ class SmtpTransport(
|
||||
throw MissingCapabilityException("AUTH EXTERNAL")
|
||||
}
|
||||
}
|
||||
AuthType.AUTOMATIC -> {
|
||||
if (secureConnection) {
|
||||
// try saslAuthPlain first, because it supports UTF-8 explicitly
|
||||
if (authPlainSupported) {
|
||||
saslAuthPlain()
|
||||
} else if (authLoginSupported) {
|
||||
saslAuthLogin()
|
||||
} else if (authCramMD5Supported) {
|
||||
saslAuthCramMD5()
|
||||
} else {
|
||||
throw MissingCapabilityException("AUTH PLAIN")
|
||||
}
|
||||
} else {
|
||||
if (authCramMD5Supported) {
|
||||
saslAuthCramMD5()
|
||||
} else {
|
||||
// We refuse to insecurely transmit the password using the obsolete AUTOMATIC setting
|
||||
// because of the potential for a MITM attack. Affected users must choose a different
|
||||
// setting.
|
||||
throw MessagingException(
|
||||
"Update your outgoing server authentication setting. " +
|
||||
"AUTOMATIC authentication is unavailable.",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
throw MessagingException("Unhandled authentication method found in server settings (bug).")
|
||||
}
|
||||
|
@ -464,54 +464,6 @@ class SmtpTransportTest {
|
||||
server.verifyInteractionCompleted()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `open() with automatic auth and no transport security and AUTH CRAM-MD5 extension should use CRAM-MD5`() {
|
||||
val server = MockSmtpServer().apply {
|
||||
output("220 localhost Simple Mail Transfer Service Ready")
|
||||
expect("EHLO [127.0.0.1]")
|
||||
output("250-localhost Hello client.localhost")
|
||||
output("250 AUTH CRAM-MD5")
|
||||
expect("AUTH CRAM-MD5")
|
||||
output("334 " + Base64.encode("<24609.1047914046@localhost>"))
|
||||
expect("dXNlciAyZDBlNTcwYzZlYWI0ZjY3ZDUyZmFkN2Q1NGExZDJhYQ==")
|
||||
output("235 2.7.0 Authentication successful")
|
||||
}
|
||||
val transport = startServerAndCreateSmtpTransport(
|
||||
server,
|
||||
authenticationType = AuthType.AUTOMATIC,
|
||||
connectionSecurity = ConnectionSecurity.NONE,
|
||||
)
|
||||
|
||||
transport.open()
|
||||
|
||||
server.verifyConnectionStillOpen()
|
||||
server.verifyInteractionCompleted()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `open() with automatic auth and no transport security and AUTH PLAIN extension should throw`() {
|
||||
val server = MockSmtpServer()
|
||||
server.output("220 localhost Simple Mail Transfer Service Ready")
|
||||
server.expect("EHLO [127.0.0.1]")
|
||||
server.output("250-localhost Hello client.localhost")
|
||||
server.output("250 AUTH PLAIN LOGIN")
|
||||
server.expect("QUIT")
|
||||
server.output("221 BYE")
|
||||
val transport = startServerAndCreateSmtpTransport(
|
||||
server,
|
||||
authenticationType = AuthType.AUTOMATIC,
|
||||
connectionSecurity = ConnectionSecurity.NONE,
|
||||
)
|
||||
|
||||
assertFailure {
|
||||
transport.open()
|
||||
}.isInstanceOf<MessagingException>()
|
||||
.hasMessage("Update your outgoing server authentication setting. AUTOMATIC authentication is unavailable.")
|
||||
|
||||
server.verifyConnectionClosed()
|
||||
server.verifyInteractionCompleted()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `open() with EHLO failing should try HELO`() {
|
||||
val server = MockSmtpServer().apply {
|
||||
|
Loading…
Reference in New Issue
Block a user