From 99c2088d0e23571cac2ec9ff048648d0e005a909 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 22 Sep 2022 10:31:37 +0200 Subject: [PATCH] Using UiaCancelledException on reAuth cancellation --- .../java/im/vector/app/features/auth/PendingAuthHandler.kt | 3 ++- .../im/vector/app/features/auth/PendingAuthHandlerTest.kt | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/auth/PendingAuthHandler.kt b/vector/src/main/java/im/vector/app/features/auth/PendingAuthHandler.kt index f4573a54a7..b986090e50 100644 --- a/vector/src/main/java/im/vector/app/features/auth/PendingAuthHandler.kt +++ b/vector/src/main/java/im/vector/app/features/auth/PendingAuthHandler.kt @@ -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 } diff --git a/vector/src/test/java/im/vector/app/features/auth/PendingAuthHandlerTest.kt b/vector/src/test/java/im/vector/app/features/auth/PendingAuthHandlerTest.kt index bc0f6495ae..a3b75aa7f4 100644 --- a/vector/src/test/java/im/vector/app/features/auth/PendingAuthHandlerTest.kt +++ b/vector/src/test/java/im/vector/app/features/auth/PendingAuthHandlerTest.kt @@ -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 }) } } }