Merge pull request #5237 from element-hq/feature/bma/removeLoginUserStory
Remove LoginUserStory.
This commit is contained in:
commit
dddc557e54
13 changed files with 6 additions and 119 deletions
|
|
@ -10,12 +10,10 @@ package io.element.android.appnav.root
|
||||||
import com.bumble.appyx.core.state.MutableSavedStateMap
|
import com.bumble.appyx.core.state.MutableSavedStateMap
|
||||||
import com.bumble.appyx.core.state.SavedStateMap
|
import com.bumble.appyx.core.state.SavedStateMap
|
||||||
import io.element.android.appnav.di.MatrixSessionCache
|
import io.element.android.appnav.di.MatrixSessionCache
|
||||||
import io.element.android.features.login.api.LoginUserStory
|
|
||||||
import io.element.android.features.preferences.api.CacheService
|
import io.element.android.features.preferences.api.CacheService
|
||||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
||||||
import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder
|
import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder
|
||||||
import io.element.android.libraries.preferences.api.store.SessionPreferencesStoreFactory
|
import io.element.android.libraries.preferences.api.store.SessionPreferencesStoreFactory
|
||||||
import io.element.android.libraries.sessionstorage.api.LoggedInState
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
|
|
@ -33,7 +31,6 @@ class RootNavStateFlowFactory @Inject constructor(
|
||||||
private val cacheService: CacheService,
|
private val cacheService: CacheService,
|
||||||
private val matrixSessionCache: MatrixSessionCache,
|
private val matrixSessionCache: MatrixSessionCache,
|
||||||
private val imageLoaderHolder: ImageLoaderHolder,
|
private val imageLoaderHolder: ImageLoaderHolder,
|
||||||
private val loginUserStory: LoginUserStory,
|
|
||||||
private val sessionPreferencesStoreFactory: SessionPreferencesStoreFactory,
|
private val sessionPreferencesStoreFactory: SessionPreferencesStoreFactory,
|
||||||
) {
|
) {
|
||||||
private var currentCacheIndex = 0
|
private var currentCacheIndex = 0
|
||||||
|
|
@ -42,13 +39,11 @@ class RootNavStateFlowFactory @Inject constructor(
|
||||||
return combine(
|
return combine(
|
||||||
cacheIndexFlow(savedStateMap),
|
cacheIndexFlow(savedStateMap),
|
||||||
authenticationService.loggedInStateFlow(),
|
authenticationService.loggedInStateFlow(),
|
||||||
loginUserStory.loginFlowIsDone,
|
) { cacheIndex, loggedInState ->
|
||||||
) { cacheIndex, loggedInState, loginFlowIsDone ->
|
RootNavState(
|
||||||
if (loginFlowIsDone) {
|
cacheIndex = cacheIndex,
|
||||||
RootNavState(cacheIndex = cacheIndex, loggedInState = loggedInState)
|
loggedInState = loggedInState,
|
||||||
} else {
|
)
|
||||||
RootNavState(cacheIndex = cacheIndex, loggedInState = LoggedInState.NotLoggedIn)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
* Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.features.login.api
|
|
||||||
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
|
|
||||||
interface LoginUserStory {
|
|
||||||
val loginFlowIsDone: StateFlow<Boolean>
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
* Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.features.login.impl
|
|
||||||
|
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
|
||||||
import io.element.android.features.login.api.LoginUserStory
|
|
||||||
import io.element.android.libraries.di.AppScope
|
|
||||||
import io.element.android.libraries.di.SingleIn
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@SingleIn(AppScope::class)
|
|
||||||
@ContributesBinding(AppScope::class)
|
|
||||||
class DefaultLoginUserStory @Inject constructor() : LoginUserStory {
|
|
||||||
// True by default, will be set to false when the login user story is started, and set to true again once it's done.
|
|
||||||
override val loginFlowIsDone: MutableStateFlow<Boolean> = MutableStateFlow(true)
|
|
||||||
|
|
||||||
fun setLoginFlowIsDone(value: Boolean) {
|
|
||||||
loginFlowIsDone.value = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -55,7 +55,6 @@ class LoginFlowNode @AssistedInject constructor(
|
||||||
@Assisted buildContext: BuildContext,
|
@Assisted buildContext: BuildContext,
|
||||||
@Assisted plugins: List<Plugin>,
|
@Assisted plugins: List<Plugin>,
|
||||||
private val accountProviderDataSource: AccountProviderDataSource,
|
private val accountProviderDataSource: AccountProviderDataSource,
|
||||||
private val defaultLoginUserStory: DefaultLoginUserStory,
|
|
||||||
private val oidcActionFlow: OidcActionFlow,
|
private val oidcActionFlow: OidcActionFlow,
|
||||||
) : BaseFlowNode<LoginFlowNode.NavTarget>(
|
) : BaseFlowNode<LoginFlowNode.NavTarget>(
|
||||||
backstack = BackStack(
|
backstack = BackStack(
|
||||||
|
|
@ -77,7 +76,6 @@ class LoginFlowNode @AssistedInject constructor(
|
||||||
|
|
||||||
override fun onBuilt() {
|
override fun onBuilt() {
|
||||||
super.onBuilt()
|
super.onBuilt()
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(false)
|
|
||||||
lifecycle.subscribe(
|
lifecycle.subscribe(
|
||||||
onResume = {
|
onResume = {
|
||||||
if (externalAppStarted) {
|
if (externalAppStarted) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.error.ChangeServerError
|
import io.element.android.features.login.impl.error.ChangeServerError
|
||||||
import io.element.android.features.login.impl.screens.chooseaccountprovider.ChooseAccountProviderPresenter
|
import io.element.android.features.login.impl.screens.chooseaccountprovider.ChooseAccountProviderPresenter
|
||||||
import io.element.android.features.login.impl.screens.confirmaccountprovider.ConfirmAccountProviderPresenter
|
import io.element.android.features.login.impl.screens.confirmaccountprovider.ConfirmAccountProviderPresenter
|
||||||
|
|
@ -38,7 +37,6 @@ import javax.inject.Inject
|
||||||
class LoginHelper @Inject constructor(
|
class LoginHelper @Inject constructor(
|
||||||
private val oidcActionFlow: OidcActionFlow,
|
private val oidcActionFlow: OidcActionFlow,
|
||||||
private val authenticationService: MatrixAuthenticationService,
|
private val authenticationService: MatrixAuthenticationService,
|
||||||
private val defaultLoginUserStory: DefaultLoginUserStory,
|
|
||||||
private val webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever,
|
private val webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever,
|
||||||
) {
|
) {
|
||||||
private val loginModeState: MutableState<AsyncData<LoginMode>> = mutableStateOf(AsyncData.Uninitialized)
|
private val loginModeState: MutableState<AsyncData<LoginMode>> = mutableStateOf(AsyncData.Uninitialized)
|
||||||
|
|
@ -108,9 +106,6 @@ class LoginHelper @Inject constructor(
|
||||||
}
|
}
|
||||||
is OidcAction.Success -> {
|
is OidcAction.Success -> {
|
||||||
authenticationService.loginWithOidc(oidcAction.url)
|
authenticationService.loginWithOidc(oidcAction.url)
|
||||||
.onSuccess { _ ->
|
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(true)
|
|
||||||
}
|
|
||||||
.onFailure { failure ->
|
.onFailure { failure ->
|
||||||
loginModeState.value = AsyncData.Failure(failure)
|
loginModeState.value = AsyncData.Failure(failure)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import com.bumble.appyx.navmodel.backstack.operation.replace
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import io.element.android.anvilannotations.ContributesNode
|
import io.element.android.anvilannotations.ContributesNode
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.di.QrCodeLoginBindings
|
import io.element.android.features.login.impl.di.QrCodeLoginBindings
|
||||||
import io.element.android.features.login.impl.di.QrCodeLoginComponent
|
import io.element.android.features.login.impl.di.QrCodeLoginComponent
|
||||||
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationNode
|
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationNode
|
||||||
|
|
@ -54,7 +53,6 @@ class QrCodeLoginFlowNode @AssistedInject constructor(
|
||||||
@Assisted buildContext: BuildContext,
|
@Assisted buildContext: BuildContext,
|
||||||
@Assisted plugins: List<Plugin>,
|
@Assisted plugins: List<Plugin>,
|
||||||
qrCodeLoginComponentBuilder: QrCodeLoginComponent.Builder,
|
qrCodeLoginComponentBuilder: QrCodeLoginComponent.Builder,
|
||||||
private val defaultLoginUserStory: DefaultLoginUserStory,
|
|
||||||
private val coroutineDispatchers: CoroutineDispatchers,
|
private val coroutineDispatchers: CoroutineDispatchers,
|
||||||
) : BaseFlowNode<QrCodeLoginFlowNode.NavTarget>(
|
) : BaseFlowNode<QrCodeLoginFlowNode.NavTarget>(
|
||||||
backstack = BackStack(
|
backstack = BackStack(
|
||||||
|
|
@ -198,7 +196,6 @@ class QrCodeLoginFlowNode @AssistedInject constructor(
|
||||||
authenticationJob = launch(coroutineDispatchers.main) {
|
authenticationJob = launch(coroutineDispatchers.main) {
|
||||||
qrCodeLoginManager.authenticate(qrCodeLoginData)
|
qrCodeLoginManager.authenticate(qrCodeLoginData)
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(true)
|
|
||||||
authenticationJob = null
|
authenticationJob = null
|
||||||
}
|
}
|
||||||
.onFailure { throwable ->
|
.onFailure { throwable ->
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedFactory
|
import dagger.assisted.AssistedFactory
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
import io.element.android.libraries.core.data.tryOrNull
|
import io.element.android.libraries.core.data.tryOrNull
|
||||||
|
|
@ -36,7 +35,6 @@ class CreateAccountPresenter @AssistedInject constructor(
|
||||||
@Assisted private val url: String,
|
@Assisted private val url: String,
|
||||||
private val authenticationService: MatrixAuthenticationService,
|
private val authenticationService: MatrixAuthenticationService,
|
||||||
private val clientProvider: MatrixClientProvider,
|
private val clientProvider: MatrixClientProvider,
|
||||||
private val defaultLoginUserStory: DefaultLoginUserStory,
|
|
||||||
private val messageParser: MessageParser,
|
private val messageParser: MessageParser,
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
) : Presenter<CreateAccountState> {
|
) : Presenter<CreateAccountState> {
|
||||||
|
|
@ -86,8 +84,6 @@ class CreateAccountPresenter @AssistedInject constructor(
|
||||||
val sessionVerificationService = client.sessionVerificationService()
|
val sessionVerificationService = client.sessionVerificationService()
|
||||||
withTimeout(10.seconds) { sessionVerificationService.sessionVerifiedStatus.first { it.isVerified() } }
|
withTimeout(10.seconds) { sessionVerificationService.sessionVerifiedStatus.first { it.isVerified() } }
|
||||||
}
|
}
|
||||||
// We will not navigate to the WaitList screen, so the login user story is done
|
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(true)
|
|
||||||
loggedInState.value = AsyncAction.Success(sessionId)
|
loggedInState.value = AsyncAction.Success(sessionId)
|
||||||
}.onFailure { failure ->
|
}.onFailure { failure ->
|
||||||
loggedInState.value = AsyncAction.Failure(failure)
|
loggedInState.value = AsyncAction.Failure(failure)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
||||||
import io.element.android.libraries.architecture.AsyncData
|
import io.element.android.libraries.architecture.AsyncData
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
|
@ -28,7 +27,6 @@ import javax.inject.Inject
|
||||||
class LoginPasswordPresenter @Inject constructor(
|
class LoginPasswordPresenter @Inject constructor(
|
||||||
private val authenticationService: MatrixAuthenticationService,
|
private val authenticationService: MatrixAuthenticationService,
|
||||||
private val accountProviderDataSource: AccountProviderDataSource,
|
private val accountProviderDataSource: AccountProviderDataSource,
|
||||||
private val defaultLoginUserStory: DefaultLoginUserStory,
|
|
||||||
) : Presenter<LoginPasswordState> {
|
) : Presenter<LoginPasswordState> {
|
||||||
@Composable
|
@Composable
|
||||||
override fun present(): LoginPasswordState {
|
override fun present(): LoginPasswordState {
|
||||||
|
|
@ -69,8 +67,6 @@ class LoginPasswordPresenter @Inject constructor(
|
||||||
loggedInState.value = AsyncData.Loading()
|
loggedInState.value = AsyncData.Loading()
|
||||||
authenticationService.login(formState.login.trim(), formState.password)
|
authenticationService.login(formState.login.trim(), formState.password)
|
||||||
.onSuccess { sessionId ->
|
.onSuccess { sessionId ->
|
||||||
// We will not navigate to the WaitList screen, so the login user story is done
|
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(true)
|
|
||||||
loggedInState.value = AsyncData.Success(sessionId)
|
loggedInState.value = AsyncData.Success(sessionId)
|
||||||
}
|
}
|
||||||
.onFailure { failure ->
|
.onFailure { failure ->
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import com.bumble.appyx.core.modality.AncestryInfo
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl
|
import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.di.FakeMergedQrCodeLoginComponent
|
import io.element.android.features.login.impl.di.FakeMergedQrCodeLoginComponent
|
||||||
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationStep
|
import io.element.android.features.login.impl.screens.qrcode.confirmation.QrCodeConfirmationStep
|
||||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||||
|
|
@ -98,7 +97,7 @@ class QrCodeLoginFlowNodeTest {
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Test
|
@Test
|
||||||
fun `startAuthentication - success marks the login flow as done`() = runTest {
|
fun `startAuthentication - success`() = runTest {
|
||||||
val fakeAuthenticationService = FakeMatrixAuthenticationService(
|
val fakeAuthenticationService = FakeMatrixAuthenticationService(
|
||||||
loginWithQrCodeResult = { _, progress ->
|
loginWithQrCodeResult = { _, progress ->
|
||||||
progress(QrCodeLoginStep.Finished)
|
progress(QrCodeLoginStep.Finished)
|
||||||
|
|
@ -107,12 +106,8 @@ class QrCodeLoginFlowNodeTest {
|
||||||
)
|
)
|
||||||
// Test with a real manager to ensure the flow is correctly done
|
// Test with a real manager to ensure the flow is correctly done
|
||||||
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory().apply {
|
|
||||||
loginFlowIsDone.value = false
|
|
||||||
}
|
|
||||||
val flowNode = createLoginFlowNode(
|
val flowNode = createLoginFlowNode(
|
||||||
qrCodeLoginManager = qrCodeLoginManager,
|
qrCodeLoginManager = qrCodeLoginManager,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -122,7 +117,6 @@ class QrCodeLoginFlowNodeTest {
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Finished)
|
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Finished)
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isTrue()
|
|
||||||
assertThat(flowNode.isLoginInProgress()).isFalse()
|
assertThat(flowNode.isLoginInProgress()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,12 +131,8 @@ class QrCodeLoginFlowNodeTest {
|
||||||
)
|
)
|
||||||
// Test with a real manager to ensure the flow is correctly done
|
// Test with a real manager to ensure the flow is correctly done
|
||||||
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory().apply {
|
|
||||||
loginFlowIsDone.value = false
|
|
||||||
}
|
|
||||||
val flowNode = createLoginFlowNode(
|
val flowNode = createLoginFlowNode(
|
||||||
qrCodeLoginManager = qrCodeLoginManager,
|
qrCodeLoginManager = qrCodeLoginManager,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -152,7 +142,6 @@ class QrCodeLoginFlowNodeTest {
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Failed(QrLoginException.Unknown))
|
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Failed(QrLoginException.Unknown))
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
assertThat(flowNode.isLoginInProgress()).isFalse()
|
assertThat(flowNode.isLoginInProgress()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,12 +156,8 @@ class QrCodeLoginFlowNodeTest {
|
||||||
)
|
)
|
||||||
// Test with a real manager to ensure the flow is correctly done
|
// Test with a real manager to ensure the flow is correctly done
|
||||||
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
val qrCodeLoginManager = DefaultQrCodeLoginManager(fakeAuthenticationService)
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory().apply {
|
|
||||||
loginFlowIsDone.value = false
|
|
||||||
}
|
|
||||||
val flowNode = createLoginFlowNode(
|
val flowNode = createLoginFlowNode(
|
||||||
qrCodeLoginManager = qrCodeLoginManager,
|
qrCodeLoginManager = qrCodeLoginManager,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -183,13 +168,11 @@ class QrCodeLoginFlowNodeTest {
|
||||||
advanceUntilIdle()
|
advanceUntilIdle()
|
||||||
|
|
||||||
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Uninitialized)
|
assertThat(qrCodeLoginManager.currentLoginStep.value).isEqualTo(QrCodeLoginStep.Uninitialized)
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
assertThat(flowNode.isLoginInProgress()).isFalse()
|
assertThat(flowNode.isLoginInProgress()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestScope.createLoginFlowNode(
|
private fun TestScope.createLoginFlowNode(
|
||||||
qrCodeLoginManager: QrCodeLoginManager = FakeQrCodeLoginManager(),
|
qrCodeLoginManager: QrCodeLoginManager = FakeQrCodeLoginManager(),
|
||||||
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
|
|
||||||
coroutineDispatchers: CoroutineDispatchers = testCoroutineDispatchers()
|
coroutineDispatchers: CoroutineDispatchers = testCoroutineDispatchers()
|
||||||
): QrCodeLoginFlowNode {
|
): QrCodeLoginFlowNode {
|
||||||
val buildContext = BuildContext(
|
val buildContext = BuildContext(
|
||||||
|
|
@ -201,7 +184,6 @@ class QrCodeLoginFlowNodeTest {
|
||||||
buildContext = buildContext,
|
buildContext = buildContext,
|
||||||
plugins = emptyList(),
|
plugins = emptyList(),
|
||||||
qrCodeLoginComponentBuilder = FakeMergedQrCodeLoginComponent.Builder(qrCodeLoginManager),
|
qrCodeLoginComponentBuilder = FakeMergedQrCodeLoginComponent.Builder(qrCodeLoginManager),
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
coroutineDispatchers = coroutineDispatchers,
|
coroutineDispatchers = coroutineDispatchers,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.appconfig.AuthenticationConfig
|
import io.element.android.appconfig.AuthenticationConfig
|
||||||
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
||||||
import io.element.android.features.login.impl.login.LoginMode
|
import io.element.android.features.login.impl.login.LoginMode
|
||||||
import io.element.android.features.login.impl.screens.createaccount.AccountCreationNotSupported
|
import io.element.android.features.login.impl.screens.createaccount.AccountCreationNotSupported
|
||||||
|
|
@ -30,7 +29,6 @@ import io.element.android.libraries.oidc.api.OidcAction
|
||||||
import io.element.android.libraries.oidc.api.OidcActionFlow
|
import io.element.android.libraries.oidc.api.OidcActionFlow
|
||||||
import io.element.android.libraries.oidc.test.customtab.FakeOidcActionFlow
|
import io.element.android.libraries.oidc.test.customtab.FakeOidcActionFlow
|
||||||
import io.element.android.tests.testutils.WarmUpRule
|
import io.element.android.tests.testutils.WarmUpRule
|
||||||
import io.element.android.tests.testutils.waitForPredicate
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -186,13 +184,9 @@ class ConfirmAccountProviderPresenterTest {
|
||||||
fun `present - oidc - success with success`() = runTest {
|
fun `present - oidc - success with success`() = runTest {
|
||||||
val authenticationService = FakeMatrixAuthenticationService()
|
val authenticationService = FakeMatrixAuthenticationService()
|
||||||
val defaultOidcActionFlow = FakeOidcActionFlow()
|
val defaultOidcActionFlow = FakeOidcActionFlow()
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory().apply {
|
|
||||||
setLoginFlowIsDone(false)
|
|
||||||
}
|
|
||||||
val presenter = createConfirmAccountProviderPresenter(
|
val presenter = createConfirmAccountProviderPresenter(
|
||||||
matrixAuthenticationService = authenticationService,
|
matrixAuthenticationService = authenticationService,
|
||||||
defaultOidcActionFlow = defaultOidcActionFlow,
|
defaultOidcActionFlow = defaultOidcActionFlow,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
)
|
)
|
||||||
authenticationService.givenHomeserver(A_HOMESERVER_OIDC)
|
authenticationService.givenHomeserver(A_HOMESERVER_OIDC)
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
|
@ -207,11 +201,9 @@ class ConfirmAccountProviderPresenterTest {
|
||||||
assertThat(successState.submitEnabled).isFalse()
|
assertThat(successState.submitEnabled).isFalse()
|
||||||
assertThat(successState.loginMode).isInstanceOf(AsyncData.Success::class.java)
|
assertThat(successState.loginMode).isInstanceOf(AsyncData.Success::class.java)
|
||||||
assertThat(successState.loginMode.dataOrNull()).isInstanceOf(LoginMode.Oidc::class.java)
|
assertThat(successState.loginMode.dataOrNull()).isInstanceOf(LoginMode.Oidc::class.java)
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
defaultOidcActionFlow.post(OidcAction.Success("aUrl"))
|
defaultOidcActionFlow.post(OidcAction.Success("aUrl"))
|
||||||
val successSuccessState = awaitItem()
|
val successSuccessState = awaitItem()
|
||||||
assertThat(successSuccessState.loginMode).isInstanceOf(AsyncData.Loading::class.java)
|
assertThat(successSuccessState.loginMode).isInstanceOf(AsyncData.Loading::class.java)
|
||||||
waitForPredicate { defaultLoginUserStory.loginFlowIsDone.value }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +349,6 @@ class ConfirmAccountProviderPresenterTest {
|
||||||
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
|
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
|
||||||
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||||
defaultOidcActionFlow: OidcActionFlow = FakeOidcActionFlow(),
|
defaultOidcActionFlow: OidcActionFlow = FakeOidcActionFlow(),
|
||||||
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
|
|
||||||
webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever = FakeWebClientUrlForAuthenticationRetriever(),
|
webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever = FakeWebClientUrlForAuthenticationRetriever(),
|
||||||
) = ConfirmAccountProviderPresenter(
|
) = ConfirmAccountProviderPresenter(
|
||||||
params = params,
|
params = params,
|
||||||
|
|
@ -365,7 +356,6 @@ class ConfirmAccountProviderPresenterTest {
|
||||||
loginHelper = createLoginHelper(
|
loginHelper = createLoginHelper(
|
||||||
authenticationService = matrixAuthenticationService,
|
authenticationService = matrixAuthenticationService,
|
||||||
oidcActionFlow = defaultOidcActionFlow,
|
oidcActionFlow = defaultOidcActionFlow,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
webClientUrlForAuthenticationRetriever = webClientUrlForAuthenticationRetriever,
|
webClientUrlForAuthenticationRetriever = webClientUrlForAuthenticationRetriever,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import app.cash.molecule.RecompositionMode
|
||||||
import app.cash.molecule.moleculeFlow
|
import app.cash.molecule.moleculeFlow
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.core.meta.BuildMeta
|
import io.element.android.libraries.core.meta.BuildMeta
|
||||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
||||||
|
|
@ -88,9 +87,6 @@ class CreateAccountPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - receiving a message able to be parsed change the state to success`() = runTest {
|
fun `present - receiving a message able to be parsed change the state to success`() = runTest {
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory()
|
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(false)
|
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
val lambda = lambdaRecorder<String, ExternalSession> { _ -> anExternalSession() }
|
val lambda = lambdaRecorder<String, ExternalSession> { _ -> anExternalSession() }
|
||||||
val sessionVerificationService = FakeSessionVerificationService()
|
val sessionVerificationService = FakeSessionVerificationService()
|
||||||
val client = FakeMatrixClient(sessionVerificationService = sessionVerificationService)
|
val client = FakeMatrixClient(sessionVerificationService = sessionVerificationService)
|
||||||
|
|
@ -100,7 +96,6 @@ class CreateAccountPresenterTest {
|
||||||
importCreatedSessionLambda = { Result.success(A_SESSION_ID) }
|
importCreatedSessionLambda = { Result.success(A_SESSION_ID) }
|
||||||
),
|
),
|
||||||
messageParser = FakeMessageParser(lambda),
|
messageParser = FakeMessageParser(lambda),
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
clientProvider = clientProvider,
|
clientProvider = clientProvider,
|
||||||
)
|
)
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
|
@ -113,14 +108,10 @@ class CreateAccountPresenterTest {
|
||||||
assertThat(awaitItem().createAction.dataOrNull()).isEqualTo(A_SESSION_ID)
|
assertThat(awaitItem().createAction.dataOrNull()).isEqualTo(A_SESSION_ID)
|
||||||
}
|
}
|
||||||
lambda.assertions().isCalledOnce().with(value("aMessage"))
|
lambda.assertions().isCalledOnce().with(value("aMessage"))
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isTrue()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - receiving a message able to be parsed but error in importing change the state to error`() = runTest {
|
fun `present - receiving a message able to be parsed but error in importing change the state to error`() = runTest {
|
||||||
val defaultLoginUserStory = DefaultLoginUserStory()
|
|
||||||
defaultLoginUserStory.setLoginFlowIsDone(false)
|
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
val presenter = createPresenter(
|
val presenter = createPresenter(
|
||||||
authenticationService = FakeMatrixAuthenticationService(
|
authenticationService = FakeMatrixAuthenticationService(
|
||||||
importCreatedSessionLambda = { Result.failure(AN_EXCEPTION) }
|
importCreatedSessionLambda = { Result.failure(AN_EXCEPTION) }
|
||||||
|
|
@ -135,20 +126,17 @@ class CreateAccountPresenterTest {
|
||||||
assertThat(awaitItem().createAction.isLoading()).isTrue()
|
assertThat(awaitItem().createAction.isLoading()).isTrue()
|
||||||
assertThat(awaitItem().createAction.errorOrNull()).isNotNull()
|
assertThat(awaitItem().createAction.errorOrNull()).isNotNull()
|
||||||
}
|
}
|
||||||
assertThat(defaultLoginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPresenter(
|
private fun createPresenter(
|
||||||
url: String = "aUrl",
|
url: String = "aUrl",
|
||||||
authenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
authenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||||
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
|
|
||||||
messageParser: MessageParser = FakeMessageParser(),
|
messageParser: MessageParser = FakeMessageParser(),
|
||||||
buildMeta: BuildMeta = aBuildMeta(),
|
buildMeta: BuildMeta = aBuildMeta(),
|
||||||
clientProvider: FakeMatrixClientProvider = FakeMatrixClientProvider(),
|
clientProvider: FakeMatrixClientProvider = FakeMatrixClientProvider(),
|
||||||
) = CreateAccountPresenter(
|
) = CreateAccountPresenter(
|
||||||
url = url,
|
url = url,
|
||||||
authenticationService = authenticationService,
|
authenticationService = authenticationService,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
messageParser = messageParser,
|
messageParser = messageParser,
|
||||||
buildMeta = buildMeta,
|
buildMeta = buildMeta,
|
||||||
clientProvider = clientProvider,
|
clientProvider = clientProvider,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ package io.element.android.features.login.impl.screens.loginpassword
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.appconfig.AuthenticationConfig
|
import io.element.android.appconfig.AuthenticationConfig
|
||||||
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
||||||
import io.element.android.libraries.architecture.AsyncData
|
import io.element.android.libraries.architecture.AsyncData
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
|
|
@ -64,12 +63,9 @@ class LoginPasswordPresenterTest {
|
||||||
fun `present - submit`() = runTest {
|
fun `present - submit`() = runTest {
|
||||||
val authenticationService = FakeMatrixAuthenticationService()
|
val authenticationService = FakeMatrixAuthenticationService()
|
||||||
authenticationService.givenHomeserver(A_HOMESERVER)
|
authenticationService.givenHomeserver(A_HOMESERVER)
|
||||||
val loginUserStory = DefaultLoginUserStory().apply { setLoginFlowIsDone(false) }
|
|
||||||
createLoginPasswordPresenter(
|
createLoginPasswordPresenter(
|
||||||
authenticationService = authenticationService,
|
authenticationService = authenticationService,
|
||||||
defaultLoginUserStory = loginUserStory,
|
|
||||||
).test {
|
).test {
|
||||||
assertThat(loginUserStory.loginFlowIsDone.value).isFalse()
|
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(LoginPasswordEvents.SetLogin(A_USER_NAME))
|
initialState.eventSink.invoke(LoginPasswordEvents.SetLogin(A_USER_NAME))
|
||||||
initialState.eventSink.invoke(LoginPasswordEvents.SetPassword(A_PASSWORD))
|
initialState.eventSink.invoke(LoginPasswordEvents.SetPassword(A_PASSWORD))
|
||||||
|
|
@ -80,7 +76,6 @@ class LoginPasswordPresenterTest {
|
||||||
assertThat(submitState.loginAction).isInstanceOf(AsyncData.Loading::class.java)
|
assertThat(submitState.loginAction).isInstanceOf(AsyncData.Loading::class.java)
|
||||||
val loggedInState = awaitItem()
|
val loggedInState = awaitItem()
|
||||||
assertThat(loggedInState.loginAction).isEqualTo(AsyncData.Success(A_SESSION_ID))
|
assertThat(loggedInState.loginAction).isEqualTo(AsyncData.Success(A_SESSION_ID))
|
||||||
assertThat(loginUserStory.loginFlowIsDone.value).isTrue()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,10 +129,8 @@ class LoginPasswordPresenterTest {
|
||||||
private fun createLoginPasswordPresenter(
|
private fun createLoginPasswordPresenter(
|
||||||
authenticationService: FakeMatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
authenticationService: FakeMatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||||
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
|
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
|
||||||
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory()
|
|
||||||
): LoginPasswordPresenter = LoginPasswordPresenter(
|
): LoginPasswordPresenter = LoginPasswordPresenter(
|
||||||
authenticationService = authenticationService,
|
authenticationService = authenticationService,
|
||||||
accountProviderDataSource = accountProviderDataSource,
|
accountProviderDataSource = accountProviderDataSource,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.appconfig.OnBoardingConfig
|
import io.element.android.appconfig.OnBoardingConfig
|
||||||
import io.element.android.features.enterprise.api.EnterpriseService
|
import io.element.android.features.enterprise.api.EnterpriseService
|
||||||
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
||||||
import io.element.android.features.login.impl.DefaultLoginUserStory
|
|
||||||
import io.element.android.features.login.impl.accesscontrol.DefaultAccountProviderAccessControl
|
import io.element.android.features.login.impl.accesscontrol.DefaultAccountProviderAccessControl
|
||||||
import io.element.android.features.login.impl.login.LoginHelper
|
import io.element.android.features.login.impl.login.LoginHelper
|
||||||
import io.element.android.features.login.impl.web.FakeWebClientUrlForAuthenticationRetriever
|
import io.element.android.features.login.impl.web.FakeWebClientUrlForAuthenticationRetriever
|
||||||
|
|
@ -253,11 +252,9 @@ private fun createPresenter(
|
||||||
fun createLoginHelper(
|
fun createLoginHelper(
|
||||||
oidcActionFlow: OidcActionFlow = FakeOidcActionFlow(),
|
oidcActionFlow: OidcActionFlow = FakeOidcActionFlow(),
|
||||||
authenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
authenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
|
||||||
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
|
|
||||||
webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever = FakeWebClientUrlForAuthenticationRetriever(),
|
webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever = FakeWebClientUrlForAuthenticationRetriever(),
|
||||||
): LoginHelper = LoginHelper(
|
): LoginHelper = LoginHelper(
|
||||||
oidcActionFlow = oidcActionFlow,
|
oidcActionFlow = oidcActionFlow,
|
||||||
authenticationService = authenticationService,
|
authenticationService = authenticationService,
|
||||||
defaultLoginUserStory = defaultLoginUserStory,
|
|
||||||
webClientUrlForAuthenticationRetriever = webClientUrlForAuthenticationRetriever,
|
webClientUrlForAuthenticationRetriever = webClientUrlForAuthenticationRetriever,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue