From 01a0da9c5abfc7f7df3e8ab6ec1e3af7a9000c1a Mon Sep 17 00:00:00 2001 From: AndroidBob Date: Tue, 19 Mar 2024 15:22:15 +0100 Subject: [PATCH] fix: some end points are not routed through the proxy server 4.6 (#2754) Co-authored-by: Mohamad Jaara --- .../com/wire/android/di/CoreLogicModule.kt | 10 ----- .../feature/MigrateActiveAccountsUseCase.kt | 6 ++- .../feature/MigrateServerConfigUseCase.kt | 14 +++---- .../com/wire/android/ui/WireActivityState.kt | 11 +++--- .../wire/android/ui/WireActivityViewModel.kt | 2 +- .../android/ui/authentication/ServerTitle.kt | 23 ++++++++++-- .../create/code/CreateAccountCodeViewModel.kt | 6 ++- .../email/CreateAccountEmailViewModel.kt | 24 +----------- .../ui/authentication/login/LoginState.kt | 10 ++++- .../ui/authentication/login/LoginViewModel.kt | 3 -- .../login/email/LoginEmailViewModel.kt | 37 +++++++++---------- .../login/sso/LoginSSOViewModel.kt | 13 +++++-- .../ui/common/dialogs/CustomServerDialog.kt | 11 ++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 3 ++ .../MigrateServerConfigUseCaseTest.kt | 36 ++++++++++++------ .../login/sso/LoginSSOViewModelTest.kt | 2 +- kalium | 2 +- 18 files changed, 119 insertions(+), 95 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt index f71d86aa684..8f6395a20fc 100644 --- a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt +++ b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt @@ -206,16 +206,6 @@ class UseCaseModule { fun provideGetServerConfigUserCase(@KaliumCoreLogic coreLogic: CoreLogic) = coreLogic.getGlobalScope().fetchServerConfigFromDeepLink - @ViewModelScoped - @Provides - fun provideFetchApiVersionUserCase(@KaliumCoreLogic coreLogic: CoreLogic) = - coreLogic.getGlobalScope().fetchApiVersion - - @ViewModelScoped - @Provides - fun provideObserveServerConfigUseCase(@KaliumCoreLogic coreLogic: CoreLogic) = - coreLogic.getGlobalScope().observeServerConfig - @ViewModelScoped @Provides fun provideUpdateApiVersionsUseCase(@KaliumCoreLogic coreLogic: CoreLogic) = diff --git a/app/src/main/kotlin/com/wire/android/migration/feature/MigrateActiveAccountsUseCase.kt b/app/src/main/kotlin/com/wire/android/migration/feature/MigrateActiveAccountsUseCase.kt index 29b8a5d7ffb..055000e9a0d 100644 --- a/app/src/main/kotlin/com/wire/android/migration/feature/MigrateActiveAccountsUseCase.kt +++ b/app/src/main/kotlin/com/wire/android/migration/feature/MigrateActiveAccountsUseCase.kt @@ -115,7 +115,11 @@ class MigrateActiveAccountsUseCase @Inject constructor( private suspend fun handleMissingData( serverConfig: ServerConfig, refreshToken: String, - ): Either = coreLogic.authenticationScope(serverConfig) { + ): Either = coreLogic.authenticationScope( + serverConfig, + // scala did not support proxy mode so we can pass null + proxyCredentials = null + ) { ssoLoginScope.getLoginSession(refreshToken) }.let { when (it) { diff --git a/app/src/main/kotlin/com/wire/android/migration/feature/MigrateServerConfigUseCase.kt b/app/src/main/kotlin/com/wire/android/migration/feature/MigrateServerConfigUseCase.kt index f2eb55a6690..1c68b612519 100644 --- a/app/src/main/kotlin/com/wire/android/migration/feature/MigrateServerConfigUseCase.kt +++ b/app/src/main/kotlin/com/wire/android/migration/feature/MigrateServerConfigUseCase.kt @@ -27,7 +27,7 @@ import com.wire.kalium.logic.StorageFailure import com.wire.kalium.logic.configuration.server.CommonApiVersionType import com.wire.kalium.logic.configuration.server.ServerConfig import com.wire.kalium.logic.failure.ServerConfigFailure -import com.wire.kalium.logic.feature.server.FetchApiVersionResult +import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase import com.wire.kalium.logic.feature.server.GetServerConfigResult import com.wire.kalium.logic.feature.server.StoreServerConfigResult import com.wire.kalium.logic.functional.Either @@ -66,13 +66,13 @@ class MigrateServerConfigUseCase @Inject constructor( } private suspend fun ServerConfig.Links.fetchApiVersionAndStore(): Either = - coreLogic.getGlobalScope().fetchApiVersion(this).let { // it also already stores the fetched config + // scala did not support proxy mode so we can pass null here + coreLogic.versionedAuthenticationScope(this)(null).let { // it also already stores the fetched config when (it) { - is FetchApiVersionResult.Success -> Either.Right(it.serverConfig) - FetchApiVersionResult.Failure.TooNewVersion -> Either.Left(ServerConfigFailure.NewServerVersion) - FetchApiVersionResult.Failure.UnknownServerVersion -> Either.Left(ServerConfigFailure.UnknownServerVersion) - is FetchApiVersionResult.Failure.Generic -> Either.Left(it.genericFailure) + is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> Either.Left(it.genericFailure) + AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> Either.Left(ServerConfigFailure.NewServerVersion) + AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> Either.Left(ServerConfigFailure.UnknownServerVersion) + is AutoVersionAuthScopeUseCase.Result.Success -> Either.Right(it.authenticationScope.currentServerConfig()) } } - } diff --git a/app/src/main/kotlin/com/wire/android/ui/WireActivityState.kt b/app/src/main/kotlin/com/wire/android/ui/WireActivityState.kt index db8e2921fa5..4916122814c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/WireActivityState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/WireActivityState.kt @@ -18,10 +18,11 @@ package com.wire.android.ui -sealed class WireActivityState { +sealed class +WireActivityState { - data class NavigationGraph(val startNavigationRoute: String, val navigationArguments: List): WireActivityState() - data class ClientUpdateRequired(val clientUpdateUrl: String): WireActivityState() - object ServerVersionNotSupported: WireActivityState() - object Loading: WireActivityState() + data class NavigationGraph(val startNavigationRoute: String, val navigationArguments: List) : WireActivityState() + data class ClientUpdateRequired(val clientUpdateUrl: String) : WireActivityState() + object ServerVersionNotSupported : WireActivityState() + object Loading : WireActivityState() } diff --git a/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt index f66e31e1970..12ba8586963 100644 --- a/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt @@ -186,7 +186,7 @@ class WireActivityViewModel @Inject constructor( } private fun observeUpdateAppState() { - viewModelScope.launch(dispatchers.io()) { + viewModelScope.launch { observeIfAppUpdateRequired(BuildConfig.VERSION_CODE) .distinctUntilChanged() .collect { diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/ServerTitle.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/ServerTitle.kt index d8ce0da998f..d8524960afe 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/ServerTitle.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/ServerTitle.kt @@ -110,9 +110,8 @@ private fun ServerEnrollmentDialogContent( onDismiss: () -> Unit, onClick: () -> Unit, ) { - WireDialog( - title = stringResource(id = R.string.server_details_dialog_title), - text = LocalContext.current.resources.stringWithStyledArgs( + val text = if (serverLinks.apiProxy == null) { + LocalContext.current.resources.stringWithStyledArgs( R.string.server_details_dialog_body, MaterialTheme.wireTypography.body02, MaterialTheme.wireTypography.body02, @@ -120,7 +119,23 @@ private fun ServerEnrollmentDialogContent( argsColor = colorsScheme().onBackground, serverLinks.title, serverLinks.api - ), + ) + } else { + LocalContext.current.resources.stringWithStyledArgs( + R.string.server_details_dialog_body_with_proxy, + MaterialTheme.wireTypography.body02, + MaterialTheme.wireTypography.body02, + normalColor = colorsScheme().secondaryText, + argsColor = colorsScheme().onBackground, + serverLinks.title, + serverLinks.api, + serverLinks.apiProxy!!.host, + serverLinks.apiProxy!!.needsAuthentication.toString() + ) + } + WireDialog( + title = stringResource(id = R.string.server_details_dialog_title), + text = text, onDismiss = onDismiss, optionButton1Properties = WireDialogButtonProperties( stringResource(id = R.string.label_ok), diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/create/code/CreateAccountCodeViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/create/code/CreateAccountCodeViewModel.kt index 69011f6ed01..b2e1adf74e6 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/create/code/CreateAccountCodeViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/create/code/CreateAccountCodeViewModel.kt @@ -71,7 +71,8 @@ class CreateAccountCodeViewModel @Inject constructor( fun resendCode() { codeState = codeState.copy(loading = true) viewModelScope.launch { - val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let { + // create account does not support proxy yet + val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope @@ -130,7 +131,8 @@ class CreateAccountCodeViewModel @Inject constructor( private fun onCodeContinue(onSuccess: () -> Unit) { codeState = codeState.copy(loading = true) viewModelScope.launch { - val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let { + // create account does not support proxy yet + val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/create/email/CreateAccountEmailViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/create/email/CreateAccountEmailViewModel.kt index 75fb10548db..5656091bdc5 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/create/email/CreateAccountEmailViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/create/email/CreateAccountEmailViewModel.kt @@ -33,8 +33,6 @@ import com.wire.kalium.logic.configuration.server.ServerConfig import com.wire.kalium.logic.feature.auth.ValidateEmailUseCase import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase import com.wire.kalium.logic.feature.register.RequestActivationCodeResult -import com.wire.kalium.logic.feature.server.FetchApiVersionResult -import com.wire.kalium.logic.feature.server.FetchApiVersionUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -44,7 +42,6 @@ import javax.inject.Inject class CreateAccountEmailViewModel @Inject constructor( savedStateHandle: SavedStateHandle, private val authServerConfigProvider: AuthServerConfigProvider, - private val fetchApiVersion: FetchApiVersionUseCase, private val validateEmail: ValidateEmailUseCase, @KaliumCoreLogic private val coreLogic: CoreLogic, ) : ViewModel() { @@ -69,25 +66,6 @@ class CreateAccountEmailViewModel @Inject constructor( fun onEmailContinue(onSuccess: () -> Unit) { emailState = emailState.copy(loading = true, continueEnabled = false) viewModelScope.launch { - fetchApiVersion(authServerConfigProvider.authServer.value).let { - when (it) { - is FetchApiVersionResult.Success -> {} - is FetchApiVersionResult.Failure.UnknownServerVersion -> { - emailState = emailState.copy(showServerVersionNotSupportedDialog = true) - return@launch - } - - is FetchApiVersionResult.Failure.TooNewVersion -> { - emailState = emailState.copy(showClientUpdateDialog = true) - return@launch - } - - is FetchApiVersionResult.Failure.Generic -> { - return@launch - } - } - } - val emailError = if (validateEmail(emailState.email.text.trim().lowercase())) CreateAccountEmailViewState.EmailError.None else CreateAccountEmailViewState.EmailError.TextFieldError.InvalidEmailError @@ -106,7 +84,7 @@ class CreateAccountEmailViewModel @Inject constructor( fun onTermsAccept(onSuccess: () -> Unit) { emailState = emailState.copy(loading = true, continueEnabled = false, termsDialogVisible = false, termsAccepted = true) viewModelScope.launch { - val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let { + val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt index 578caa2d0c9..84eb7d9f42f 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginState.kt @@ -20,6 +20,7 @@ package com.wire.android.ui.authentication.login import androidx.compose.ui.text.input.TextFieldValue import com.wire.android.ui.common.dialogs.CustomServerDialogState +import com.wire.kalium.logic.data.auth.login.ProxyCredentials data class LoginState( val userIdentifier: TextFieldValue = TextFieldValue(""), @@ -36,7 +37,14 @@ data class LoginState( val loginError: LoginError = LoginError.None, val isProxyEnabled: Boolean = false, val customServerDialogState: CustomServerDialogState? = null, -) +) { + fun getProxyCredentials(): ProxyCredentials? = + if (proxyIdentifier.text.isNotBlank() && proxyPassword.text.isNotBlank()) { + ProxyCredentials(proxyIdentifier.text, proxyPassword.text) + } else { + null + } +} fun LoginState.updateEmailLoginEnabled() = copy( diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt index a0184f6d058..787b7e160c6 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/LoginViewModel.kt @@ -40,7 +40,6 @@ import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase import com.wire.kalium.logic.feature.auth.AuthenticationResult import com.wire.kalium.logic.feature.auth.DomainLookupUseCase -import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase import com.wire.kalium.logic.feature.client.RegisterClientResult import com.wire.kalium.logic.feature.client.RegisterClientUseCase import dagger.hilt.android.lifecycle.HiltViewModel @@ -68,8 +67,6 @@ open class LoginViewModel @Inject constructor( } } - protected suspend fun authScope(): AutoVersionAuthScopeUseCase.Result = coreLogic.versionedAuthenticationScope(serverConfig)() - private val loginNavArgs: LoginNavArgs = savedStateHandle.navArgs() private val preFilledUserIdentifier: PreFilledUserIdentifierType = loginNavArgs.userHandle.let { if (it.isNullOrEmpty()) PreFilledUserIdentifierType.None else PreFilledUserIdentifierType.PreFilled(it) diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt index 85361e510b0..4fd15a6c2e3 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/email/LoginEmailViewModel.kt @@ -36,7 +36,6 @@ import com.wire.android.ui.authentication.verificationcode.VerificationCodeState import com.wire.android.ui.common.textfield.CodeFieldValue import com.wire.android.util.dispatchers.DispatcherProvider import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.logic.data.auth.login.ProxyCredentials import com.wire.kalium.logic.data.auth.verification.VerifiableAction import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase import com.wire.kalium.logic.feature.auth.AuthenticationResult @@ -137,29 +136,27 @@ class LoginEmailViewModel @Inject constructor( private suspend fun resolveCurrentAuthScope(): AuthenticationScope? = coreLogic.versionedAuthenticationScope(serverConfig).invoke( - AutoVersionAuthScopeUseCase.ProxyAuthentication.UsernameAndPassword( - ProxyCredentials(loginState.proxyIdentifier.text, loginState.proxyPassword.text) - ) - ).let { - when (it) { - is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope - - is AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> { - updateEmailLoginError(LoginError.DialogError.ServerVersionNotSupported) - return null - } + loginState.getProxyCredentials() + ).let { + when (it) { + is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope + + is AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> { + updateEmailLoginError(LoginError.DialogError.ServerVersionNotSupported) + return null + } - is AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> { - updateEmailLoginError(LoginError.DialogError.ClientUpdateRequired) - return null - } + is AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> { + updateEmailLoginError(LoginError.DialogError.ClientUpdateRequired) + return null + } - is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> { - updateEmailLoginError(LoginError.DialogError.GenericError(it.genericFailure)) - return null + is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> { + updateEmailLoginError(LoginError.DialogError.GenericError(it.genericFailure)) + return null + } } } - } private suspend fun handleAuthenticationFailure(it: AuthenticationResult.Failure, authScope: AuthenticationScope) { when (it) { diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt index af0e111012c..0b8bc779420 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModel.kt @@ -90,7 +90,9 @@ class LoginSSOViewModel @Inject constructor( if (loginState.customServerDialogState != null) { authServerConfigProvider.updateAuthServer(loginState.customServerDialogState!!.serverLinks) - val authScope = coreLogic.versionedAuthenticationScope(loginState.customServerDialogState!!.serverLinks)().let { + // sso does not support proxy + // TODO: add proxy support + val authScope = coreLogic.versionedAuthenticationScope(loginState.customServerDialogState!!.serverLinks)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Failure.Generic, AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion, @@ -134,7 +136,9 @@ class LoginSSOViewModel @Inject constructor( val defaultAuthScope: AuthenticationScope = coreLogic.versionedAuthenticationScope( authServerConfigProvider.defaultServerLinks() - )().let { + // domain lockup does not support proxy + // TODO: add proxy support + )(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Failure.Generic, AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion, @@ -168,7 +172,8 @@ class LoginSSOViewModel @Inject constructor( private fun ssoLoginWithCodeFlow() { viewModelScope.launch { val authScope = - authScope().let { + // sso does not support proxy + coreLogic.versionedAuthenticationScope(serverConfig)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope @@ -207,7 +212,7 @@ class LoginSSOViewModel @Inject constructor( loginState = loginState.copy(ssoLoginLoading = true, loginError = LoginError.None).updateSSOLoginEnabled() viewModelScope.launch { val authScope = - authScope().let { + coreLogic.versionedAuthenticationScope(serverConfig)(null).let { when (it) { is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope diff --git a/app/src/main/kotlin/com/wire/android/ui/common/dialogs/CustomServerDialog.kt b/app/src/main/kotlin/com/wire/android/ui/common/dialogs/CustomServerDialog.kt index a884f7266c8..aa130cbc332 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/dialogs/CustomServerDialog.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/dialogs/CustomServerDialog.kt @@ -86,6 +86,17 @@ internal fun CustomServerDialog( title = stringResource(id = R.string.custom_backend_dialog_body_backend_api), value = serverLinks.api ) + if (serverLinks.apiProxy != null) { + CustomServerPropertyInfo( + title = stringResource(id = R.string.custom_backend_dialog_body_backend_proxy_url), + value = serverLinks.apiProxy!!.host + ) + + CustomServerPropertyInfo( + title = stringResource(id = R.string.custom_backend_dialog_body_backend_proxy_authentication), + value = serverLinks.apiProxy!!.needsAuthentication.toString() + ) + } if (showDetails) { CustomServerPropertyInfo( title = stringResource(id = R.string.custom_backend_dialog_body_backend_websocket), diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0a27a0ec731..4d8f017e478 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -210,6 +210,7 @@ Wire wird unabhängig geprüft und ist ISO-, CCPA-, DSGVO- und SOX-konform Team erstellen Backend-Name:\n%1$s\n\nBackend-URL:\n%2$s + Backend name:\n%1$s\n\nBackend URL:\n%2$s\n\nProxy-URL:\n%3$s\n\nProxy-Authentifizierung:\n%4$s Lokales Backend Willkommen in unserer neuen App 👋 Wir haben die App überarbeitet, um sie für alle benutzerfreundlicher zu machen.\n\nErfahren Sie mehr über die neu gestaltete App – zusätzliche Optionen und verbesserte Barrierefreiheit bei gleichbleibend hoher Sicherheit. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2028a3618cb..218fda616d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -226,6 +226,7 @@ Wire is independently audited and ISO, CCPA, GDPR, SOX-compliant Create a Team Backend name:\n%1$s\n\nBackend URL:\n%2$s + Backend name:\n%1$s\n\nBackend URL:\n%2$s\n\nProxy URL:\n%3$s\n\nProxy authentication:\n%4$s On-premises Backend Welcome To Our New Android App 👋 We rebuilt the app to make it more usable for everyone.\n\nFind out more about Wire’s redesigned app—new options and improved accessibility, with the same strong security. @@ -1013,6 +1014,8 @@ If you proceed, your client will be redirected to the following on-premises backend: Backend name: Backend URL: + Proxy URL: + Proxy authentication: Blacklist URL: Teams URL: Accounts URL: diff --git a/app/src/test/kotlin/com/wire/android/migration/MigrateServerConfigUseCaseTest.kt b/app/src/test/kotlin/com/wire/android/migration/MigrateServerConfigUseCaseTest.kt index 7509e8c1e8c..5b12c4da989 100644 --- a/app/src/test/kotlin/com/wire/android/migration/MigrateServerConfigUseCaseTest.kt +++ b/app/src/test/kotlin/com/wire/android/migration/MigrateServerConfigUseCaseTest.kt @@ -27,7 +27,8 @@ import com.wire.kalium.logic.CoreLogic import com.wire.kalium.logic.GlobalKaliumScope import com.wire.kalium.logic.StorageFailure import com.wire.kalium.logic.configuration.server.ServerConfig -import com.wire.kalium.logic.feature.server.FetchApiVersionResult +import com.wire.kalium.logic.feature.auth.AuthenticationScope +import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase import com.wire.kalium.logic.feature.server.GetServerConfigResult import com.wire.kalium.logic.feature.server.StoreServerConfigResult import com.wire.kalium.logic.functional.Either @@ -59,7 +60,6 @@ class MigrateServerConfigUseCaseTest { .arrange() val result = useCase() coVerify(exactly = 1) { arrangement.globalKaliumScope.storeServerConfig(expected.links, versionInfo) } - coVerify { arrangement.globalKaliumScope.fetchApiVersion(any()) wasNot Called } assert(result.isRight()) assertEquals(expected, (result as Either.Right).value) } @@ -69,10 +69,10 @@ class MigrateServerConfigUseCaseTest { val expected = Arrangement.serverConfig val (arrangement, useCase) = Arrangement() .withScalaServerConfig(ScalaServerConfig.Links(expected.links)) - .withFetchApiVersionResult(FetchApiVersionResult.Success(expected)) + .withCurrentServerConfig(expected) .arrange() + val result = useCase() - coVerify(exactly = 1) { arrangement.globalKaliumScope.fetchApiVersion(expected.links) } assert(result.isRight()) assertEquals(expected, (result as Either.Right).value) } @@ -84,11 +84,11 @@ class MigrateServerConfigUseCaseTest { val (arrangement, useCase) = Arrangement() .withScalaServerConfig(ScalaServerConfig.ConfigUrl(customConfigUrl)) .withFetchServerConfigFromDeepLinkResult(GetServerConfigResult.Success(expected.links)) - .withFetchApiVersionResult(FetchApiVersionResult.Success(expected)) + .withCurrentServerConfig(expected) .arrange() + val result = useCase() coVerify(exactly = 1) { arrangement.globalKaliumScope.fetchServerConfigFromDeepLink(customConfigUrl) } - coVerify(exactly = 1) { arrangement.globalKaliumScope.fetchApiVersion(expected.links) } assert(result.isRight()) assertEquals(expected, (result as Either.Right).value) } @@ -107,8 +107,10 @@ class MigrateServerConfigUseCaseTest { private class Arrangement { @MockK lateinit var coreLogic: CoreLogic + @MockK lateinit var scalaServerConfigDAO: ScalaServerConfigDAO + @MockK lateinit var globalKaliumScope: GlobalKaliumScope @@ -116,27 +118,37 @@ class MigrateServerConfigUseCaseTest { MigrateServerConfigUseCase(coreLogic, scalaServerConfigDAO) } + @MockK + lateinit var autoVersionAuthScopeUseCase: AutoVersionAuthScopeUseCase + + @MockK + lateinit var authScope: AuthenticationScope + init { MockKAnnotations.init(this, relaxUnitFun = true) every { coreLogic.getGlobalScope() } returns globalKaliumScope + every { coreLogic.versionedAuthenticationScope(any()) } returns autoVersionAuthScopeUseCase + coEvery { autoVersionAuthScopeUseCase(any()) } returns AutoVersionAuthScopeUseCase.Result.Success(authScope) + } + + fun withCurrentServerConfig(serverConfig: ServerConfig) = apply { + every { authScope.currentServerConfig() } returns serverConfig } fun withScalaServerConfig(scalaServerConfig: ScalaServerConfig): Arrangement { every { scalaServerConfigDAO.scalaServerConfig } returns scalaServerConfig return this } - fun withStoreServerConfigResult(result : StoreServerConfigResult): Arrangement { + + fun withStoreServerConfigResult(result: StoreServerConfigResult): Arrangement { coEvery { globalKaliumScope.storeServerConfig(any(), any()) } returns result return this } - fun withFetchServerConfigFromDeepLinkResult(result : GetServerConfigResult): Arrangement { + + fun withFetchServerConfigFromDeepLinkResult(result: GetServerConfigResult): Arrangement { coEvery { globalKaliumScope.fetchServerConfigFromDeepLink(any()) } returns result return this } - fun withFetchApiVersionResult(result : FetchApiVersionResult): Arrangement { - coEvery { globalKaliumScope.fetchApiVersion(any()) } returns result - return this - } fun arrange() = this to useCase diff --git a/app/src/test/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModelTest.kt index e6e33468d51..3d4ca18db66 100644 --- a/app/src/test/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/authentication/login/sso/LoginSSOViewModelTest.kt @@ -139,7 +139,7 @@ class LoginSSOViewModelTest { authServerConfigProvider.updateAuthServer(newServerConfig(1).links) coEvery { - autoVersionAuthScopeUseCase() + autoVersionAuthScopeUseCase(null) } returns AutoVersionAuthScopeUseCase.Result.Success( authenticationScope ) diff --git a/kalium b/kalium index 494d5a75f9c..18b7699e312 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 494d5a75f9ce4c3c711cb49e6668522bbfea542e +Subproject commit 18b7699e312bedf08a441433e25d96fb37dc920f