Remove unused default port functionality

This commit is contained in:
Wolf-Martell Montwé 2023-12-04 16:56:51 +01:00
parent b164243a57
commit ee3e9c4eb4
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
2 changed files with 0 additions and 46 deletions

View file

@ -2,12 +2,9 @@ package com.fsck.k9.account
import app.k9mail.core.common.mail.Protocols
import com.fsck.k9.Account.DeletePolicy
import com.fsck.k9.mail.ConnectionSecurity
/**
* Deals with logic surrounding account creation.
*
* TODO move this close to account creator
*/
class AccountCreatorHelper {
@ -19,25 +16,4 @@ class AccountCreatorHelper {
else -> throw AssertionError("Unhandled case: $type")
}
}
fun getDefaultPort(securityType: ConnectionSecurity, serverType: String): Int {
return when (serverType) {
Protocols.IMAP -> getImapDefaultPort(securityType)
Protocols.POP3 -> getPop3DefaultPort(securityType)
Protocols.SMTP -> getSmtpDefaultPort(securityType)
else -> throw AssertionError("Unhandled case: $serverType")
}
}
private fun getImapDefaultPort(connectionSecurity: ConnectionSecurity): Int {
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 993 else 143
}
private fun getPop3DefaultPort(connectionSecurity: ConnectionSecurity): Int {
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 995 else 110
}
private fun getSmtpDefaultPort(connectionSecurity: ConnectionSecurity): Int {
return if (connectionSecurity == ConnectionSecurity.SSL_TLS_REQUIRED) 465 else 587
}
}

View file

@ -5,7 +5,6 @@ import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import com.fsck.k9.Account.DeletePolicy
import com.fsck.k9.account.AccountCreatorHelper
import com.fsck.k9.mail.ConnectionSecurity
import org.junit.Test
class AccountCreatorHelperTest {
@ -31,25 +30,4 @@ class AccountCreatorHelperTest {
accountCreatorHelper.getDefaultDeletePolicy(Protocols.SMTP)
}.isInstanceOf<AssertionError>()
}
@Test
fun `getDefaultPort with NoConnectionSecurity and IMAP should return default port`() {
val result = accountCreatorHelper.getDefaultPort(ConnectionSecurity.NONE, Protocols.IMAP)
assertThat(result).isEqualTo(143)
}
@Test
fun `getDefaultPort with StartTls and IMAP should return default port`() {
val result = accountCreatorHelper.getDefaultPort(ConnectionSecurity.STARTTLS_REQUIRED, Protocols.IMAP)
assertThat(result).isEqualTo(143)
}
@Test
fun `getDefaultPort with Tls and IMAP should return default Tls port`() {
val result = accountCreatorHelper.getDefaultPort(ConnectionSecurity.SSL_TLS_REQUIRED, Protocols.IMAP)
assertThat(result).isEqualTo(993)
}
}