Using UiaCancelledException on reAuth cancellation

This commit is contained in:
Maxime NATUREL 2022-09-22 10:31:37 +02:00
parent 0d7d841d73
commit 99c2088d0e
2 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import im.vector.app.core.di.ActiveSessionHolder
import org.matrix.android.sdk.api.Matrix
import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.auth.UserPasswordAuth
import org.matrix.android.sdk.api.session.uia.exceptions.UiaCancelledException
import org.matrix.android.sdk.api.util.fromBase64
import timber.log.Timber
import javax.inject.Inject
@ -62,7 +63,7 @@ class PendingAuthHandler @Inject constructor(
fun reAuthCancelled() {
Timber.d("reAuthCancelled")
uiaContinuation?.resumeWithException(Exception())
uiaContinuation?.resumeWithException(UiaCancelledException())
uiaContinuation = null
pendingAuth = null
}

View File

@ -33,6 +33,7 @@ import org.junit.Ignore
import org.junit.Test
import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.auth.UserPasswordAuth
import org.matrix.android.sdk.api.session.uia.exceptions.UiaCancelledException
import kotlin.coroutines.Continuation
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
@ -90,7 +91,7 @@ class PendingAuthHandlerTest {
pendingAuthHandler.ssoAuthDone()
// Then
verify { continuation.resumeWithException(match { it is IllegalArgumentException })}
verify { continuation.resumeWithException(match { it is IllegalArgumentException }) }
}
@Test
@ -138,6 +139,6 @@ class PendingAuthHandlerTest {
// Then
pendingAuthHandler.pendingAuth shouldBe null
pendingAuthHandler.uiaContinuation shouldBe null
verify { continuation.resumeWithException(match { it is Exception })}
verify { continuation.resumeWithException(match { it is UiaCancelledException }) }
}
}