diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionCreatorTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionCreatorTest.kt index c9eb2bc2e0..35558fda2f 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionCreatorTest.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionCreatorTest.kt @@ -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() } } diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionParamsCreatorTestBase.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionParamsCreatorTestBase.kt index 8265c1cc27..385b03b061 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionParamsCreatorTestBase.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/auth/DefaultSessionParamsCreatorTestBase.kt @@ -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( diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/internal/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/internal/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt index d066907cdf..0351849d33 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/internal/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/internal/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt @@ -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" } } diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/HomeServerConnectionConfigFixture.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/HomeServerConnectionConfigFixture.kt new file mode 100644 index 0000000000..ceffb506d6 --- /dev/null +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/HomeServerConnectionConfigFixture.kt @@ -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 = emptyList(), + shouldPin: Boolean = false, + tlsVersions: List? = null, + tlsCipherSuites: List? = null, + shouldAcceptTlsExtensions: Boolean = true, + allowHttpExtension: Boolean = false, + forceUsageTlsVersions: Boolean = false + ) = HomeServerConnectionConfig( + homeServerUri, + homeServerUriBase, + identityServerUri, + antiVirusServerUri, + allowedFingerprints, + shouldPin, + tlsVersions, + tlsCipherSuites, + shouldAcceptTlsExtensions, + allowHttpExtension, + forceUsageTlsVersions, + ) +} diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/SessionParamsFixture.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/SessionParamsFixture.kt index 387727e8f0..37f18d1221 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/SessionParamsFixture.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fixtures/SessionParamsFixture.kt @@ -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(