BIT-2255: When admin-approval is denied, do not update the UI (#1283)

This commit is contained in:
David Perez 2024-04-17 16:25:00 -05:00 committed by Álison Fernandes
parent f6f2746b25
commit e69ef60f53
2 changed files with 38 additions and 13 deletions

View file

@ -158,6 +158,10 @@ class LoginWithDeviceViewModel @Inject constructor(
} }
CreateAuthRequestResult.Declined -> { CreateAuthRequestResult.Declined -> {
when (state.loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> {
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
viewState = LoginWithDeviceState.ViewState.Content( viewState = LoginWithDeviceState.ViewState.Content(
@ -173,6 +177,12 @@ class LoginWithDeviceViewModel @Inject constructor(
} }
} }
LoginWithDeviceType.SSO_ADMIN_APPROVAL -> {
// Do nothing, the user should not be informed of this state
}
}
}
CreateAuthRequestResult.Expired -> { CreateAuthRequestResult.Expired -> {
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(

View file

@ -442,7 +442,7 @@ class LoginWithDeviceViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength") @Suppress("MaxLineLength")
@Test @Test
fun `on createAuthRequestWithUpdates Declined received should show content with error dialog`() { fun `on createAuthRequestWithUpdates with OTHER_DEVICE, Declined received should show error dialog`() {
val viewModel = createViewModel() val viewModel = createViewModel()
assertEquals(DEFAULT_STATE, viewModel.stateFlow.value) assertEquals(DEFAULT_STATE, viewModel.stateFlow.value)
mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined) mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined)
@ -461,6 +461,21 @@ class LoginWithDeviceViewModelTest : BaseViewModelTest() {
) )
} }
@Suppress("MaxLineLength")
@Test
fun `on createAuthRequestWithUpdates with SSO_ADMIN_APPROVAL, Declined received should show unchanged content`() {
val initialState = DEFAULT_STATE.copy(
loginWithDeviceType = LoginWithDeviceType.SSO_ADMIN_APPROVAL,
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
loginWithDeviceType = LoginWithDeviceType.SSO_ADMIN_APPROVAL,
),
)
val viewModel = createViewModel(initialState)
assertEquals(initialState, viewModel.stateFlow.value)
mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined)
assertEquals(initialState, viewModel.stateFlow.value)
}
@Test @Test
fun `on createAuthRequestWithUpdates Expired received should show content with error dialog`() { fun `on createAuthRequestWithUpdates Expired received should show content with error dialog`() {
val viewModel = createViewModel() val viewModel = createViewModel()