Merge pull request #6370 from element-hq/feature/bma/fixMalformedWellknown
Improve error displayed when .well-known file is malformed
This commit is contained in:
commit
3ad4931b7c
2 changed files with 11 additions and 3 deletions
|
|
@ -22,7 +22,10 @@ fun Throwable.mapAuthenticationException(): AuthenticationException {
|
||||||
is ClientBuildException.Sdk -> AuthenticationException.Generic(message)
|
is ClientBuildException.Sdk -> AuthenticationException.Generic(message)
|
||||||
is ClientBuildException.ServerUnreachable -> AuthenticationException.ServerUnreachable(message)
|
is ClientBuildException.ServerUnreachable -> AuthenticationException.ServerUnreachable(message)
|
||||||
is ClientBuildException.SlidingSync -> AuthenticationException.Generic(message)
|
is ClientBuildException.SlidingSync -> AuthenticationException.Generic(message)
|
||||||
is ClientBuildException.WellKnownDeserializationException -> AuthenticationException.Generic(message)
|
is ClientBuildException.WellKnownDeserializationException -> {
|
||||||
|
// Can happen if the .well-known URL has a redirection to an HTML page for instance
|
||||||
|
AuthenticationException.InvalidServerName(message)
|
||||||
|
}
|
||||||
is ClientBuildException.WellKnownLookupFailed -> AuthenticationException.Generic(message)
|
is ClientBuildException.WellKnownLookupFailed -> AuthenticationException.Generic(message)
|
||||||
is ClientBuildException.EventCache -> AuthenticationException.Generic(message)
|
is ClientBuildException.EventCache -> AuthenticationException.Generic(message)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@ class AuthenticationExceptionMappingTest {
|
||||||
assertThat(mappedException).isException<AuthenticationException.Generic>("Generic exception")
|
assertThat(mappedException).isException<AuthenticationException.Generic>("Generic exception")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `mapping a WellKnownDeserializationException returns a InvalidServerName AuthenticationException`() {
|
||||||
|
val exception = ClientBuildException.WellKnownDeserializationException("WellKnown Deserialization")
|
||||||
|
val mappedException = exception.mapAuthenticationException()
|
||||||
|
assertThat(mappedException).isException<AuthenticationException.InvalidServerName>("WellKnown Deserialization")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `mapping specific exceptions map to their kotlin counterparts`() {
|
fun `mapping specific exceptions map to their kotlin counterparts`() {
|
||||||
assertThat(ClientBuildException.Generic("Unknown error").mapAuthenticationException())
|
assertThat(ClientBuildException.Generic("Unknown error").mapAuthenticationException())
|
||||||
|
|
@ -50,8 +57,6 @@ class AuthenticationExceptionMappingTest {
|
||||||
.isException<AuthenticationException.ServerUnreachable>("Server unreachable")
|
.isException<AuthenticationException.ServerUnreachable>("Server unreachable")
|
||||||
assertThat(ClientBuildException.SlidingSync("Sliding Sync").mapAuthenticationException())
|
assertThat(ClientBuildException.SlidingSync("Sliding Sync").mapAuthenticationException())
|
||||||
.isException<AuthenticationException.Generic>("Sliding Sync")
|
.isException<AuthenticationException.Generic>("Sliding Sync")
|
||||||
assertThat(ClientBuildException.WellKnownDeserializationException("WellKnown Deserialization").mapAuthenticationException())
|
|
||||||
.isException<AuthenticationException.Generic>("WellKnown Deserialization")
|
|
||||||
assertThat(ClientBuildException.WellKnownLookupFailed("WellKnown Lookup Failed").mapAuthenticationException())
|
assertThat(ClientBuildException.WellKnownLookupFailed("WellKnown Lookup Failed").mapAuthenticationException())
|
||||||
.isException<AuthenticationException.Generic>("WellKnown Lookup Failed")
|
.isException<AuthenticationException.Generic>("WellKnown Lookup Failed")
|
||||||
assertThat(ClientBuildException.EventCache("EventCache error").mapAuthenticationException())
|
assertThat(ClientBuildException.EventCache("EventCache error").mapAuthenticationException())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue