mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-11 17:33:46 +01:00
matching variable name with type
This commit is contained in:
parent
b76899a6e0
commit
bc2a99c3cf
@ -32,13 +32,13 @@ import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.WellKnown
|
||||
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
|
||||
|
||||
private val A_LOGIN_OR_REGISTER_ACTION = OnboardingAction.AuthenticateAction.LoginDirect("@a-user:id.org", "a-password", "a-device-name")
|
||||
private val A_DIRECT_LOGIN_ACTION = OnboardingAction.AuthenticateAction.LoginDirect("@a-user:id.org", "a-password", "a-device-name")
|
||||
private val A_WELLKNOWN_SUCCESS_RESULT = WellknownResult.Prompt("https://homeserverurl.com", identityServerUrl = null, WellKnown())
|
||||
private val A_WELLKNOWN_FAILED_WITH_CONTENT_RESULT = WellknownResult.FailPrompt("https://homeserverurl.com", WellKnown())
|
||||
private val A_WELLKNOWN_FAILED_WITHOUT_CONTENT_RESULT = WellknownResult.FailPrompt(null, null)
|
||||
private val NO_HOMESERVER_CONFIG: HomeServerConnectionConfig? = null
|
||||
private val A_FALLBACK_CONFIG: HomeServerConnectionConfig = HomeServerConnectionConfig(
|
||||
homeServerUri = FakeUri("https://${A_LOGIN_OR_REGISTER_ACTION.matrixId.getServerName()}").instance,
|
||||
homeServerUri = FakeUri("https://${A_DIRECT_LOGIN_ACTION.matrixId.getServerName()}").instance,
|
||||
homeServerUriBase = FakeUri(A_WELLKNOWN_SUCCESS_RESULT.homeServerUrl).instance,
|
||||
identityServerUri = null
|
||||
)
|
||||
@ -54,11 +54,11 @@ class DirectLoginUseCaseTest {
|
||||
|
||||
@Test
|
||||
fun `when logging in directly, then returns success with direct session result`() = runTest {
|
||||
fakeAuthenticationService.givenWellKnown(A_LOGIN_OR_REGISTER_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, result = A_WELLKNOWN_SUCCESS_RESULT)
|
||||
val (username, password, initialDeviceName) = A_LOGIN_OR_REGISTER_ACTION
|
||||
fakeAuthenticationService.givenWellKnown(A_DIRECT_LOGIN_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, result = A_WELLKNOWN_SUCCESS_RESULT)
|
||||
val (username, password, initialDeviceName) = A_DIRECT_LOGIN_ACTION
|
||||
fakeAuthenticationService.givenDirectAuthentication(A_FALLBACK_CONFIG, username, password, initialDeviceName, result = fakeSession)
|
||||
|
||||
val result = useCase.execute(A_LOGIN_OR_REGISTER_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
val result = useCase.execute(A_DIRECT_LOGIN_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
|
||||
result shouldBeEqualTo Result.success(fakeSession)
|
||||
}
|
||||
@ -66,14 +66,14 @@ class DirectLoginUseCaseTest {
|
||||
@Test
|
||||
fun `given wellknown fails with content, when logging in directly, then returns success with direct session result`() = runTest {
|
||||
fakeAuthenticationService.givenWellKnown(
|
||||
A_LOGIN_OR_REGISTER_ACTION.matrixId,
|
||||
A_DIRECT_LOGIN_ACTION.matrixId,
|
||||
config = NO_HOMESERVER_CONFIG,
|
||||
result = A_WELLKNOWN_FAILED_WITH_CONTENT_RESULT
|
||||
)
|
||||
val (username, password, initialDeviceName) = A_LOGIN_OR_REGISTER_ACTION
|
||||
val (username, password, initialDeviceName) = A_DIRECT_LOGIN_ACTION
|
||||
fakeAuthenticationService.givenDirectAuthentication(A_FALLBACK_CONFIG, username, password, initialDeviceName, result = fakeSession)
|
||||
|
||||
val result = useCase.execute(A_LOGIN_OR_REGISTER_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
val result = useCase.execute(A_DIRECT_LOGIN_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
|
||||
result shouldBeEqualTo Result.success(fakeSession)
|
||||
}
|
||||
@ -81,14 +81,14 @@ class DirectLoginUseCaseTest {
|
||||
@Test
|
||||
fun `given wellknown fails without content, when logging in directly, then returns well known error`() = runTest {
|
||||
fakeAuthenticationService.givenWellKnown(
|
||||
A_LOGIN_OR_REGISTER_ACTION.matrixId,
|
||||
A_DIRECT_LOGIN_ACTION.matrixId,
|
||||
config = NO_HOMESERVER_CONFIG,
|
||||
result = A_WELLKNOWN_FAILED_WITHOUT_CONTENT_RESULT
|
||||
)
|
||||
val (username, password, initialDeviceName) = A_LOGIN_OR_REGISTER_ACTION
|
||||
val (username, password, initialDeviceName) = A_DIRECT_LOGIN_ACTION
|
||||
fakeAuthenticationService.givenDirectAuthentication(A_FALLBACK_CONFIG, username, password, initialDeviceName, result = fakeSession)
|
||||
|
||||
val result = useCase.execute(A_LOGIN_OR_REGISTER_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
val result = useCase.execute(A_DIRECT_LOGIN_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
|
||||
result should { this.isFailure }
|
||||
result should { this.exceptionOrNull() is Exception }
|
||||
@ -97,20 +97,20 @@ class DirectLoginUseCaseTest {
|
||||
|
||||
@Test
|
||||
fun `given wellknown throws, when logging in directly, then returns failure result with original cause`() = runTest {
|
||||
fakeAuthenticationService.givenWellKnownThrows(A_LOGIN_OR_REGISTER_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, cause = AN_ERROR)
|
||||
fakeAuthenticationService.givenWellKnownThrows(A_DIRECT_LOGIN_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, cause = AN_ERROR)
|
||||
|
||||
val result = useCase.execute(A_LOGIN_OR_REGISTER_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
val result = useCase.execute(A_DIRECT_LOGIN_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
|
||||
result shouldBeEqualTo Result.failure(AN_ERROR)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given direct authentication throws, when logging in directly, then returns failure result with original cause`() = runTest {
|
||||
fakeAuthenticationService.givenWellKnown(A_LOGIN_OR_REGISTER_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, result = A_WELLKNOWN_SUCCESS_RESULT)
|
||||
val (username, password, initialDeviceName) = A_LOGIN_OR_REGISTER_ACTION
|
||||
fakeAuthenticationService.givenWellKnown(A_DIRECT_LOGIN_ACTION.matrixId, config = NO_HOMESERVER_CONFIG, result = A_WELLKNOWN_SUCCESS_RESULT)
|
||||
val (username, password, initialDeviceName) = A_DIRECT_LOGIN_ACTION
|
||||
fakeAuthenticationService.givenDirectAuthenticationThrows(A_FALLBACK_CONFIG, username, password, initialDeviceName, cause = AN_ERROR)
|
||||
|
||||
val result = useCase.execute(A_LOGIN_OR_REGISTER_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
val result = useCase.execute(A_DIRECT_LOGIN_ACTION, homeServerConnectionConfig = NO_HOMESERVER_CONFIG)
|
||||
|
||||
result shouldBeEqualTo Result.failure(AN_ERROR)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user