From d09cb2afeb8cbcae8d09a46c7045e7c5653a4b88 Mon Sep 17 00:00:00 2001 From: cketti Date: Sat, 15 Jul 2023 21:23:17 +0200 Subject: [PATCH] Add source to `AutoDiscoveryResult.Settings` --- .../k9mail/cli/autodiscovery/AutoDiscoveryResultFormatter.kt | 2 ++ .../feature/account/setup/domain/usecase/GetAutoDiscovery.kt | 1 + .../ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt | 1 + .../setup/ui/autodiscovery/view/AutoDiscoveryStatusView.kt | 2 ++ .../setup/domain/entity/AutoDiscoverySettingsFixture.kt | 1 + .../common/mapper/AccountAutoDiscoveryStateMapperKtTest.kt | 1 + .../app/k9mail/autodiscovery/api/AutoDiscoveryResult.kt | 5 +++++ .../k9mail/autodiscovery/autoconfig/RealAutoconfigFetcher.kt | 1 + .../k9mail/autodiscovery/autoconfig/MockAutoconfigFetcher.kt | 2 ++ .../autodiscovery/service/PriorityParallelRunnerTest.kt | 2 ++ 10 files changed, 18 insertions(+) diff --git a/cli/autodiscovery-cli/src/main/kotlin/app/k9mail/cli/autodiscovery/AutoDiscoveryResultFormatter.kt b/cli/autodiscovery-cli/src/main/kotlin/app/k9mail/cli/autodiscovery/AutoDiscoveryResultFormatter.kt index b42ba6ad7..8f317d929 100644 --- a/cli/autodiscovery-cli/src/main/kotlin/app/k9mail/cli/autodiscovery/AutoDiscoveryResultFormatter.kt +++ b/cli/autodiscovery-cli/src/main/kotlin/app/k9mail/cli/autodiscovery/AutoDiscoveryResultFormatter.kt @@ -10,6 +10,8 @@ internal class AutoDiscoveryResultFormatter(private val echo: (String) -> Unit) val outgoingServer = requireNotNull(settings.outgoingServerSettings as? SmtpServerSettings) echo("------------------------------") + echo("Source: ${settings.source}") + echo("") echo("Incoming server:") echo(" Hostname: ${incomingServer.hostname.value}") echo(" Port: ${incomingServer.port.value}") diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/GetAutoDiscovery.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/GetAutoDiscovery.kt index 4d0141e94..b8a21bfbb 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/GetAutoDiscovery.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/GetAutoDiscovery.kt @@ -73,6 +73,7 @@ internal class GetAutoDiscovery( username = "username", ), isTrusted = isTrusted, + source = "fake", ) } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt index e5a0bd120..5315c57c4 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt @@ -126,6 +126,7 @@ internal fun AutoDiscoveryStatusBodyViewPreview() { username = "", ), isTrusted = true, + source = "preview", ), onEditConfigurationClick = {}, ) diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusView.kt index 8c5cdf6fd..b86e67a1c 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusView.kt @@ -88,6 +88,7 @@ internal fun AutoDiscoveryStatusViewTrustedPreview() { username = "", ), isTrusted = true, + source = "preview", ), onEditConfigurationClick = {}, ) @@ -115,6 +116,7 @@ internal fun AutoDiscoveryStatusViewUntrustedPreview() { username = "", ), isTrusted = false, + source = "preview", ), onEditConfigurationClick = {}, ) diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/entity/AutoDiscoverySettingsFixture.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/entity/AutoDiscoverySettingsFixture.kt index e6ebb6e43..e6b157360 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/entity/AutoDiscoverySettingsFixture.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/entity/AutoDiscoverySettingsFixture.kt @@ -26,5 +26,6 @@ object AutoDiscoverySettingsFixture { username = "outgoing_username", ), isTrusted = true, + source = "test", ) } diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AccountAutoDiscoveryStateMapperKtTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AccountAutoDiscoveryStateMapperKtTest.kt index fdf416599..5cb010a89 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AccountAutoDiscoveryStateMapperKtTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AccountAutoDiscoveryStateMapperKtTest.kt @@ -176,6 +176,7 @@ class AccountAutoDiscoveryStateMapperKtTest { username = AUTO_DISCOVERY_USERNAME, ), isTrusted = true, + source = "test", ), ) diff --git a/feature/autodiscovery/api/src/main/kotlin/app/k9mail/autodiscovery/api/AutoDiscoveryResult.kt b/feature/autodiscovery/api/src/main/kotlin/app/k9mail/autodiscovery/api/AutoDiscoveryResult.kt index 515dc8292..66913d0b9 100644 --- a/feature/autodiscovery/api/src/main/kotlin/app/k9mail/autodiscovery/api/AutoDiscoveryResult.kt +++ b/feature/autodiscovery/api/src/main/kotlin/app/k9mail/autodiscovery/api/AutoDiscoveryResult.kt @@ -23,6 +23,11 @@ sealed interface AutoDiscoveryResult { * the user has given consent. */ val isTrusted: Boolean, + + /** + * String describing the source of the server settings. Use a URI if possible. + */ + val source: String, ) : AutoDiscoveryResult /** diff --git a/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigFetcher.kt b/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigFetcher.kt index 0dd0e7ddd..e43ece464 100644 --- a/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigFetcher.kt +++ b/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigFetcher.kt @@ -41,6 +41,7 @@ internal class RealAutoconfigFetcher( incomingServerSettings = parserResult.incomingServerSettings, outgoingServerSettings = parserResult.outgoingServerSettings, isTrusted = fetchResult.isTrusted, + source = autoconfigUrl.toString(), ) } diff --git a/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/MockAutoconfigFetcher.kt b/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/MockAutoconfigFetcher.kt index aa8e5ac91..741162021 100644 --- a/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/MockAutoconfigFetcher.kt +++ b/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/MockAutoconfigFetcher.kt @@ -50,6 +50,7 @@ internal class MockAutoconfigFetcher : AutoconfigFetcher { username = "irrelevant@domain.example", ), isTrusted = true, + source = "result 1", ) val RESULT_TWO = AutoDiscoveryResult.Settings( incomingServerSettings = ImapServerSettings( @@ -67,6 +68,7 @@ internal class MockAutoconfigFetcher : AutoconfigFetcher { username = "irrelevant@company.example", ), isTrusted = true, + source = "result 2", ) } } diff --git a/feature/autodiscovery/service/src/test/kotlin/app/k9mail/autodiscovery/service/PriorityParallelRunnerTest.kt b/feature/autodiscovery/service/src/test/kotlin/app/k9mail/autodiscovery/service/PriorityParallelRunnerTest.kt index 08195935b..b97f034a6 100644 --- a/feature/autodiscovery/service/src/test/kotlin/app/k9mail/autodiscovery/service/PriorityParallelRunnerTest.kt +++ b/feature/autodiscovery/service/src/test/kotlin/app/k9mail/autodiscovery/service/PriorityParallelRunnerTest.kt @@ -156,6 +156,7 @@ class PriorityParallelRunnerTest { username = "user@domain.example", ), isTrusted = true, + source = "result 1", ) private val DISCOVERY_RESULT_TWO = AutoDiscoveryResult.Settings( @@ -174,6 +175,7 @@ class PriorityParallelRunnerTest { username = "user@domain.example", ), isTrusted = true, + source = "result 2", ) } }