Skip to content

Commit 0fd77dc

Browse files
committed
Ensure that the default account provider cannot be "*"
This should not happen IRL, but better be robust against issue in application configuration.
1 parent 68a7a1e commit 0fd77dc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/accountprovider/AccountProviderDataSource.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import javax.inject.Inject
2020
class AccountProviderDataSource @Inject constructor(
2121
enterpriseService: EnterpriseService,
2222
) {
23-
private val defaultAccountProvider = (enterpriseService.defaultHomeserverList().firstOrNull() ?: AuthenticationConfig.MATRIX_ORG_URL)
23+
private val defaultAccountProvider = (enterpriseService.defaultHomeserverList().firstOrNull { it != "*" } ?: AuthenticationConfig.MATRIX_ORG_URL)
2424
.let { url ->
2525
AccountProvider(
2626
url = url,

features/login/impl/src/test/kotlin/io/element/android/features/login/impl/accountprovider/AccountProviderDataSourceTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ class AccountProviderDataSourceTest {
6060
}
6161
}
6262

63+
@Test
64+
fun `present - ensure that default homeserver is not start char`() = runTest {
65+
val sut = AccountProviderDataSource(
66+
FakeEnterpriseService(
67+
defaultHomeserverListResult = { listOf("*", AuthenticationConfig.MATRIX_ORG_URL) }
68+
)
69+
)
70+
sut.flow.test {
71+
val initialState = awaitItem()
72+
assertThat(initialState).isEqualTo(
73+
AccountProvider(
74+
url = AuthenticationConfig.MATRIX_ORG_URL,
75+
title = "matrix.org",
76+
subtitle = null,
77+
isPublic = true,
78+
isMatrixOrg = true,
79+
isValid = false,
80+
)
81+
)
82+
}
83+
}
84+
6385
@Test
6486
fun `present - user change and reset`() = runTest {
6587
val sut = AccountProviderDataSource(FakeEnterpriseService())

0 commit comments

Comments
 (0)