mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Merge commit from fork
* Log error on unsupported OAuth URL. * Bump version to 26.06.2
This commit is contained in:
+4
-2
@@ -12,6 +12,7 @@ import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import io.element.android.libraries.matrix.api.auth.OAuthRedirectUrlProvider
|
||||
import io.element.android.libraries.oauth.api.OAuthAction
|
||||
import timber.log.Timber
|
||||
|
||||
fun interface OAuthUrlParser {
|
||||
fun parse(url: String): OAuthAction?
|
||||
@@ -38,7 +39,8 @@ class DefaultOAuthUrlParser(
|
||||
if (url.contains("error=access_denied")) return OAuthAction.GoBack()
|
||||
if (url.contains("code=")) return OAuthAction.Success(url)
|
||||
|
||||
// Other case not supported, let's crash the app for now
|
||||
error("Not supported: $url")
|
||||
// Other cases are not supported, log an error and return null
|
||||
Timber.w("Unsupported OAuth url")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -13,7 +13,6 @@ import androidx.core.net.toUri
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.test.auth.FakeOAuthRedirectUrlProvider
|
||||
import io.element.android.libraries.oauth.api.OAuthAction
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
@@ -54,9 +53,8 @@ class DefaultOAuthIntentResolverTest {
|
||||
action = Intent.ACTION_VIEW
|
||||
data = "io.element.android:/invalid".toUri()
|
||||
}
|
||||
assertThrows(IllegalStateException::class.java) {
|
||||
sut.resolve(intent)
|
||||
}
|
||||
val result = sut.resolve(intent)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
private fun createDefaultOAuthIntentResolver(): DefaultOAuthIntentResolver {
|
||||
|
||||
Reference in New Issue
Block a user