Merge pull request #7313 from thunderbird/remove_old_account_setup
Remove old account setup
This commit is contained in:
commit
189ac4de2a
10 changed files with 24 additions and 345 deletions
|
@ -66,11 +66,6 @@
|
|||
android:theme="@style/Theme.K9.Dialog.Translucent.DayNight"
|
||||
/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.setup.AccountSetupAccountType"
|
||||
android:configChanges="locale"
|
||||
android:label="@string/account_setup_account_type_title"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.setup.AccountSetupIncoming"
|
||||
android:configChanges="locale"
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
package com.fsck.k9.activity.setup
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import app.k9mail.core.common.mail.Protocols
|
||||
import app.k9mail.feature.account.oauth.domain.AccountOAuthDomainContract.UseCase.SuggestServerName
|
||||
import com.fsck.k9.Account
|
||||
import com.fsck.k9.Preferences
|
||||
import com.fsck.k9.helper.EmailHelper.getDomainFromEmailAddress
|
||||
import com.fsck.k9.mail.ConnectionSecurity
|
||||
import com.fsck.k9.mail.ServerSettings
|
||||
import com.fsck.k9.mailstore.SpecialLocalFoldersCreator
|
||||
import com.fsck.k9.ui.R
|
||||
import com.fsck.k9.ui.base.K9Activity
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
/**
|
||||
* Prompts the user to select an account type. The account type, along with the
|
||||
* passed in email address, password and makeDefault are then passed on to the
|
||||
* AccountSetupIncoming activity.
|
||||
*/
|
||||
class AccountSetupAccountType : K9Activity() {
|
||||
private val preferences: Preferences by inject()
|
||||
private val serverNameSuggester: SuggestServerName by inject()
|
||||
private val localFoldersCreator: SpecialLocalFoldersCreator by inject()
|
||||
|
||||
private lateinit var account: Account
|
||||
private var makeDefault = false
|
||||
private lateinit var initialAccountSettings: InitialAccountSettings
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setLayout(R.layout.account_setup_account_type)
|
||||
setTitle(R.string.account_setup_account_type_title)
|
||||
|
||||
decodeArguments()
|
||||
|
||||
findViewById<View>(R.id.pop).setOnClickListener { setupPop3Account() }
|
||||
findViewById<View>(R.id.imap).setOnClickListener { setupImapAccount() }
|
||||
}
|
||||
|
||||
private fun decodeArguments() {
|
||||
val accountUuid = intent.getStringExtra(EXTRA_ACCOUNT) ?: error("No account UUID provided")
|
||||
account = preferences.getAccount(accountUuid) ?: error("No account with given UUID found")
|
||||
makeDefault = intent.getBooleanExtra(EXTRA_MAKE_DEFAULT, false)
|
||||
initialAccountSettings = intent.getParcelableExtra(EXTRA_INITIAL_ACCOUNT_SETTINGS)
|
||||
?: error("Initial account settings are missing")
|
||||
}
|
||||
|
||||
private fun setupPop3Account() {
|
||||
setupAccount(Protocols.POP3)
|
||||
}
|
||||
|
||||
private fun setupImapAccount() {
|
||||
setupAccount(Protocols.IMAP)
|
||||
}
|
||||
|
||||
private fun setupAccount(serverType: String) {
|
||||
setupStoreAndSmtpTransport(serverType)
|
||||
createSpecialLocalFolders()
|
||||
returnAccountTypeSelectionResult()
|
||||
}
|
||||
|
||||
private fun setupStoreAndSmtpTransport(serverType: String) {
|
||||
val domainPart = getDomainFromEmailAddress(account.email) ?: error("Couldn't get domain from email address")
|
||||
|
||||
initializeIncomingServerSettings(serverType, domainPart)
|
||||
initializeOutgoingServerSettings(domainPart)
|
||||
}
|
||||
|
||||
private fun initializeIncomingServerSettings(serverType: String, domainPart: String) {
|
||||
val suggestedStoreServerName = serverNameSuggester.suggest(serverType, domainPart)
|
||||
val storeServer = ServerSettings(
|
||||
serverType,
|
||||
suggestedStoreServerName,
|
||||
-1,
|
||||
ConnectionSecurity.SSL_TLS_REQUIRED,
|
||||
initialAccountSettings.authenticationType,
|
||||
initialAccountSettings.email,
|
||||
initialAccountSettings.password,
|
||||
initialAccountSettings.clientCertificateAlias,
|
||||
)
|
||||
account.incomingServerSettings = storeServer
|
||||
}
|
||||
|
||||
private fun initializeOutgoingServerSettings(domainPart: String) {
|
||||
val suggestedTransportServerName = serverNameSuggester.suggest(Protocols.SMTP, domainPart)
|
||||
val transportServer = ServerSettings(
|
||||
Protocols.SMTP,
|
||||
suggestedTransportServerName,
|
||||
-1,
|
||||
ConnectionSecurity.STARTTLS_REQUIRED,
|
||||
initialAccountSettings.authenticationType,
|
||||
initialAccountSettings.email,
|
||||
initialAccountSettings.password,
|
||||
initialAccountSettings.clientCertificateAlias,
|
||||
)
|
||||
account.outgoingServerSettings = transportServer
|
||||
}
|
||||
|
||||
private fun createSpecialLocalFolders() {
|
||||
localFoldersCreator.createSpecialLocalFolders(account)
|
||||
}
|
||||
|
||||
private fun returnAccountTypeSelectionResult() {
|
||||
AccountSetupIncoming.actionIncomingSettings(this, account, makeDefault)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val EXTRA_ACCOUNT = "account"
|
||||
private const val EXTRA_MAKE_DEFAULT = "makeDefault"
|
||||
private const val EXTRA_INITIAL_ACCOUNT_SETTINGS = "initialAccountSettings"
|
||||
|
||||
@JvmStatic
|
||||
fun actionSelectAccountType(
|
||||
context: Context,
|
||||
account: Account,
|
||||
makeDefault: Boolean,
|
||||
initialAccountSettings: InitialAccountSettings,
|
||||
) {
|
||||
val intent = Intent(context, AccountSetupAccountType::class.java).apply {
|
||||
putExtra(EXTRA_ACCOUNT, account.uuid)
|
||||
putExtra(EXTRA_MAKE_DEFAULT, makeDefault)
|
||||
putExtra(EXTRA_INITIAL_ACCOUNT_SETTINGS, initialAccountSettings)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
|
||||
package com.fsck.k9.activity.setup;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -27,14 +24,12 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import app.k9mail.core.common.mail.Protocols;
|
||||
import app.k9mail.feature.account.oauth.domain.AccountOAuthDomainContract.UseCase.SuggestServerName;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.LocalKeyStoreManager;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.account.AccountCreatorHelper;
|
||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||
import com.fsck.k9.helper.EmailHelper;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
|
@ -52,15 +47,13 @@ import timber.log.Timber;
|
|||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
|
||||
@Deprecated(since = "Remove once the new account edit feature is the default")
|
||||
public class AccountSetupIncoming extends K9Activity implements OnClickListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
||||
private static final String STATE_SECURITY_TYPE_POSITION = "stateSecurityTypePosition";
|
||||
private static final String STATE_AUTH_TYPE_POSITION = "authTypePosition";
|
||||
|
||||
private final AccountCreatorHelper accountCreatorHelper = DI.get(AccountCreatorHelper.class);
|
||||
private final SuggestServerName serverNameSuggester = DI.get(SuggestServerName.class);
|
||||
|
||||
private String mStoreType;
|
||||
private TextInputEditText mUsernameView;
|
||||
|
@ -79,19 +72,10 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
private ViewGroup mAllowClientCertificateView;
|
||||
private Button mNextButton;
|
||||
private Account mAccount;
|
||||
private boolean mMakeDefault;
|
||||
private CheckBox useCompressionCheckBox;
|
||||
private CheckBox isSendClientIdEnabledCheckBox;
|
||||
private AuthTypeAdapter mAuthTypeAdapter;
|
||||
private ConnectionSecurity[] mConnectionSecurityChoices = ConnectionSecurity.values();
|
||||
private boolean editSettings;
|
||||
|
||||
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
|
||||
Intent i = new Intent(context, AccountSetupIncoming.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static void actionEditIncomingSettings(Context context, String accountUuid) {
|
||||
Intent intent = new Intent(context, AccountSetupIncoming.class);
|
||||
|
@ -152,7 +136,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
|
||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
mAccount = Preferences.getPreferences().getAccount(accountUuid);
|
||||
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
|
||||
|
||||
/*
|
||||
* If we're being reloaded we override the original account with the one
|
||||
|
@ -167,11 +150,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
mAuthTypeAdapter = AuthTypeAdapter.get(this, oAuthSupported);
|
||||
mAuthTypeView.setAdapter(mAuthTypeAdapter);
|
||||
|
||||
editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
|
||||
if (editSettings) {
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -216,10 +196,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
throw new Exception("Unknown account type: " + settings.type);
|
||||
}
|
||||
|
||||
if (!editSettings) {
|
||||
mAccount.setDeletePolicy(accountCreatorHelper.getDefaultDeletePolicy(settings.type));
|
||||
}
|
||||
|
||||
// Note that mConnectionSecurityChoices is configured above based on server type
|
||||
ConnectionSecurityAdapter securityTypesAdapter =
|
||||
ConnectionSecurityAdapter.get(this, mConnectionSecurityChoices);
|
||||
|
@ -331,15 +307,13 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
mServerView.addTextChangedListener(validationTextWatcher);
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
|
||||
if (editSettings) {
|
||||
TextInputLayoutHelper.configureAuthenticatedPasswordToggle(
|
||||
mPasswordLayoutView,
|
||||
this,
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_title),
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_subtitle),
|
||||
getString(R.string.account_setup_basics_show_password_need_lock)
|
||||
);
|
||||
}
|
||||
TextInputLayoutHelper.configureAuthenticatedPasswordToggle(
|
||||
mPasswordLayoutView,
|
||||
this,
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_title),
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_subtitle),
|
||||
getString(R.string.account_setup_basics_show_password_need_lock)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -492,36 +466,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
}
|
||||
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (editSettings) {
|
||||
Preferences.getPreferences().saveAccount(mAccount);
|
||||
finish();
|
||||
} else {
|
||||
/*
|
||||
* Set the username and password for the outgoing settings to the username and
|
||||
* password the user just set for incoming.
|
||||
*/
|
||||
String username = mUsernameView.getText().toString().trim();
|
||||
|
||||
String password = null;
|
||||
String clientCertificateAlias = null;
|
||||
AuthType authType = getSelectedAuthType();
|
||||
if ((ConnectionSecurity.SSL_TLS_REQUIRED == getSelectedSecurity()) ||
|
||||
(ConnectionSecurity.STARTTLS_REQUIRED == getSelectedSecurity()) ) {
|
||||
clientCertificateAlias = mClientCertificateSpinner.getAlias();
|
||||
}
|
||||
if (AuthType.EXTERNAL != authType) {
|
||||
password = mPasswordView.getText().toString();
|
||||
}
|
||||
|
||||
String domain = EmailHelper.getDomainFromEmailAddress(mAccount.getEmail());
|
||||
String host = serverNameSuggester.suggest(Protocols.SMTP, domain);
|
||||
ServerSettings transportServer = new ServerSettings(Protocols.SMTP, host,
|
||||
-1, ConnectionSecurity.SSL_TLS_REQUIRED, authType, username, password,
|
||||
clientCertificateAlias);
|
||||
mAccount.setOutgoingServerSettings(transportServer);
|
||||
|
||||
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount);
|
||||
}
|
||||
Preferences.getPreferences().saveAccount(mAccount);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package com.fsck.k9.activity.setup;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -45,6 +43,7 @@ import com.google.android.material.textfield.TextInputEditText;
|
|||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import timber.log.Timber;
|
||||
|
||||
@Deprecated(since = "Remove once the new account edit feature is the default")
|
||||
public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
OnCheckedChangeListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
@ -73,13 +72,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
private AuthTypeAdapter mAuthTypeAdapter;
|
||||
private Button mNextButton;
|
||||
private Account mAccount;
|
||||
private boolean editSettings;
|
||||
|
||||
public static void actionOutgoingSettings(Context context, Account account) {
|
||||
Intent i = new Intent(context, AccountSetupOutgoing.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static Intent intentActionEditOutgoingSettings(Context context, Account account) {
|
||||
Intent i = new Intent(context, AccountSetupOutgoing.class);
|
||||
|
@ -145,11 +137,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
mAccount = Preferences.getPreferences().getAccount(accountUuid);
|
||||
}
|
||||
|
||||
editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
|
||||
if (editSettings) {
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -310,15 +299,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
mServerView.addTextChangedListener(validationTextWatcher);
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
|
||||
if (editSettings) {
|
||||
TextInputLayoutHelper.configureAuthenticatedPasswordToggle(
|
||||
mPasswordLayoutView,
|
||||
this,
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_title),
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_subtitle),
|
||||
getString(R.string.account_setup_basics_show_password_need_lock)
|
||||
);
|
||||
}
|
||||
TextInputLayoutHelper.configureAuthenticatedPasswordToggle(
|
||||
mPasswordLayoutView,
|
||||
this,
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_title),
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_subtitle),
|
||||
getString(R.string.account_setup_basics_show_password_need_lock)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -492,12 +479,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
}
|
||||
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (editSettings) {
|
||||
Preferences.getPreferences().saveAccount(mAccount);
|
||||
finish();
|
||||
} else {
|
||||
// AccountSetupOptions.actionOptions(this, mAccount);
|
||||
}
|
||||
Preferences.getPreferences().saveAccount(mAccount);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.fsck.k9.activity.setup.AccountSetupAccountType">
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="6dip">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
android:paddingBottom="10dip"
|
||||
android:text="@string/account_setup_account_type_instructions"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/imap"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:minWidth="@dimen/button_minWidth"
|
||||
android:padding="10dip"
|
||||
android:text="@string/account_setup_account_type_imap_action" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/pop"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:minWidth="@dimen/button_minWidth"
|
||||
android:padding="10dip"
|
||||
android:text="@string/account_setup_account_type_pop_action" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -359,11 +359,6 @@
|
|||
<string name="account_setup_check_settings_fetch">Fetching account settings\u2026</string>
|
||||
<string name="account_setup_check_settings_canceling_msg">Canceling\u2026</string>
|
||||
|
||||
<string name="account_setup_account_type_title">Account type</string>
|
||||
<string name="account_setup_account_type_instructions">What kind of account is this?</string>
|
||||
<string name="account_setup_account_type_pop_action">POP3</string>
|
||||
<string name="account_setup_account_type_imap_action">IMAP</string>
|
||||
|
||||
<string name="account_setup_auth_type_normal_password">Normal password</string>
|
||||
<string name="account_setup_auth_type_insecure_password">Password, transmitted insecurely</string>
|
||||
<string name="account_setup_auth_type_encrypted_password">Encrypted password</string>
|
||||
|
|
|
@ -8,7 +8,6 @@ import app.k9mail.feature.account.oauth.domain.AccountOAuthDomainContract.UseCas
|
|||
import app.k9mail.feature.account.oauth.domain.usecase.CheckIsGoogleSignIn
|
||||
import app.k9mail.feature.account.oauth.domain.usecase.FinishOAuthSignIn
|
||||
import app.k9mail.feature.account.oauth.domain.usecase.GetOAuthRequestIntent
|
||||
import app.k9mail.feature.account.oauth.domain.usecase.SuggestServerName
|
||||
import app.k9mail.feature.account.oauth.ui.AccountOAuthContract
|
||||
import app.k9mail.feature.account.oauth.ui.AccountOAuthViewModel
|
||||
import net.openid.appauth.AuthorizationService
|
||||
|
@ -35,8 +34,6 @@ val featureAccountOAuthModule: Module = module {
|
|||
AuthorizationStateRepository()
|
||||
}
|
||||
|
||||
factory<UseCase.SuggestServerName> { SuggestServerName() }
|
||||
|
||||
factory<UseCase.GetOAuthRequestIntent> {
|
||||
GetOAuthRequestIntent(
|
||||
repository = get(),
|
||||
|
|
|
@ -11,10 +11,6 @@ import net.openid.appauth.AuthorizationResponse
|
|||
interface AccountOAuthDomainContract {
|
||||
|
||||
interface UseCase {
|
||||
fun interface SuggestServerName {
|
||||
fun suggest(protocol: String, domain: String): String
|
||||
}
|
||||
|
||||
fun interface GetOAuthRequestIntent {
|
||||
fun execute(hostname: String, emailAddress: String): AuthorizationIntentResult
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package app.k9mail.feature.account.oauth.domain.usecase
|
||||
|
||||
import app.k9mail.core.common.mail.Protocols
|
||||
import app.k9mail.feature.account.oauth.domain.AccountOAuthDomainContract.UseCase
|
||||
|
||||
@Deprecated("This is not needed anymore, remove once auth setup flow is updated")
|
||||
class SuggestServerName : UseCase.SuggestServerName {
|
||||
override fun suggest(protocol: String, domain: String): String = when (protocol) {
|
||||
Protocols.IMAP -> "imap.$domain"
|
||||
Protocols.SMTP -> "smtp.$domain"
|
||||
Protocols.POP3 -> "pop3.$domain"
|
||||
else -> throw AssertionError("Missed case: $protocol")
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package app.k9mail.feature.account.oauth.domain.usecase
|
||||
|
||||
import app.k9mail.core.common.mail.Protocols
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import org.junit.Test
|
||||
|
||||
class SuggestServerNameTest {
|
||||
|
||||
private val testSubject = SuggestServerName()
|
||||
|
||||
@Test
|
||||
fun `should suggest server name for IMAP server`() {
|
||||
val serverType = Protocols.IMAP
|
||||
val domain = "example.org"
|
||||
|
||||
val result = testSubject.suggest(serverType, domain)
|
||||
|
||||
assertThat(result).isEqualTo("imap.example.org")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should suggest server name for POP3 server`() {
|
||||
val serverType = Protocols.POP3
|
||||
val domain = "example.org"
|
||||
|
||||
val result = testSubject.suggest(serverType, domain)
|
||||
|
||||
assertThat(result).isEqualTo("pop3.example.org")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should suggest server name for SMTP server`() {
|
||||
val serverType = Protocols.SMTP
|
||||
val domain = "example.org"
|
||||
|
||||
val result = testSubject.suggest(serverType, domain)
|
||||
|
||||
assertThat(result).isEqualTo("smtp.example.org")
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue