Avoid usage of not() and add unit tests.
This commit is contained in:
parent
98792c9562
commit
70e3e768aa
7 changed files with 58 additions and 6 deletions
|
|
@ -11,4 +11,6 @@ data class MatrixHomeServerDetails(
|
|||
val url: String,
|
||||
val supportsPasswordLogin: Boolean,
|
||||
val supportsOidcLogin: Boolean,
|
||||
)
|
||||
) {
|
||||
val isSupported = supportsPasswordLogin || supportsOidcLogin
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.auth
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.test.auth.aMatrixHomeServerDetails
|
||||
import org.junit.Test
|
||||
|
||||
class MatrixHomeServerDetailsTest {
|
||||
@Test
|
||||
fun `if homeserver supports oidc, then it is supported`() {
|
||||
val sut = aMatrixHomeServerDetails(
|
||||
supportsOidcLogin = true,
|
||||
supportsPasswordLogin = false,
|
||||
)
|
||||
assertThat(sut.isSupported).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if homeserver supports password, then it is supported`() {
|
||||
val sut = aMatrixHomeServerDetails(
|
||||
supportsOidcLogin = false,
|
||||
supportsPasswordLogin = true,
|
||||
)
|
||||
assertThat(sut.isSupported).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if homeserver supports both, then it is supported`() {
|
||||
val sut = aMatrixHomeServerDetails(
|
||||
supportsOidcLogin = true,
|
||||
supportsPasswordLogin = true,
|
||||
)
|
||||
assertThat(sut.isSupported).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if homeserver supports none, then it is not supported`() {
|
||||
val sut = aMatrixHomeServerDetails(
|
||||
supportsOidcLogin = false,
|
||||
supportsPasswordLogin = false,
|
||||
)
|
||||
assertThat(sut.isSupported).isFalse()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue