Fixes broken tests due to uninitialised HomeServerConnectionConfig homeServerUri
This commit is contained in:
parent
275505b3e6
commit
bb2369dad2
|
@ -19,13 +19,13 @@ package org.matrix.android.sdk.internal.auth
|
|||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runBlockingTest
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fakes.internal.FakeSessionManager
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.FakePendingSessionStore
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.FakeSessionParamsCreator
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.FakeSessionParamsStore
|
||||
import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials
|
||||
import org.matrix.android.sdk.test.fixtures.HomeServerConnectionConfigFixture.aHomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.test.fixtures.SessionParamsFixture.aSessionParams
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
|
@ -56,6 +56,6 @@ class DefaultSessionCreatorTest {
|
|||
companion object {
|
||||
private val sessionParams = aSessionParams()
|
||||
private val credentials = aCredentials()
|
||||
private val homeServerConnectionConfig = HomeServerConnectionConfig.Builder().build()
|
||||
private val homeServerConnectionConfig = aHomeServerConnectionConfig()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ package org.matrix.android.sdk.internal.auth
|
|||
import android.net.Uri
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.matrix.android.sdk.api.auth.data.DiscoveryInformation
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fixtures.CredentialsFixture
|
||||
import org.matrix.android.sdk.test.fixtures.DiscoveryInformationFixture
|
||||
import org.matrix.android.sdk.test.fixtures.HomeServerConnectionConfigFixture.aHomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.test.fixtures.WellKnownBaseConfigFixture
|
||||
|
||||
abstract class DefaultSessionParamsCreatorTestBase {
|
||||
|
@ -33,7 +33,7 @@ abstract class DefaultSessionParamsCreatorTestBase {
|
|||
protected val credentials = CredentialsFixture.aCredentials()
|
||||
protected val credentialsWithHomeServer = CredentialsFixture.aCredentials(discoveryInformation = discoveryWithHomeServer)
|
||||
protected val credentialsWithIdentityServer = CredentialsFixture.aCredentials(discoveryInformation = discoveryWithIdentityServer)
|
||||
protected val homeServerConnectionConfig = HomeServerConnectionConfig.Builder().build()
|
||||
protected val homeServerConnectionConfig = aHomeServerConnectionConfig()
|
||||
|
||||
protected fun assertExpectedSessionParams(sessionParams: SessionParams) {
|
||||
sessionParams shouldBeEqualTo SessionParams(
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.mockk.mockk
|
|||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeSessionParamsMapperMoshi.Companion.sessionParams
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeSessionParamsMapperMoshi.Companion.sessionParamsEntity
|
||||
import org.matrix.android.sdk.test.fixtures.HomeServerConnectionConfigFixture.aHomeServerConnectionConfig
|
||||
|
||||
internal class FakeHomeServerConnectionConfigJsonAdapter {
|
||||
|
||||
|
@ -41,7 +42,7 @@ internal class FakeHomeServerConnectionConfigJsonAdapter {
|
|||
}
|
||||
|
||||
companion object {
|
||||
val homeServerConnectionConfig = HomeServerConnectionConfig.Builder().build()
|
||||
val homeServerConnectionConfig = aHomeServerConnectionConfig()
|
||||
const val HOME_SERVER_CONNECTION_CONFIG_JSON = "home_server_connection_config_json"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.test.fixtures
|
||||
|
||||
import android.net.Uri
|
||||
import okhttp3.CipherSuite
|
||||
import okhttp3.TlsVersion
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
|
||||
|
||||
object HomeServerConnectionConfigFixture {
|
||||
fun aHomeServerConnectionConfig(
|
||||
homeServerUri: Uri = Uri.EMPTY,
|
||||
homeServerUriBase: Uri = Uri.EMPTY,
|
||||
identityServerUri: Uri? = null,
|
||||
antiVirusServerUri: Uri? = null,
|
||||
allowedFingerprints: List<Fingerprint> = emptyList(),
|
||||
shouldPin: Boolean = false,
|
||||
tlsVersions: List<TlsVersion>? = null,
|
||||
tlsCipherSuites: List<CipherSuite>? = null,
|
||||
shouldAcceptTlsExtensions: Boolean = true,
|
||||
allowHttpExtension: Boolean = false,
|
||||
forceUsageTlsVersions: Boolean = false
|
||||
) = HomeServerConnectionConfig(
|
||||
homeServerUri,
|
||||
homeServerUriBase,
|
||||
identityServerUri,
|
||||
antiVirusServerUri,
|
||||
allowedFingerprints,
|
||||
shouldPin,
|
||||
tlsVersions,
|
||||
tlsCipherSuites,
|
||||
shouldAcceptTlsExtensions,
|
||||
allowHttpExtension,
|
||||
forceUsageTlsVersions,
|
||||
)
|
||||
}
|
|
@ -21,11 +21,12 @@ import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
|||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials
|
||||
import org.matrix.android.sdk.test.fixtures.HomeServerConnectionConfigFixture.aHomeServerConnectionConfig
|
||||
|
||||
object SessionParamsFixture {
|
||||
fun aSessionParams(
|
||||
credentials: Credentials = aCredentials(),
|
||||
homeServerConnectionConfig: HomeServerConnectionConfig = HomeServerConnectionConfig.Builder().build(),
|
||||
homeServerConnectionConfig: HomeServerConnectionConfig = aHomeServerConnectionConfig(),
|
||||
isTokenValid: Boolean = false,
|
||||
loginType: LoginType = LoginType.UNKNOWN,
|
||||
) = SessionParams(
|
||||
|
|
Loading…
Reference in New Issue