From dcad7a95b615c6f85a6f8a153d1de92a654e37aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Tue, 5 Sep 2023 17:10:44 +0200 Subject: [PATCH] Move server certificate to server module --- .../com/fsck/k9/DependencyInjectionTest.kt | 8 +++-- .../certificate}/build.gradle.kts | 4 +-- .../certificate/ServerCertificateModule.kt | 29 +++++++++++++++++++ ...nMemoryServerCertificateErrorRepository.kt | 8 ++--- .../ServerCertificateDomainContract.kt} | 6 ++-- .../domain/entity/ServerCertificateError.kt | 2 +- .../usecase/AddServerCertificateException.kt | 4 +-- .../ui/ServerCertificateErrorContract.kt} | 4 +-- .../ui/ServerCertificateErrorScreen.kt} | 22 +++++++------- .../ui/ServerCertificateErrorViewModel.kt} | 20 ++++++------- .../ServerCertificateModuleKtTest.kt} | 8 ++--- .../server/validation/build.gradle.kts | 2 +- .../validation/ServerValidationModule.kt | 2 +- .../ui/ServerValidationMainScreen.kt | 2 +- .../validation/ui/ServerValidationScreen.kt | 4 +-- .../ui/ServerValidationViewModel.kt | 6 ++-- .../ServerValidationModuleKtTest.kt | 8 ++--- .../ui/ServerValidationViewModelTest.kt | 2 +- .../AccountServerCertificateModule.kt | 29 ------------------- feature/account/setup/build.gradle.kts | 2 +- .../account/setup/AccountSetupModuleKtTest.kt | 4 +-- settings.gradle.kts | 2 +- 22 files changed, 91 insertions(+), 87 deletions(-) rename feature/account/{servercertificate => server/certificate}/build.gradle.kts (74%) create mode 100644 feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModule.kt rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate}/data/InMemoryServerCertificateErrorRepository.kt (59%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/AccountServerCertificateDomainContract.kt => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/ServerCertificateDomainContract.kt} (70%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate}/domain/entity/ServerCertificateError.kt (72%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate}/domain/usecase/AddServerCertificateException.kt (78%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorContract.kt => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorContract.kt} (81%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorScreen.kt => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorScreen.kt} (89%) rename feature/account/{servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorViewModel.kt => server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorViewModel.kt} (79%) rename feature/account/{servercertificate/src/test/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModuleKtTest.kt => server/certificate/src/test/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModuleKtTest.kt} (74%) delete mode 100644 feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModule.kt diff --git a/app/k9mail/src/test/java/com/fsck/k9/DependencyInjectionTest.kt b/app/k9mail/src/test/java/com/fsck/k9/DependencyInjectionTest.kt index f3cbf1e39..3593d9fba 100644 --- a/app/k9mail/src/test/java/com/fsck/k9/DependencyInjectionTest.kt +++ b/app/k9mail/src/test/java/com/fsck/k9/DependencyInjectionTest.kt @@ -61,8 +61,12 @@ class DependencyInjectionTest : AutoCloseKoinTest() { withParameters(clazz = Class.forName("com.fsck.k9.view.K9WebViewClient").kotlin) { parametersOf(null, null) } - withParameter(named(KOIN_NAME_INCOMING_SERVER_VALIDATION)) { authStateStorage } - withParameter(named(KOIN_NAME_OUTGOING_SERVER_VALIDATION)) { authStateStorage } + withParameter( + named(KOIN_NAME_INCOMING_SERVER_VALIDATION), + ) { authStateStorage } + withParameter( + named(KOIN_NAME_OUTGOING_SERVER_VALIDATION), + ) { authStateStorage } withParameter { authStateStorage } withParameter { mock() } } diff --git a/feature/account/servercertificate/build.gradle.kts b/feature/account/server/certificate/build.gradle.kts similarity index 74% rename from feature/account/servercertificate/build.gradle.kts rename to feature/account/server/certificate/build.gradle.kts index ac04d5f40..a392d2994 100644 --- a/feature/account/servercertificate/build.gradle.kts +++ b/feature/account/server/certificate/build.gradle.kts @@ -3,8 +3,8 @@ plugins { } android { - namespace = "app.k9mail.feature.account.servercertificate" - resourcePrefix = "account_servercertificate_" + namespace = "app.k9mail.feature.account.server.certificate" + resourcePrefix = "account_server_certificate_" } dependencies { diff --git a/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModule.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModule.kt new file mode 100644 index 000000000..8f006c127 --- /dev/null +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModule.kt @@ -0,0 +1,29 @@ +package app.k9mail.feature.account.server.certificate + +import app.k9mail.feature.account.server.certificate.data.InMemoryServerCertificateErrorRepository +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract +import app.k9mail.feature.account.server.certificate.domain.usecase.AddServerCertificateException +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorViewModel +import org.koin.androidx.viewmodel.dsl.viewModel +import org.koin.core.module.Module +import org.koin.dsl.module + +val featureAccountServerCertificateModule: Module = module { + + single { + InMemoryServerCertificateErrorRepository() + } + + factory { + AddServerCertificateException( + localKeyStore = get(), + ) + } + + viewModel { + ServerCertificateErrorViewModel( + certificateErrorRepository = get(), + addServerCertificateException = get(), + ) + } +} diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/data/InMemoryServerCertificateErrorRepository.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/data/InMemoryServerCertificateErrorRepository.kt similarity index 59% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/data/InMemoryServerCertificateErrorRepository.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/data/InMemoryServerCertificateErrorRepository.kt index 61a2786ee..f07bd3228 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/data/InMemoryServerCertificateErrorRepository.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/data/InMemoryServerCertificateErrorRepository.kt @@ -1,11 +1,11 @@ -package app.k9mail.feature.account.servercertificate.data +package app.k9mail.feature.account.server.certificate.data -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract -import app.k9mail.feature.account.servercertificate.domain.entity.ServerCertificateError +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract +import app.k9mail.feature.account.server.certificate.domain.entity.ServerCertificateError class InMemoryServerCertificateErrorRepository( private var serverCertificateError: ServerCertificateError? = null, -) : AccountServerCertificateDomainContract.ServerCertificateErrorRepository { +) : ServerCertificateDomainContract.ServerCertificateErrorRepository { override fun getCertificateError(): ServerCertificateError? { return serverCertificateError diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/AccountServerCertificateDomainContract.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/ServerCertificateDomainContract.kt similarity index 70% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/AccountServerCertificateDomainContract.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/ServerCertificateDomainContract.kt index dd5d8e8ee..66700cc34 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/AccountServerCertificateDomainContract.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/ServerCertificateDomainContract.kt @@ -1,9 +1,9 @@ -package app.k9mail.feature.account.servercertificate.domain +package app.k9mail.feature.account.server.certificate.domain -import app.k9mail.feature.account.servercertificate.domain.entity.ServerCertificateError +import app.k9mail.feature.account.server.certificate.domain.entity.ServerCertificateError import java.security.cert.X509Certificate -interface AccountServerCertificateDomainContract { +interface ServerCertificateDomainContract { interface ServerCertificateErrorRepository { fun getCertificateError(): ServerCertificateError? diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/entity/ServerCertificateError.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/entity/ServerCertificateError.kt similarity index 72% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/entity/ServerCertificateError.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/entity/ServerCertificateError.kt index 796b6d41a..5a558ad59 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/entity/ServerCertificateError.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/entity/ServerCertificateError.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.servercertificate.domain.entity +package app.k9mail.feature.account.server.certificate.domain.entity import java.security.cert.X509Certificate diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/usecase/AddServerCertificateException.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/usecase/AddServerCertificateException.kt similarity index 78% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/usecase/AddServerCertificateException.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/usecase/AddServerCertificateException.kt index baf3c3d4f..de65461cc 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/domain/usecase/AddServerCertificateException.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/domain/usecase/AddServerCertificateException.kt @@ -1,6 +1,6 @@ -package app.k9mail.feature.account.servercertificate.domain.usecase +package app.k9mail.feature.account.server.certificate.domain.usecase -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract.UseCase +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract.UseCase import com.fsck.k9.mail.ssl.LocalKeyStore import java.security.cert.X509Certificate import kotlinx.coroutines.CoroutineDispatcher diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorContract.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorContract.kt similarity index 81% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorContract.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorContract.kt index e5f21ab86..60278650b 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorContract.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorContract.kt @@ -1,8 +1,8 @@ -package app.k9mail.feature.account.servercertificate.ui +package app.k9mail.feature.account.server.certificate.ui import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel -interface AccountServerCertificateErrorContract { +interface ServerCertificateErrorContract { interface ViewModel : UnidirectionalViewModel diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorScreen.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorScreen.kt similarity index 89% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorScreen.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorScreen.kt index 7c0a4343a..bcf6bc633 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorScreen.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorScreen.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.servercertificate.ui +package app.k9mail.feature.account.server.certificate.ui import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Column @@ -21,11 +21,11 @@ import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer import app.k9mail.core.ui.compose.designsystem.template.Scaffold import app.k9mail.core.ui.compose.theme.K9Theme import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.feature.account.servercertificate.data.InMemoryServerCertificateErrorRepository -import app.k9mail.feature.account.servercertificate.domain.entity.ServerCertificateError -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.Effect -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.Event -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.ViewModel +import app.k9mail.feature.account.server.certificate.data.InMemoryServerCertificateErrorRepository +import app.k9mail.feature.account.server.certificate.domain.entity.ServerCertificateError +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.Effect +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.Event +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.ViewModel import java.security.cert.CertificateFactory import java.security.cert.X509Certificate import org.koin.androidx.compose.koinViewModel @@ -33,11 +33,11 @@ import org.koin.androidx.compose.koinViewModel // Note: This is a placeholder with mostly hardcoded text. // TODO: Replace with final design. @Composable -fun CertificateErrorScreen( +fun ServerCertificateErrorScreen( onCertificateAccepted: () -> Unit, onBack: () -> Unit, modifier: Modifier = Modifier, - viewModel: ViewModel = koinViewModel(), + viewModel: ViewModel = koinViewModel(), ) { val (state, dispatch) = viewModel.observe { effect -> when (effect) { @@ -102,7 +102,7 @@ fun CertificateErrorScreen( @Composable @DevicePreviews -internal fun CertificateErrorScreenK9Preview() { +internal fun ServerCertificateErrorScreenK9Preview() { val inputStream = """ -----BEGIN CERTIFICATE----- MIIE8jCCA9qgAwIBAgISA3bsPKY1eoe/RiBO2t8fUvh1MA0GCSqGSIb3DQEBCwUA @@ -145,10 +145,10 @@ internal fun CertificateErrorScreenK9Preview() { ) K9Theme { - CertificateErrorScreen( + ServerCertificateErrorScreen( onCertificateAccepted = {}, onBack = {}, - viewModel = AccountServerCertificateErrorViewModel( + viewModel = ServerCertificateErrorViewModel( addServerCertificateException = { _, _, _ -> }, certificateErrorRepository = InMemoryServerCertificateErrorRepository(serverCertificateError), ), diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorViewModel.kt b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorViewModel.kt similarity index 79% rename from feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorViewModel.kt rename to feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorViewModel.kt index 58641a40b..15184b603 100644 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/ui/AccountServerCertificateErrorViewModel.kt +++ b/feature/account/server/certificate/src/main/kotlin/app/k9mail/feature/account/server/certificate/ui/ServerCertificateErrorViewModel.kt @@ -1,13 +1,13 @@ -package app.k9mail.feature.account.servercertificate.ui +package app.k9mail.feature.account.server.certificate.ui import androidx.lifecycle.viewModelScope import app.k9mail.core.ui.compose.common.mvi.BaseViewModel -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract.UseCase -import app.k9mail.feature.account.servercertificate.domain.entity.ServerCertificateError -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.Effect -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.Event -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract.State +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract.UseCase +import app.k9mail.feature.account.server.certificate.domain.entity.ServerCertificateError +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.Effect +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.Event +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract.State import com.fsck.k9.logging.Timber import com.fsck.k9.mail.filter.Hex import java.security.MessageDigest @@ -15,11 +15,11 @@ import java.security.NoSuchAlgorithmException import java.security.cert.CertificateEncodingException import kotlinx.coroutines.launch -class AccountServerCertificateErrorViewModel( - private val certificateErrorRepository: AccountServerCertificateDomainContract.ServerCertificateErrorRepository, +class ServerCertificateErrorViewModel( + private val certificateErrorRepository: ServerCertificateDomainContract.ServerCertificateErrorRepository, private val addServerCertificateException: UseCase.AddServerCertificateException, initialState: State = State(), -) : BaseViewModel(initialState), AccountServerCertificateErrorContract.ViewModel { +) : BaseViewModel(initialState), ServerCertificateErrorContract.ViewModel { private val serverCertificateError: ServerCertificateError? = certificateErrorRepository.getCertificateError() init { diff --git a/feature/account/servercertificate/src/test/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModuleKtTest.kt b/feature/account/server/certificate/src/test/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModuleKtTest.kt similarity index 74% rename from feature/account/servercertificate/src/test/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModuleKtTest.kt rename to feature/account/server/certificate/src/test/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModuleKtTest.kt index 2009862fb..0247bd8b3 100644 --- a/feature/account/servercertificate/src/test/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModuleKtTest.kt +++ b/feature/account/server/certificate/src/test/kotlin/app/k9mail/feature/account/server/certificate/ServerCertificateModuleKtTest.kt @@ -1,6 +1,6 @@ -package app.k9mail.feature.account.servercertificate +package app.k9mail.feature.account.server.certificate -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract import com.fsck.k9.mail.ssl.LocalKeyStore import org.junit.Test import org.koin.core.annotation.KoinExperimentalAPI @@ -12,7 +12,7 @@ import org.koin.test.check.checkModules import org.koin.test.verify.verify import org.mockito.Mockito -class AccountServerCertificateModuleKtTest : KoinTest { +class ServerCertificateModuleKtTest : KoinTest { private val externalModule: Module = module { single { Mockito.mock() } @@ -23,7 +23,7 @@ class AccountServerCertificateModuleKtTest : KoinTest { fun `should have a valid di module`() { featureAccountServerCertificateModule.verify( extraTypes = listOf( - AccountServerCertificateErrorContract.State::class, + ServerCertificateErrorContract.State::class, ), ) diff --git a/feature/account/server/validation/build.gradle.kts b/feature/account/server/validation/build.gradle.kts index aa23f22b6..75c9d1be0 100644 --- a/feature/account/server/validation/build.gradle.kts +++ b/feature/account/server/validation/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { implementation(projects.feature.account.common) implementation(projects.feature.account.oauth) - implementation(projects.feature.account.servercertificate) + implementation(projects.feature.account.server.certificate) testImplementation(projects.core.ui.compose.testing) } diff --git a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModule.kt b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModule.kt index 3fe94c8b2..6c9bc29e7 100644 --- a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModule.kt +++ b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModule.kt @@ -3,10 +3,10 @@ package app.k9mail.feature.account.server.validation import app.k9mail.core.common.coreCommonModule import app.k9mail.feature.account.common.featureAccountCommonModule import app.k9mail.feature.account.oauth.featureAccountOAuthModule +import app.k9mail.feature.account.server.certificate.featureAccountServerCertificateModule import app.k9mail.feature.account.server.validation.domain.ServerValidationDomainContract import app.k9mail.feature.account.server.validation.domain.usecase.ValidateServerSettings import app.k9mail.feature.account.server.validation.ui.ServerValidationViewModel -import app.k9mail.feature.account.servercertificate.featureAccountServerCertificateModule import com.fsck.k9.mail.store.imap.ImapServerSettingsValidator import com.fsck.k9.mail.store.pop3.Pop3ServerSettingsValidator import com.fsck.k9.mail.transport.smtp.SmtpServerSettingsValidator diff --git a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationMainScreen.kt b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationMainScreen.kt index 0e34bad7e..0d1db380f 100644 --- a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationMainScreen.kt +++ b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationMainScreen.kt @@ -12,9 +12,9 @@ import app.k9mail.feature.account.common.ui.WizardNavigationBar import app.k9mail.feature.account.common.ui.WizardNavigationBarState import app.k9mail.feature.account.common.ui.preview.PreviewAccountStateRepository import app.k9mail.feature.account.oauth.ui.preview.PreviewAccountOAuthViewModel +import app.k9mail.feature.account.server.certificate.data.InMemoryServerCertificateErrorRepository import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Event import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.ViewModel -import app.k9mail.feature.account.servercertificate.data.InMemoryServerCertificateErrorRepository import com.fsck.k9.mail.server.ServerSettingsValidationResult @Composable diff --git a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationScreen.kt b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationScreen.kt index 5e79d0854..32f16da0d 100644 --- a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationScreen.kt +++ b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationScreen.kt @@ -5,10 +5,10 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import app.k9mail.core.ui.compose.common.mvi.observe +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorScreen import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Effect import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Event import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.ViewModel -import app.k9mail.feature.account.servercertificate.ui.CertificateErrorScreen @Composable fun ServerValidationScreen( @@ -33,7 +33,7 @@ fun ServerValidationScreen( } if (state.value.error is ServerValidationContract.Error.CertificateError) { - CertificateErrorScreen( + ServerCertificateErrorScreen( onCertificateAccepted = { dispatch(Event.OnCertificateAccepted) }, onBack = { dispatch(Event.OnBackClicked) }, modifier = modifier, diff --git a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModel.kt b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModel.kt index 15653a7c4..bdd457c3e 100644 --- a/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModel.kt +++ b/feature/account/server/validation/src/main/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModel.kt @@ -7,13 +7,13 @@ import app.k9mail.feature.account.oauth.domain.AccountOAuthDomainContract import app.k9mail.feature.account.oauth.domain.entity.OAuthResult import app.k9mail.feature.account.oauth.domain.entity.isOAuth import app.k9mail.feature.account.oauth.ui.AccountOAuthContract +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract +import app.k9mail.feature.account.server.certificate.domain.entity.ServerCertificateError import app.k9mail.feature.account.server.validation.domain.ServerValidationDomainContract import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Effect import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Error import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Event import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.State -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract -import app.k9mail.feature.account.servercertificate.domain.entity.ServerCertificateError import com.fsck.k9.mail.server.ServerSettingsValidationResult import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.delay @@ -26,7 +26,7 @@ class ServerValidationViewModel( private val accountStateRepository: AccountDomainContract.AccountStateRepository, private val validateServerSettings: ServerValidationDomainContract.UseCase.ValidateServerSettings, private val authorizationStateRepository: AccountOAuthDomainContract.AuthorizationStateRepository, - private val certificateErrorRepository: AccountServerCertificateDomainContract.ServerCertificateErrorRepository, + private val certificateErrorRepository: ServerCertificateDomainContract.ServerCertificateErrorRepository, override val oAuthViewModel: AccountOAuthContract.ViewModel, override val isIncomingValidation: Boolean = true, initialState: State? = null, diff --git a/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModuleKtTest.kt b/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModuleKtTest.kt index a7444692b..e6d2f7bda 100644 --- a/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModuleKtTest.kt +++ b/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ServerValidationModuleKtTest.kt @@ -4,9 +4,9 @@ import android.content.Context import app.k9mail.core.common.oauth.OAuthConfigurationFactory import app.k9mail.feature.account.common.domain.AccountDomainContract import app.k9mail.feature.account.common.domain.entity.AccountState +import app.k9mail.feature.account.server.certificate.domain.ServerCertificateDomainContract +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract import app.k9mail.feature.account.server.validation.ui.ServerValidationContract -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract import com.fsck.k9.mail.oauth.OAuth2TokenProvider import com.fsck.k9.mail.oauth.OAuth2TokenProviderFactory import com.fsck.k9.mail.ssl.LocalKeyStore @@ -51,8 +51,8 @@ class ServerValidationModuleKtTest : KoinTest { extraTypes = listOf( ServerValidationContract.State::class, AccountDomainContract.AccountStateRepository::class, - AccountServerCertificateDomainContract.ServerCertificateErrorRepository::class, - AccountServerCertificateErrorContract.State::class, + ServerCertificateDomainContract.ServerCertificateErrorRepository::class, + ServerCertificateErrorContract.State::class, AccountState::class, Context::class, Boolean::class, diff --git a/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModelTest.kt b/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModelTest.kt index f963ccb7f..a482fdf65 100644 --- a/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModelTest.kt +++ b/feature/account/server/validation/src/test/kotlin/app/k9mail/feature/account/server/validation/ui/ServerValidationViewModelTest.kt @@ -6,11 +6,11 @@ import app.k9mail.core.ui.compose.testing.mvi.turbinesWithInitialStateCheck import app.k9mail.feature.account.common.data.InMemoryAccountStateRepository import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.oauth.ui.fake.FakeAccountOAuthViewModel +import app.k9mail.feature.account.server.certificate.data.InMemoryServerCertificateErrorRepository import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Effect import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Error import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.Event import app.k9mail.feature.account.server.validation.ui.ServerValidationContract.State -import app.k9mail.feature.account.servercertificate.data.InMemoryServerCertificateErrorRepository import assertk.assertThat import assertk.assertions.isEqualTo import assertk.assertions.isTrue diff --git a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModule.kt b/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModule.kt deleted file mode 100644 index 94de6d5e3..000000000 --- a/feature/account/servercertificate/src/main/kotlin/app/k9mail/feature/account/servercertificate/AccountServerCertificateModule.kt +++ /dev/null @@ -1,29 +0,0 @@ -package app.k9mail.feature.account.servercertificate - -import app.k9mail.feature.account.servercertificate.data.InMemoryServerCertificateErrorRepository -import app.k9mail.feature.account.servercertificate.domain.AccountServerCertificateDomainContract -import app.k9mail.feature.account.servercertificate.domain.usecase.AddServerCertificateException -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorViewModel -import org.koin.androidx.viewmodel.dsl.viewModel -import org.koin.core.module.Module -import org.koin.dsl.module - -val featureAccountServerCertificateModule: Module = module { - - single { - InMemoryServerCertificateErrorRepository() - } - - factory { - AddServerCertificateException( - localKeyStore = get(), - ) - } - - viewModel { - AccountServerCertificateErrorViewModel( - certificateErrorRepository = get(), - addServerCertificateException = get(), - ) - } -} diff --git a/feature/account/setup/build.gradle.kts b/feature/account/setup/build.gradle.kts index 9180fec88..697507561 100644 --- a/feature/account/setup/build.gradle.kts +++ b/feature/account/setup/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { api(projects.feature.account.common) implementation(projects.feature.account.oauth) - implementation(projects.feature.account.servercertificate) + implementation(projects.feature.account.server.certificate) api(projects.feature.account.server.validation) testImplementation(projects.core.ui.compose.testing) diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt index f0ac5169d..da60b4251 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt @@ -4,8 +4,8 @@ import android.content.Context import app.k9mail.core.common.oauth.OAuthConfigurationFactory import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.oauth.ui.AccountOAuthContract +import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract import app.k9mail.feature.account.server.validation.ui.ServerValidationContract -import app.k9mail.feature.account.servercertificate.ui.AccountServerCertificateErrorContract import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCreator import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCreator.AccountCreatorResult import app.k9mail.feature.account.setup.ui.AccountSetupContract @@ -69,7 +69,7 @@ class AccountSetupModuleKtTest : KoinTest { AccountOutgoingConfigContract.State::class, AccountOptionsContract.State::class, AccountState::class, - AccountServerCertificateErrorContract.State::class, + ServerCertificateErrorContract.State::class, AuthStateStorage::class, Context::class, Boolean::class, diff --git a/settings.gradle.kts b/settings.gradle.kts index c34e383d8..4c7e49384 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -46,8 +46,8 @@ include( include( ":feature:account:common", ":feature:account:oauth", - ":feature:account:servercertificate", ":feature:account:setup", + ":feature:account:server:certificate", ":feature:account:server:validation", )