Skip to content

Commit bfaa9f8

Browse files
committed
Add unit test on HomeserverLoginDetails.map()
1 parent e117b74 commit bfaa9f8

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.libraries.matrix.impl.auth
9+
10+
import com.google.common.truth.Truth.assertThat
11+
import io.element.android.libraries.matrix.api.auth.MatrixHomeServerDetails
12+
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustHomeserverLoginDetails
13+
import org.junit.Test
14+
15+
class HomeserverDetailsKtTest {
16+
@Test
17+
fun `map should be correct`() {
18+
// Given
19+
val homeserverLoginDetails = FakeRustHomeserverLoginDetails(
20+
url = "https://example.org",
21+
supportsPasswordLogin = true,
22+
supportsOidcLogin = false
23+
)
24+
25+
// When
26+
val result = homeserverLoginDetails.map()
27+
28+
// Then
29+
assertThat(result).isEqualTo(
30+
MatrixHomeServerDetails(
31+
url = "https://example.org",
32+
supportsPasswordLogin = true,
33+
supportsOidcLogin = false
34+
)
35+
)
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.libraries.matrix.impl.auth
9+
10+
import com.google.common.truth.Truth.assertThat
11+
import io.element.android.libraries.matrix.api.auth.OidcConfig
12+
import org.junit.Test
13+
import java.io.File
14+
15+
class OidcConfigurationProviderTest {
16+
@Test
17+
fun get() {
18+
val result = OidcConfigurationProvider(File("/base")).get()
19+
assertThat(result.redirectUri).isEqualTo(OidcConfig.REDIRECT_URI)
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.libraries.matrix.impl.fixtures.fakes
9+
10+
import org.matrix.rustcomponents.sdk.HomeserverLoginDetails
11+
import org.matrix.rustcomponents.sdk.NoPointer
12+
13+
class FakeRustHomeserverLoginDetails(
14+
private val url: String = "https://example.org",
15+
private val supportsPasswordLogin: Boolean = true,
16+
private val supportsOidcLogin: Boolean = false
17+
) : HomeserverLoginDetails(NoPointer) {
18+
override fun url(): String = url
19+
override fun supportsOidcLogin(): Boolean = supportsOidcLogin
20+
override fun supportsPasswordLogin(): Boolean = supportsPasswordLogin
21+
}

0 commit comments

Comments
 (0)