diff --git a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/CommonJvmConfig.kt b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/CommonJvmConfig.kt index 574eac21bf9..26a90d7efe5 100644 --- a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/CommonJvmConfig.kt +++ b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/CommonJvmConfig.kt @@ -20,7 +20,7 @@ package com.wire.kalium.plugins import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget -fun KotlinJvmTarget.commonJvmConfig(includeNativeInterop: Boolean, enableIntegrationTests: Boolean = false) { +fun KotlinJvmTarget.commonJvmConfig(includeNativeInterop: Boolean) { compilations.all { kotlinOptions.jvmTarget = "17" kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" @@ -35,9 +35,4 @@ fun KotlinJvmTarget.commonJvmConfig(includeNativeInterop: Boolean, enableIntegra } } } - if (enableIntegrationTests) { - testRuns.getByName("integrationTest").executionTask.configure { - useJUnit() - } - } } diff --git a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/LibraryPlugin.kt b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/LibraryPlugin.kt index a6bbdbcba54..ea47ab11801 100644 --- a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/LibraryPlugin.kt +++ b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/LibraryPlugin.kt @@ -38,7 +38,6 @@ class LibraryPlugin : Plugin { val enableJs: Property val enableJsTests: Property val includeNativeInterop: Property - val enableIntegrationTests: Property } @get:Nested @@ -54,8 +53,7 @@ class LibraryPlugin : Plugin { enableApple = multiplatformConfiguration.enableApple.getOrElse(true), enableJs = multiplatformConfiguration.enableJs.getOrElse(true), enableJsTests = multiplatformConfiguration.enableJsTests.getOrElse(true), - includeNativeInterop = multiplatformConfiguration.includeNativeInterop.getOrElse(false), - enableIntegrationTests = multiplatformConfiguration.enableIntegrationTests.getOrElse(false) + includeNativeInterop = multiplatformConfiguration.includeNativeInterop.getOrElse(false) ) } } diff --git a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/Multiplatform.kt b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/Multiplatform.kt index fea73e6932c..0918d9eedf6 100644 --- a/buildSrc/src/main/kotlin/com/wire/kalium/plugins/Multiplatform.kt +++ b/buildSrc/src/main/kotlin/com/wire/kalium/plugins/Multiplatform.kt @@ -36,7 +36,6 @@ fun Project.configureDefaultMultiplatform( enableJs: Boolean, enableJsTests: Boolean, includeNativeInterop: Boolean, - enableIntegrationTests: Boolean, androidNamespaceSuffix: String = this.name ) { val kotlinExtension = extensions.findByName("kotlin") as? KotlinMultiplatformExtension @@ -45,7 +44,7 @@ fun Project.configureDefaultMultiplatform( } kotlinExtension.apply { targetHierarchy.default() - jvm { commonJvmConfig(includeNativeInterop, enableIntegrationTests) } + jvm { commonJvmConfig(includeNativeInterop) } androidTarget { commmonKotlinAndroidTargetConfig() } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreLogic.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreLogic.kt index 05cca3c76b5..a3e96198b49 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreLogic.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreLogic.kt @@ -78,8 +78,7 @@ abstract class CoreLogicCommon internal constructor( proxyCredentials, getGlobalScope().serverConfigRepository, networkStateObserver, - kaliumConfigs::certPinningConfig, - kaliumConfigs.mockEngine + kaliumConfigs::certPinningConfig ) @Suppress("MemberVisibilityCanBePrivate") // Can be used by other targets like iOS and JS diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/GlobalKaliumScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/GlobalKaliumScope.kt index 25ecbfb007c..81bb6c8bfb1 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/GlobalKaliumScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/GlobalKaliumScope.kt @@ -101,8 +101,7 @@ class GlobalKaliumScope internal constructor( kaliumConfigs.developmentApiEnabled, userAgent, kaliumConfigs.ignoreSSLCertificatesForUnboundCalls, - kaliumConfigs.certPinningConfig, - kaliumConfigs.mockEngine + kaliumConfigs.certPinningConfig ) } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt index d939aaae23c..bf72978ad2a 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt @@ -463,8 +463,7 @@ class UserSessionScope internal constructor( sessionManager, UserIdDTO(userId.value, userId.domain), userAgent, - certificatePinning = kaliumConfigs.certPinningConfig, - mockEngine = kaliumConfigs.mockEngine + certificatePinning = kaliumConfigs.certPinningConfig ) private val featureSupport: FeatureSupport = FeatureSupportImpl( kaliumConfigs, @@ -475,8 +474,7 @@ class UserSessionScope internal constructor( sessionManager.getProxyCredentials(), globalScope.serverConfigRepository, networkStateObserver, - kaliumConfigs::certPinningConfig, - mockEngine = kaliumConfigs.mockEngine + kaliumConfigs::certPinningConfig ) private val userConfigRepository: UserConfigRepository diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/appVersioning/ObserveIfAppUpdateRequiredUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/appVersioning/ObserveIfAppUpdateRequiredUseCase.kt index 1480a4ccfae..350c554d463 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/appVersioning/ObserveIfAppUpdateRequiredUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/appVersioning/ObserveIfAppUpdateRequiredUseCase.kt @@ -61,7 +61,6 @@ class ObserveIfAppUpdateRequiredUseCaseImpl internal constructor( private val kaliumConfigs: KaliumConfigs ) : ObserveIfAppUpdateRequiredUseCase { - @Suppress("ComplexMethod", "LongMethod") @OptIn(ExperimentalCoroutinesApi::class) override suspend fun invoke(currentAppVersion: Int): Flow { val currentDate = DateTimeUtil.currentIsoDateTimeString() @@ -106,8 +105,7 @@ class ObserveIfAppUpdateRequiredUseCaseImpl internal constructor( proxyCredentials, serverConfigRepository, networkStateObserver, - kaliumConfigs::certPinningConfig, - kaliumConfigs.mockEngine + kaliumConfigs::certPinningConfig ) .checkIfUpdateRequired(currentAppVersion, serverConfig.links.blackList) serverConfig.id to isUpdateRequired diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/auth/AuthenticationScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/auth/AuthenticationScope.kt index 2d4b5783558..2b772c099fc 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/auth/AuthenticationScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/auth/AuthenticationScope.kt @@ -42,7 +42,6 @@ import com.wire.kalium.logic.util.safeComputeIfAbsent import com.wire.kalium.network.NetworkStateObserver import com.wire.kalium.network.networkContainer.UnauthenticatedNetworkContainer import com.wire.kalium.network.session.CertificatePinning -import io.ktor.client.engine.HttpClientEngine class AuthenticationScopeProvider internal constructor( private val userAgent: String @@ -53,14 +52,12 @@ class AuthenticationScopeProvider internal constructor( ConcurrentMutableMap() } - @Suppress("LongParameterList") internal fun provide( serverConfig: ServerConfig, proxyCredentials: ProxyCredentials?, serverConfigRepository: ServerConfigRepository, networkStateObserver: NetworkStateObserver, - certConfig: () -> CertificatePinning, - mockEngine: HttpClientEngine? + certConfig: () -> CertificatePinning ): AuthenticationScope = authenticationScopeStorage.safeComputeIfAbsent(serverConfig to proxyCredentials) { AuthenticationScope( @@ -69,21 +66,18 @@ class AuthenticationScopeProvider internal constructor( proxyCredentials, serverConfigRepository, networkStateObserver, - certConfig, - mockEngine + certConfig ) } } -@Suppress("LongParameterList") class AuthenticationScope internal constructor( private val userAgent: String, private val serverConfig: ServerConfig, private val proxyCredentials: ProxyCredentials?, private val serverConfigRepository: ServerConfigRepository, private val networkStateObserver: NetworkStateObserver, - certConfig: () -> CertificatePinning, - mockEngine: HttpClientEngine? + certConfig: () -> CertificatePinning ) { private val unauthenticatedNetworkContainer: UnauthenticatedNetworkContainer by lazy { UnauthenticatedNetworkContainer.create( @@ -91,8 +85,7 @@ class AuthenticationScope internal constructor( MapperProvider.serverConfigMapper().toDTO(serverConfig), proxyCredentials?.let { MapperProvider.sessionMapper().fromModelToProxyCredentialsDTO(it) }, userAgent, - certificatePinning = certConfig(), - mockEngine + certificatePinning = certConfig() ) } private val loginRepository: LoginRepository diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/KaliumConfigs.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/KaliumConfigs.kt index 45a7882552f..da4232ac83a 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/KaliumConfigs.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/KaliumConfigs.kt @@ -18,9 +18,6 @@ package com.wire.kalium.logic.featureFlags -import com.wire.kalium.network.NetworkStateObserver -import io.ktor.client.engine.HttpClientEngine - data class KaliumConfigs( val forceConstantBitrateCalls: Boolean = false, val fileRestrictionState: BuildFileRestrictionState = BuildFileRestrictionState.NoRestriction, @@ -38,9 +35,7 @@ data class KaliumConfigs( val wipeOnDeviceRemoval: Boolean = false, val wipeOnRootedDevice: Boolean = false, val isWebSocketEnabledByDefault: Boolean = false, - val certPinningConfig: Map> = emptyMap(), - val mockEngine: HttpClientEngine? = null, - val mockNetworkStateObserver: NetworkStateObserver? = null + val certPinningConfig: Map> = emptyMap() ) sealed interface BuildFileRestrictionState { diff --git a/logic/src/jvmMain/kotlin/com/wire/kalium/logic/CoreLogic.kt b/logic/src/jvmMain/kotlin/com/wire/kalium/logic/CoreLogic.kt index 2faa42a6e51..564e95956d8 100644 --- a/logic/src/jvmMain/kotlin/com/wire/kalium/logic/CoreLogic.kt +++ b/logic/src/jvmMain/kotlin/com/wire/kalium/logic/CoreLogic.kt @@ -64,7 +64,7 @@ actual class CoreLogic( override val globalCallManager: GlobalCallManager = GlobalCallManager(PlatformContext()) override val globalWorkScheduler: GlobalWorkScheduler = GlobalWorkSchedulerImpl(this) - override val networkStateObserver: NetworkStateObserver = kaliumConfigs.mockNetworkStateObserver ?: NetworkStateObserverImpl() + override val networkStateObserver: NetworkStateObserver = NetworkStateObserverImpl() override val userSessionScopeProvider: Lazy = lazy { UserSessionScopeProviderImpl( authenticationScopeProvider, diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/networkContainer/AuthenticatedNetworkContainerV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/networkContainer/AuthenticatedNetworkContainerV0.kt index e00b74ad884..667e1521cbe 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/networkContainer/AuthenticatedNetworkContainerV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/networkContainer/AuthenticatedNetworkContainerV0.kt @@ -72,8 +72,7 @@ internal class AuthenticatedNetworkContainerV0 internal constructor( private val networkStateObserver: NetworkStateObserver, private val sessionManager: SessionManager, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy, proxyCredentials = sessionManager.proxyCredentials(), certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV0.kt index 02d01312209..cc218bd0546 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV0.kt @@ -45,8 +45,7 @@ class UnauthenticatedNetworkContainerV0 internal constructor( backendLinks: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = backendLinks.links.apiProxy, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/networkContainer/AuthenticatedNetworkContainerV2.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/networkContainer/AuthenticatedNetworkContainerV2.kt index 932d102011f..4bb236c7be5 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/networkContainer/AuthenticatedNetworkContainerV2.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/networkContainer/AuthenticatedNetworkContainerV2.kt @@ -74,8 +74,7 @@ internal class AuthenticatedNetworkContainerV2 internal constructor( private val sessionManager: SessionManager, private val selfUserId: UserId, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( sessionManager.serverConfig().links.apiProxy, certificatePinning = certificatePinning ) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV2.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV2.kt index caa5b347b12..159aeeeef42 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV2.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV2.kt @@ -45,8 +45,7 @@ class UnauthenticatedNetworkContainerV2 internal constructor( backendLinks: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = backendLinks.links.apiProxy, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/networkContainer/AuthenticatedNetworkContainerV3.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/networkContainer/AuthenticatedNetworkContainerV3.kt index 9cb423f5077..ac04615186b 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/networkContainer/AuthenticatedNetworkContainerV3.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/networkContainer/AuthenticatedNetworkContainerV3.kt @@ -75,8 +75,7 @@ internal class AuthenticatedNetworkContainerV3 internal constructor( private val sessionManager: SessionManager, private val selfUserId: UserId, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy, proxyCredentials = sessionManager.proxyCredentials(), certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV3.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV3.kt index 7ab4887bce0..f17e476e992 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV3.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV3.kt @@ -45,12 +45,11 @@ class UnauthenticatedNetworkContainerV3 internal constructor( backendLinks: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( - serverConfigDTOApiProxy = backendLinks.links.apiProxy, - proxyCredentials = proxyCredentials, - certificatePinning = certificatePinning - ) + engine: HttpClientEngine = defaultHttpEngine( + serverConfigDTOApiProxy = backendLinks.links.apiProxy, + proxyCredentials = proxyCredentials, + certificatePinning = certificatePinning + ), ) : UnauthenticatedNetworkContainer, UnauthenticatedNetworkClientProvider by UnauthenticatedNetworkClientProviderImpl( networkStateObserver, diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt index 6e0b002ead3..bfa063d2f2b 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt @@ -74,8 +74,7 @@ internal class AuthenticatedNetworkContainerV4 internal constructor( private val sessionManager: SessionManager, private val selfUserId: UserId, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy, proxyCredentials = sessionManager.proxyCredentials(), certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV4.kt index df2c7325a47..7a4fff6f917 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV4.kt @@ -45,12 +45,11 @@ class UnauthenticatedNetworkContainerV4 internal constructor( backendLinks: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = backendLinks.links.apiProxy, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning - ) + ), ) : UnauthenticatedNetworkContainer, UnauthenticatedNetworkClientProvider by UnauthenticatedNetworkClientProviderImpl( networkStateObserver, diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt index c6a9f3df2a0..3e83f3686c6 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt @@ -74,8 +74,7 @@ internal class AuthenticatedNetworkContainerV5 internal constructor( private val sessionManager: SessionManager, private val selfUserId: UserId, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy, proxyCredentials = sessionManager.proxyCredentials(), certificatePinning = certificatePinning diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt index b8af2da7412..413d4c46d1f 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt @@ -45,12 +45,11 @@ class UnauthenticatedNetworkContainerV5 internal constructor( backendLinks: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine?, - engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + engine: HttpClientEngine = defaultHttpEngine( serverConfigDTOApiProxy = backendLinks.links.apiProxy, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning - ) + ), ) : UnauthenticatedNetworkContainer, UnauthenticatedNetworkClientProvider by UnauthenticatedNetworkClientProviderImpl( networkStateObserver, diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt index 23cf78dc3b5..d5c2202e49f 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt @@ -106,15 +106,12 @@ interface AuthenticatedNetworkContainer { val propertiesApi: PropertiesApi companion object { - - @Suppress("LongParameterList") fun create( networkStateObserver: NetworkStateObserver, sessionManager: SessionManager, selfUserId: UserId, userAgent: String, - certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine? + certificatePinning: CertificatePinning ): AuthenticatedNetworkContainer { KaliumUserAgentProvider.setUserAgent(userAgent) @@ -123,47 +120,41 @@ interface AuthenticatedNetworkContainer { 0 -> AuthenticatedNetworkContainerV0( networkStateObserver, sessionManager, - certificatePinning, - mockEngine + certificatePinning ) 1 -> AuthenticatedNetworkContainerV0( networkStateObserver, sessionManager, - certificatePinning, - mockEngine + certificatePinning ) 2 -> AuthenticatedNetworkContainerV2( networkStateObserver, sessionManager, selfUserId, - certificatePinning, - mockEngine + certificatePinning ) 3 -> AuthenticatedNetworkContainerV3( networkStateObserver, sessionManager, selfUserId, - certificatePinning, - mockEngine + certificatePinning ) 4 -> AuthenticatedNetworkContainerV4( networkStateObserver, sessionManager, selfUserId, - certificatePinning, - mockEngine + certificatePinning ) 5 -> AuthenticatedNetworkContainerV5( networkStateObserver, sessionManager, selfUserId, - certificatePinning, - mockEngine + certificatePinning ) else -> error("Unsupported version: $version") diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt index 23be6cd2fe8..ea0aa6a7753 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt @@ -36,7 +36,7 @@ import com.wire.kalium.network.session.CertificatePinning import com.wire.kalium.network.tools.ServerConfigDTO import io.ktor.client.engine.HttpClientEngine -@Suppress("MagicNumber", "LongParameterList") +@Suppress("MagicNumber") interface UnauthenticatedNetworkContainer { val loginApi: LoginApi val registerApi: RegisterApi @@ -51,8 +51,7 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO: ServerConfigDTO, proxyCredentials: ProxyCredentialsDTO?, userAgent: String, - certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine? + certificatePinning: CertificatePinning ): UnauthenticatedNetworkContainer { KaliumUserAgentProvider.setUserAgent(userAgent) @@ -63,7 +62,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) 1 -> UnauthenticatedNetworkContainerV0( @@ -71,7 +69,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) 2 -> UnauthenticatedNetworkContainerV2( @@ -79,7 +76,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) 3 -> UnauthenticatedNetworkContainerV3( @@ -87,7 +83,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) 4 -> UnauthenticatedNetworkContainerV4( @@ -95,7 +90,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) 5 -> UnauthenticatedNetworkContainerV5( @@ -103,7 +97,6 @@ interface UnauthenticatedNetworkContainer { serverConfigDTO, proxyCredentials = proxyCredentials, certificatePinning = certificatePinning, - mockEngine ) else -> error("Unsupported version: ${serverConfigDTO.metaData.commonApiVersion.version}") diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnboundNetworkContainer.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnboundNetworkContainer.kt index 200ac759b21..b9aa2934465 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnboundNetworkContainer.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnboundNetworkContainer.kt @@ -60,13 +60,12 @@ class UnboundNetworkContainerCommon( private val developmentApiEnabled: Boolean, userAgent: String, private val ignoreSSLCertificates: Boolean, - certificatePinning: CertificatePinning, - mockEngine: HttpClientEngine? + certificatePinning: CertificatePinning ) : UnboundNetworkContainer, UnboundNetworkClientProvider by UnboundNetworkClientProviderImpl( networkStateObserver = networkStateObserver, userAgent = userAgent, - engine = mockEngine ?: defaultHttpEngine( + engine = defaultHttpEngine( ignoreSSLCertificates = ignoreSSLCertificates, certificatePinning = certificatePinning ) diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/ApiTest.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/ApiTest.kt index 936c6328297..f4d5791f9f2 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/ApiTest.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/ApiTest.kt @@ -113,8 +113,7 @@ internal abstract class ApiTest { engine = mockEngine, sessionManager = TEST_SESSION_MANAGER, networkStateObserver = networkStateObserver, - certificatePinning = emptyMap(), - mockEngine = null + certificatePinning = emptyMap() ).networkClient } @@ -128,8 +127,7 @@ internal abstract class ApiTest { engine = mockEngine, sessionManager = TEST_SESSION_MANAGER, networkStateObserver = networkStateObserver, - certificatePinning = emptyMap(), - mockEngine = null + certificatePinning = emptyMap() ).websocketClient } @@ -183,8 +181,7 @@ internal abstract class ApiTest { engine = mockEngine, proxyCredentials = null, networkStateObserver = networkStateObserver, - certificatePinning = emptyMap(), - mockEngine = null + certificatePinning = emptyMap() ).unauthenticatedNetworkClient } @@ -223,8 +220,7 @@ internal abstract class ApiTest { engine = mockEngine, proxyCredentials = null, networkStateObserver = networkStateObserver, - certificatePinning = emptyMap(), - mockEngine = null + certificatePinning = emptyMap() ).unauthenticatedNetworkClient } @@ -253,8 +249,7 @@ internal abstract class ApiTest { engine = mockEngine, sessionManager = TEST_SESSION_MANAGER, networkStateObserver = networkStateObserver, - certificatePinning = emptyMap(), - mockEngine = null + certificatePinning = emptyMap() ).networkClient } diff --git a/tango-tests/.gitignore b/tango-tests/.gitignore deleted file mode 100644 index b63da4551b2..00000000000 --- a/tango-tests/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/tango-tests/build.gradle.kts b/tango-tests/build.gradle.kts deleted file mode 100644 index 91d351754b8..00000000000 --- a/tango-tests/build.gradle.kts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -@Suppress("DSL_SCOPE_VIOLATION") -plugins { - kotlin("jvm") -} - -kotlin { - sourceSets { - val test by getting { - kotlin.srcDir("src/integrationTest/kotlin") - dependencies { - implementation(project(":network")) - implementation(project(":logic")) - implementation(project(":persistence")) - implementation(kotlin("test")) - implementation(libs.settings.kmpTest) - - implementation(libs.ktor.utils) - implementation(libs.coroutines.core) - implementation(libs.ktxDateTime) - // coroutines - implementation(libs.coroutines.test) - implementation(libs.turbine) - implementation(libs.ktxSerialization) - implementation(libs.ktor.serialization) - implementation(libs.ktor.okHttp) - implementation(libs.ktor.contentNegotiation) - implementation(libs.ktor.json) - implementation(libs.ktor.authClient) - implementation(libs.okhttp.loggingInterceptor) - - implementation(libs.faker) - - // ktor test - implementation(libs.ktor.mock) - } - } - - tasks.withType { - jvmArgs = listOf("-Djava.library.path=/usr/local/lib/:./native/libs") - } - } -} diff --git a/tango-tests/src/integrationTest/kotlin/PocIntegrationTest.kt b/tango-tests/src/integrationTest/kotlin/PocIntegrationTest.kt deleted file mode 100644 index c5419add8d4..00000000000 --- a/tango-tests/src/integrationTest/kotlin/PocIntegrationTest.kt +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -import action.ACMEActions -import action.ClientActions -import action.LoginActions -import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.logic.configuration.server.ServerConfig -import com.wire.kalium.logic.data.logout.LogoutReason -import com.wire.kalium.logic.feature.auth.AuthenticationScope -import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase -import com.wire.kalium.logic.featureFlags.KaliumConfigs -import com.wire.kalium.network.NetworkState -import com.wire.kalium.network.tools.ServerConfigDTO -import io.ktor.client.engine.mock.MockEngine -import kotlinx.coroutines.launch -import kotlinx.coroutines.test.runTest -import org.junit.Test -import util.MockUnboundNetworkClient -import util.MockUnboundNetworkClient.createMockEngine - -class PocIntegrationTest { - - @Test - fun givenApiWhenGettingACMEDirectoriesThenReturnAsExpectedBasedOnNetworkState() = runTest { - val mockEngine = createMockEngine( - listOf(ACMEActions.acmeGetDirectoriesRequestSuccess) - ) - - val coreLogic = createCoreLogic(mockEngine) - - launch { - TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER.updateNetworkState(NetworkState.NotConnected) - - ACMEActions.acmeDirectoriesErrorNotConnected( - coreLogic = coreLogic - ) - - TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER.updateNetworkState(NetworkState.ConnectedWithInternet) - - ACMEActions.acmeDirectoriesSuccess( - coreLogic = coreLogic - ) - - TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER.updateNetworkState(NetworkState.ConnectedWithoutInternet) - - ACMEActions.acmeDirectoriesConnectNoInternet( - coreLogic = coreLogic - ) - } - } - - @Test - fun givenEmailAndPasswordWhenLoggingInThenRegisterClientAndLogout() = runTest { - val mockEngine = createMockEngine( - mutableListOf().apply { - addAll(LoginActions.loginRequestResponseSuccess) - addAll(ClientActions.clientRequestResponseSuccess) - } - ) - - val coreLogic = createCoreLogic(mockEngine) - - TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER.updateNetworkState(NetworkState.ConnectedWithInternet) - - launch { - val authScope = getAuthScope(coreLogic, MockUnboundNetworkClient.TEST_BACKEND_CONFIG.links) - - val loginAuthToken = LoginActions.loginAndAddAuthenticatedUser( - email = USER_EMAIL, - password = USER_PASSWORD, - coreLogic = coreLogic, - authScope = authScope - ) - - val userSessionScope = ClientActions.registerClient( - password = USER_PASSWORD, - userId = loginAuthToken.userId, - coreLogic = coreLogic - ) - - val x = userSessionScope.client.selfClients() - println(x.toString()) - - userSessionScope.logout.invoke(LogoutReason.SELF_SOFT_LOGOUT) - } - } - - private suspend fun getAuthScope(coreLogic: CoreLogic, backend: ServerConfigDTO.Links): AuthenticationScope { - val result = coreLogic.versionedAuthenticationScope( - ServerConfig.Links( - api = backend.api, - accounts = backend.accounts, - webSocket = backend.webSocket, - blackList = backend.blackList, - teams = backend.teams, - website = backend.website, - title = backend.title, - isOnPremises = true, - apiProxy = null - ) - ).invoke() - if (result !is AutoVersionAuthScopeUseCase.Result.Success) { - error("Failed getting AuthScope: $result") - } - return result.authenticationScope - } - - companion object { - private val HOME_DIRECTORY: String = System.getProperty("user.home") - private val USER_EMAIL = "user@domain.com" - private val USER_PASSWORD = "password" - - fun createCoreLogic(mockEngine: MockEngine) = CoreLogic( - rootPath = "$HOME_DIRECTORY/.kalium/accounts-test", - kaliumConfigs = KaliumConfigs( - developmentApiEnabled = true, - encryptProteusStorage = true, - isMLSSupportEnabled = true, - wipeOnDeviceRemoval = true, - mockEngine = mockEngine, - mockNetworkStateObserver = TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER - ), "Wire Integration Tests" - ) - } -} diff --git a/tango-tests/src/integrationTest/kotlin/TestNetworkStateObserver.kt b/tango-tests/src/integrationTest/kotlin/TestNetworkStateObserver.kt deleted file mode 100644 index 2d649431f44..00000000000 --- a/tango-tests/src/integrationTest/kotlin/TestNetworkStateObserver.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -import com.wire.kalium.network.NetworkState -import com.wire.kalium.network.NetworkStateObserver -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow - -class TestNetworkStateObserver(initialState: NetworkState = NetworkState.ConnectedWithInternet) : NetworkStateObserver { - - private val networkState = MutableStateFlow(initialState) - - override fun observeNetworkState(): MutableStateFlow = networkState - - suspend fun updateNetworkState(state: NetworkState) { networkState.emit(state) } - - companion object { - val DEFAULT_TEST_NETWORK_STATE_OBSERVER = TestNetworkStateObserver() - } -} diff --git a/tango-tests/src/integrationTest/kotlin/action/ACMEActions.kt b/tango-tests/src/integrationTest/kotlin/action/ACMEActions.kt deleted file mode 100644 index fbf60941aca..00000000000 --- a/tango-tests/src/integrationTest/kotlin/action/ACMEActions.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package action - -import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.network.api.base.unbound.acme.AcmeDirectoriesResponse -import com.wire.kalium.network.exceptions.KaliumException -import com.wire.kalium.network.utils.NetworkResponse -import io.ktor.http.HttpMethod -import io.ktor.http.HttpStatusCode -import util.MockUnboundNetworkClient -import kotlin.test.assertEquals -import kotlin.test.assertIs - -object ACMEActions { - - suspend fun acmeDirectoriesErrorNotConnected(coreLogic: CoreLogic) = coreLogic.getGlobalScope() - .unboundNetworkContainer - .acmeApi.getACMEDirectories().also { actual -> - assertIs(actual) - assertIs(actual.kException.cause) - } - - suspend fun acmeDirectoriesSuccess(coreLogic: CoreLogic, expected: AcmeDirectoriesResponse = ACME_DIRECTORIES_SAMPLE) = - coreLogic.getGlobalScope() - .unboundNetworkContainer - .acmeApi.getACMEDirectories().also { actual -> - assertIs>(actual) - assertEquals(expected, actual.value) - } - - suspend fun acmeDirectoriesConnectNoInternet(coreLogic: CoreLogic) = coreLogic.getGlobalScope().unboundNetworkContainer - .acmeApi.getACMEDirectories().also { actual -> - assertIs(actual) - assertIs(actual.kException.cause) - } - - /** - * URL Paths - */ - private const val ACME_DIRECTORIES_PATH = "https://balderdash.hogwash.work:9000/acme/google-android/directory" - - /** - * JSON Response - */ - private val ACME_DIRECTORIES_RESPONSE = ACMEApiResponseJsonSample.validAcmeDirectoriesResponse - private val ACME_DIRECTORIES_SAMPLE = ACMEApiResponseJsonSample.ACME_DIRECTORIES_SAMPLE - - /** - * Request / Responses - */ - - val acmeGetDirectoriesRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = ACME_DIRECTORIES_PATH, - httpMethod = HttpMethod.Get, - responseBody = ACME_DIRECTORIES_RESPONSE.rawJson, - statusCode = HttpStatusCode.OK - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/action/ClientActions.kt b/tango-tests/src/integrationTest/kotlin/action/ClientActions.kt deleted file mode 100644 index 5dd768d136c..00000000000 --- a/tango-tests/src/integrationTest/kotlin/action/ClientActions.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package action - -import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.logic.data.client.ClientType -import com.wire.kalium.logic.data.user.UserId -import com.wire.kalium.logic.feature.UserSessionScope -import com.wire.kalium.logic.feature.client.RegisterClientResult -import com.wire.kalium.logic.feature.client.RegisterClientUseCase -import io.ktor.http.HttpMethod -import io.ktor.http.HttpStatusCode -import util.ClientResponseJson -import util.ListOfClientsResponseJson -import util.MockUnboundNetworkClient - -object ClientActions { - - suspend fun registerClient( - password: String, - userId: UserId, - coreLogic: CoreLogic - ): UserSessionScope { - val userSession = coreLogic.getSessionScope(userId) - val registerClientParam = RegisterClientUseCase.RegisterClientParam( - password = password, - capabilities = emptyList(), - clientType = ClientType.Temporary - ) - val registerResult = userSession.client.getOrRegister(registerClientParam) - if (registerResult is RegisterClientResult.Failure) { - error("Failed registering client of monkey : $registerResult") - } - - return userSession - } - - /** - * URL Paths - */ - private const val PATH_CLIENTS = "${CommonResponses.BASE_PATH_V1}clients" - private const val PATH_ACCESS = "${CommonResponses.BASE_PATH_V1}access" - - /** - * Request / Responses - */ - private val registerClientsRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_CLIENTS, - httpMethod = HttpMethod.Post, - responseBody = ClientResponseJson.valid.rawJson, - statusCode = HttpStatusCode.OK, - ) - private val getClientsRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_CLIENTS, - httpMethod = HttpMethod.Get, - responseBody = ListOfClientsResponseJson.valid.rawJson, - statusCode = HttpStatusCode.OK, - ) - private val accessApiRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_ACCESS, - httpMethod = HttpMethod.Post, - responseBody = CommonResponses.VALID_ACCESS_TOKEN_RESPONSE.rawJson, - statusCode = HttpStatusCode.OK, - ) - - val clientRequestResponseSuccess = listOf( - registerClientsRequestSuccess, - getClientsRequestSuccess, - accessApiRequestSuccess - ) - -} diff --git a/tango-tests/src/integrationTest/kotlin/action/CommonResponses.kt b/tango-tests/src/integrationTest/kotlin/action/CommonResponses.kt deleted file mode 100644 index 4c77272112f..00000000000 --- a/tango-tests/src/integrationTest/kotlin/action/CommonResponses.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package action - -import com.wire.kalium.network.api.base.model.AccessTokenDTO -import com.wire.kalium.network.api.base.model.QualifiedID -import util.AccessTokenDTOJson - -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -object CommonResponses { - - /** - * URL Paths - */ - const val BASE_PATH = "https://test.api.com/" - const val BASE_PATH_V1 = "${BASE_PATH}v1/" - - /** - * DTO - */ - val userID = QualifiedID("user_id", "user.domain.io") - private val accessTokenDTO = AccessTokenDTO( - userId = userID.value, - value = "Nlrhltkj-NgJUjEVevHz8Ilgy_pyWCT2b0kQb-GlnamyswanghN9DcC3an5RUuA7sh1_nC3hv2ZzMRlIhPM7Ag==.v=1.k=1.d=1637254939." + - "t=a.l=.u=75ebeb16-a860-4be4-84a7-157654b492cf.c=18401233206926541098", - expiresIn = 900, - tokenType = "Bearer" - ) - - /** - * JSON Response - */ - const val REFRESH_TOKEN = "415a5306-a476-41bc-af36-94ab075fd881" - val VALID_ACCESS_TOKEN_RESPONSE = AccessTokenDTOJson.createValid(accessTokenDTO) -} diff --git a/tango-tests/src/integrationTest/kotlin/action/LoginActions.kt b/tango-tests/src/integrationTest/kotlin/action/LoginActions.kt deleted file mode 100644 index 179654c4846..00000000000 --- a/tango-tests/src/integrationTest/kotlin/action/LoginActions.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package action - -import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase -import com.wire.kalium.logic.feature.auth.AuthTokens -import com.wire.kalium.logic.feature.auth.AuthenticationResult -import com.wire.kalium.logic.feature.auth.AuthenticationScope -import com.wire.kalium.network.api.base.model.SelfUserDTO -import io.ktor.http.HttpMethod -import io.ktor.http.HttpStatusCode -import util.ListUsersResponseJson -import util.MockUnboundNetworkClient -import util.ServerConfigDTOJson -import util.UserDTOJson - -object LoginActions { - - suspend fun loginAndAddAuthenticatedUser( - email: String, - password: String, - coreLogic: CoreLogic, - authScope: AuthenticationScope, - ): AuthTokens { - val loginResult = authScope.login(email, password, true) - if (loginResult !is AuthenticationResult.Success) { - error("User creds didn't work ($email, $password)") - } - - coreLogic.globalScope { - val storeResult = addAuthenticatedAccount( - serverConfigId = loginResult.serverConfigId, - ssoId = loginResult.ssoID, - authTokens = loginResult.authData, - proxyCredentials = loginResult.proxyCredentials, - replace = true - ) - if (storeResult !is AddAuthenticatedUserUseCase.Result.Success) { - error("Failed to store user. $storeResult") - } - } - - return loginResult.authData - } - - /** - * URL Paths - */ - private const val PATH_LOGIN = "${CommonResponses.BASE_PATH_V1}login?persist=true" - private const val PATH_SELF = "${CommonResponses.BASE_PATH_V1}self" - private const val PATH_LOGOUT = "${CommonResponses.BASE_PATH_V1}logout" - private const val PATH_API_VERSION = "${CommonResponses.BASE_PATH}api-version" - - /** - * JSON Response - */ - private val listUsersResponseJson = ListUsersResponseJson.v0 - private val selfUserDTO = SelfUserDTO( - id = CommonResponses.userID, - name = "user_name_123", - accentId = 2, - assets = listOf(), - deleted = null, - email = "test@testio.test", - handle = "mrtestio", - service = null, - teamId = null, - expiresAt = "2026-03-25T14:17:27.364Z", - nonQualifiedId = "", - locale = "", - managedByDTO = null, - phone = null, - ssoID = null - ) - private val VALID_SELF_RESPONSE = UserDTOJson.createValid(selfUserDTO) - - /** - * Requests / Responses - */ - private val loginRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_LOGIN, - responseBody = CommonResponses.VALID_ACCESS_TOKEN_RESPONSE.rawJson, - statusCode = HttpStatusCode.OK, - httpMethod = HttpMethod.Post, - headers = mapOf("set-cookie" to "zuid=${CommonResponses.REFRESH_TOKEN}") - ) - - private val selfRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_SELF, - responseBody = VALID_SELF_RESPONSE.rawJson, - httpMethod = HttpMethod.Get, - statusCode = HttpStatusCode.OK, - ) - - private val userDetailsRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_LOGOUT, - responseBody = listUsersResponseJson.rawJson, - httpMethod = HttpMethod.Post, - statusCode = HttpStatusCode.Forbidden, - ) - - private val apiVersionRequestSuccess = MockUnboundNetworkClient.TestRequestHandler( - path = PATH_API_VERSION, - responseBody = ServerConfigDTOJson.validServerConfigResponse.rawJson, - httpMethod = HttpMethod.Get, - statusCode = HttpStatusCode.OK, - ) - - val loginRequestResponseSuccess = listOf( - loginRequestSuccess, - selfRequestSuccess, - userDetailsRequestSuccess, - apiVersionRequestSuccess - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ACMEApiResponseJsonSample.kt b/tango-tests/src/integrationTest/kotlin/util/ACMEApiResponseJsonSample.kt deleted file mode 100644 index 7ad1b288b24..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ACMEApiResponseJsonSample.kt +++ /dev/null @@ -1,75 +0,0 @@ - -import com.wire.kalium.network.api.base.unbound.acme.AcmeDirectoriesResponse -import com.wire.kalium.network.api.base.unbound.acme.ChallengeResponse -import util.ValidJsonProvider - -object ACMEApiResponseJsonSample { - - const val ACME_BASE_URL = "https://balderdash.hogwash.work:9000" - - - val ACME_DIRECTORIES_SAMPLE = AcmeDirectoriesResponse( - newNonce = "$ACME_BASE_URL/acme/wire/new-nonce", - newAccount = "$ACME_BASE_URL/acme/wire/new-account", - newOrder = "$ACME_BASE_URL/acme/wire/new-order", - revokeCert = "$ACME_BASE_URL/acme/wire/revoke-cert", - keyChange = "$ACME_BASE_URL/acme/wire/key-change" - ) - - private val jsonProviderAcmeDirectories = { serializable: AcmeDirectoriesResponse -> - """ - |{ - | "newNonce": "${serializable.newNonce}", - | "newAccount": "${serializable.newAccount}", - | "newOrder": "${serializable.newOrder}" - | "revokeCert": "${serializable.revokeCert}" - | "keyChange": "${serializable.keyChange}" - |} - """.trimMargin() - } - - val validAcmeDirectoriesResponse = ValidJsonProvider( - ACME_DIRECTORIES_SAMPLE, - jsonProviderAcmeDirectories - ) - - private val jsonProviderAcmeResponse = { serializable: AcmeDirectoriesResponse -> - """ - |{ - | "sampleBody": "sample", - |} - """.trimMargin() - } - - val ACME_RESPONSE_SAMPLE = ValidJsonProvider( - ACME_DIRECTORIES_SAMPLE, - jsonProviderAcmeResponse - ) - - val ACME_CHALLENGE_RESPONSE_SAMPLE = ChallengeResponse( - type = "wire-dpop-01", - url = "https://example.com/acme/chall/prV_B7yEyA4", - status = "valid", - token = "LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0", - nonce = "random-nonce" - ) - - private val jsonProviderAcmeChallenge = { serializable: ChallengeResponse -> - """ - |{ - | "type": "${serializable.type}", - | "url": "${serializable.url}", - | "status": "${serializable.status}", - | "token": "${serializable.token}" - | "nonce": "${serializable.nonce}" - |} - """.trimMargin() - } - - val jsonProviderAcmeChallengeResponse = ValidJsonProvider( - ACME_CHALLENGE_RESPONSE_SAMPLE, - jsonProviderAcmeChallenge - ) - - -} diff --git a/tango-tests/src/integrationTest/kotlin/util/AccessTokenDTOJson.kt b/tango-tests/src/integrationTest/kotlin/util/AccessTokenDTOJson.kt deleted file mode 100644 index 6f724fcefa4..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/AccessTokenDTOJson.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.model.AccessTokenDTO - -object AccessTokenDTOJson { - private val jsonProvider = { serializable: AccessTokenDTO -> - """ - |{ - | "expires_in": ${serializable.expiresIn}, - | "access_token": "${serializable.value}", - | "user": "${serializable.userId}", - | "token_type": "${serializable.tokenType}" - |} - """.trimMargin() - } - - fun createValid(accessTokenDTO: AccessTokenDTO) = ValidJsonProvider(accessTokenDTO, jsonProvider) - - val valid = ValidJsonProvider( - AccessTokenDTO( - userId = "user_id", - value = "Nlrhltkj-NgJUjEVevHz8Ilgy_pyWCT2b0kQb-GlnamyswanghN9DcC3an5RUuA7sh1_nC3hv2ZzMRlIhPM7Ag==.v=1.k=1.d=1637254939." + - "t=a.l=.u=75ebeb16-a860-4be4-84a7-157654b492cf.c=18401233206926541098", - expiresIn = 900, - tokenType = "Bearer" - ), jsonProvider - ) - - val missingAccessToken = FaultyJsonProvider( - """ - |{ - | "expires_in": 900, - | "user": "75ebeb16-a860-4be4-84a7-157654b492", - | "token_type": "Bearer" - |} - """.trimMargin() - ) - val missingTokenType = FaultyJsonProvider( - """ - |{ - | "expires_in": 900, - | "access_token": "Nlrhltkj-NgJUjEVevHz8Ilgy_pyWCT2b0kQb-GlnamyswanghN9DcC3an5RUuA7sh1_nC3hv2ZzMRlIhPM7Ag==.v=1.k=1.d=1637254939.t=a.l=.u=75ebeb16-a860-4be4-84a7-157654b492cf.c=18401233206926541098", - | "user": "75ebeb16-a860-4be4-84a7-157654b492" - |} - """.trimMargin() - ) - val missingUser = FaultyJsonProvider( - """ - |{ - | "expires_in": 900, - | "access_token": "Nlrhltkj-NgJUjEVevHz8Ilgy_pyWCT2b0kQb-GlnamyswanghN9DcC3an5RUuA7sh1_nC3hv2ZzMRlIhPM7Ag==.v=1.k=1.d=1637254939.t=a.l=.u=75ebeb16-a860-4be4-84a7-157654b492cf.c=18401233206926541098", - | "token_type": "Bearer" - |} - """.trimMargin() - ) - val missingExpiration = FaultyJsonProvider( - """ - |{ - | "access_token": "Nlrhltkj-NgJUjEVevHz8Ilgy_pyWCT2b0kQb-GlnamyswanghN9DcC3an5RUuA7sh1_nC3hv2ZzMRlIhPM7Ag==.v=1.k=1.d=1637254939.t=a.l=.u=75ebeb16-a860-4be4-84a7-157654b492cf.c=18401233206926541098", - | "user": "75ebeb16-a860-4be4-84a7-157654b492", - | "token_type": "Bearer" - |} - """.trimMargin() - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ClientResponseJson.kt b/tango-tests/src/integrationTest/kotlin/util/ClientResponseJson.kt deleted file mode 100644 index fceb88bcb55..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ClientResponseJson.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.authenticated.client.Capabilities -import com.wire.kalium.network.api.base.authenticated.client.ClientCapabilityDTO -import com.wire.kalium.network.api.base.authenticated.client.ClientDTO -import com.wire.kalium.network.api.base.authenticated.client.ClientTypeDTO -import com.wire.kalium.network.api.base.authenticated.client.DeviceTypeDTO -import com.wire.kalium.network.api.base.model.LocationResponse - -object ClientResponseJson { - private val jsonProvider = { serializable: ClientDTO -> - """ - |{ - | "id": "${serializable.clientId}", - | "type": "${serializable.type}", - | "time": "${serializable.registrationTime}", - | "last_active": "${serializable.lastActive}", - | "class": "${serializable.deviceType}", - | "label": "${serializable.label}", - | "cookie": "${serializable.cookie}", - | "location": { - | "lat": ${serializable.location!!.latitude}, - | "lon": ${serializable.location!!.longitude} - | }, - | "model": "${serializable.model}", - | "capabilities": { - | "capabilities": [ - | "${serializable.capabilities!!.capabilities[0]}" - | ] - | } - |} - """.trimMargin() - } - - val valid = ValidJsonProvider( - ClientDTO( - clientId = "defkrr8e7grgsoufhg8", - type = ClientTypeDTO.Permanent, - deviceType = DeviceTypeDTO.Phone, - registrationTime = "2023-05-12T10:52:02.671Z", - lastActive = "2023-05-12T10:52:02.671Z", - location = LocationResponse(latitude = "1.2345", longitude = "6.7890"), - label = "label", - cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", - capabilities = Capabilities(listOf(ClientCapabilityDTO.LegalHoldImplicitConsent)), - model = "model", - mlsPublicKeys = null - ), - jsonProvider - ) - - fun createValid(client: ClientDTO) = ValidJsonProvider(client, jsonProvider) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ErrorResponseJson.kt b/tango-tests/src/integrationTest/kotlin/util/ErrorResponseJson.kt deleted file mode 100644 index 596cf100ecb..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ErrorResponseJson.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.model.ErrorResponse -import com.wire.kalium.network.api.base.model.FederationConflictResponse - -object ErrorResponseJson { - private val jsonProvider = { serializable: ErrorResponse -> - """ - |{ - | "code": ${serializable.code}, - | "label": "${serializable.label}", - | "message": "${serializable.message}" - |} - """.trimMargin() - } - - private val federationConflictJsonProvider = { serializable: FederationConflictResponse -> - """ - |{ - | "non_federating_backends": ${serializable.nonFederatingBackends} - |} - """.trimMargin() - } - - val valid = ValidJsonProvider( - ErrorResponse(code = 499, label = "error_label", message = "error_message"), - jsonProvider - ) - - fun valid(error: ErrorResponse) = ValidJsonProvider( - error, - jsonProvider - ) - - fun validFederationConflictingBackends(error: FederationConflictResponse) = ValidJsonProvider( - error, - federationConflictJsonProvider - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ListOfClientsResponseJson.kt b/tango-tests/src/integrationTest/kotlin/util/ListOfClientsResponseJson.kt deleted file mode 100644 index 1995cd90eda..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ListOfClientsResponseJson.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.authenticated.client.Capabilities -import com.wire.kalium.network.api.base.authenticated.client.ClientCapabilityDTO -import com.wire.kalium.network.api.base.authenticated.client.ClientDTO -import com.wire.kalium.network.api.base.authenticated.client.ClientTypeDTO -import com.wire.kalium.network.api.base.authenticated.client.DeviceTypeDTO -import com.wire.kalium.network.api.base.model.LocationResponse - -object ListOfClientsResponseJson { - private val jsonProvider = { serializable: ClientDTO -> - """ - |[{ - | "id": "${serializable.clientId}", - | "type": "${serializable.type}", - | "time": "${serializable.registrationTime}", - | "last_active": "${serializable.lastActive}", - | "class": "${serializable.deviceType}", - | "label": "${serializable.label}", - | "cookie": "${serializable.cookie}", - | "location": { - | "lat": ${serializable.location!!.latitude}, - | "lon": ${serializable.location!!.longitude} - | }, - | "model": "${serializable.model}", - | "capabilities": { - | "capabilities": [ - | "${serializable.capabilities!!.capabilities[0]}" - | ] - | } - |}] - """.trimMargin() - } - - val valid = ValidJsonProvider( - ClientDTO( - clientId = "defkrr8e7grgsoufhg8", - type = ClientTypeDTO.Permanent, - deviceType = DeviceTypeDTO.Phone, - registrationTime = "2023-05-12T10:52:02.671Z", - lastActive = "2023-05-12T10:52:02.671Z", - location = LocationResponse(latitude = "1.2345", longitude = "6.7890"), - label = "label", - cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", - capabilities = Capabilities(listOf(ClientCapabilityDTO.LegalHoldImplicitConsent)), - model = "model", - mlsPublicKeys = null - ), - jsonProvider - ) - - fun createValid(client: ClientDTO) = ValidJsonProvider(client, jsonProvider) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ListUsersResponseJson.kt b/tango-tests/src/integrationTest/kotlin/util/ListUsersResponseJson.kt deleted file mode 100644 index 33453af2308..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ListUsersResponseJson.kt +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.authenticated.userDetails.ListUsersDTO -import com.wire.kalium.network.api.base.model.LegalHoldStatusResponse -import com.wire.kalium.network.api.base.model.UserId -import com.wire.kalium.network.api.base.model.UserProfileDTO - -object ListUsersResponseJson { - - private val USER_1 = UserId("user10d0-000b-9c1a-000d-a4130002c221", "domain1.example.com") - private val USER_2 = UserId("user20d0-000b-9c1a-000d-a4130002c221", "domain2.example.com") - private val USER_3 = UserId("user30d0-000b-9c1a-000d-a4130002c220", "domain3.example.com") - - private val expectedUsersResponse = listOf( - UserProfileDTO( - id = USER_1, - name = "usera", - handle = "user_a", - accentId = 2147483647, - legalHoldStatus = LegalHoldStatusResponse.ENABLED, - teamId = null, - assets = emptyList(), - deleted = false, - email = null, - expiresAt = null, - nonQualifiedId = USER_1.value, - service = null - ), - UserProfileDTO( - id = USER_2, - name = "userb", - handle = "user_b", - accentId = 2147483647, - legalHoldStatus = LegalHoldStatusResponse.ENABLED, - teamId = null, - assets = emptyList(), - deleted = false, - email = null, - expiresAt = null, - nonQualifiedId = USER_2.value, - service = null - ), - ) - - private val validUserInfoProvider = { userInfo: List -> - """ - |[ - | { - | "accent_id": ${userInfo[0].accentId}, - | "handle": "${userInfo[0].handle}", - | "legalhold_status": "enabled", - | "name": "${userInfo[0].name}", - | "assets": ${userInfo[0].assets}, - | "id": "${userInfo[0].id.value}", - | "deleted": "false", - | "qualified_id": { - | "domain": "${userInfo[0].id.domain}", - | "id": "${userInfo[0].id.value}" - | } - | }, - | { - | "accent_id": ${userInfo[1].accentId}, - | "handle": "${userInfo[1].handle}", - | "legalhold_status": "enabled", - | "name": "${userInfo[1].name}", - | "assets": ${userInfo[1].assets}, - | "id": "${userInfo[1].id.value}", - | "deleted": "false", - | "qualified_id": { - | "domain": "${userInfo[1].id.domain}", - | "id": "${userInfo[1].id.value}" - | } - | } - |] - """.trimMargin() - } - - val v0 = ValidJsonProvider( - expectedUsersResponse - ) { - validUserInfoProvider(it) - } - - val v4_withFailedUsers = ValidJsonProvider( - ListUsersDTO(listOf(USER_3), expectedUsersResponse) - ) { - """ - |{ - | "failed": [ - | { - | "domain": "${it.usersFailed[0].domain}", - | "id": "${it.usersFailed[0].value}" - | } - | ], - | "found": ${validUserInfoProvider(it.usersFound)} - |} - """.trimMargin() - } - - val v4 = ValidJsonProvider( - ListUsersDTO(listOf(USER_3), expectedUsersResponse) - ) { - """ - |{ - | "found": ${validUserInfoProvider(it.usersFound)} - |} - """.trimMargin() - } -} diff --git a/tango-tests/src/integrationTest/kotlin/util/LoginWithEmailRequestJson.kt b/tango-tests/src/integrationTest/kotlin/util/LoginWithEmailRequestJson.kt deleted file mode 100644 index b620f5eb86f..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/LoginWithEmailRequestJson.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.unauthenticated.LoginApi -import kotlinx.serialization.json.buildJsonObject - -object LoginWithEmailRequestJson { - private val jsonProvider = { serializable: LoginApi.LoginParam -> - buildJsonObject { - "password" to serializable.password - "label" to serializable.label - when (serializable) { - is LoginApi.LoginParam.LoginWithEmail -> "email" to serializable.email - is LoginApi.LoginParam.LoginWithHandle -> "handle" to serializable.handle - } - }.toString() - } - - val validLoginWithEmail = ValidJsonProvider( - LoginApi.LoginParam.LoginWithEmail( - email = "user@email.de", - label = "label", - password = "password", - verificationCode = "verificationCode" - ), jsonProvider - ) - - val validLoginWithHandle = ValidJsonProvider( - LoginApi.LoginParam.LoginWithHandle( - handle = "cool_user_name", - label = "label", - password = "password", - ), jsonProvider - ) - - val missingEmailAndHandel = FaultyJsonProvider( - """ - |{ - | "label": "label", - | "password": "password", - |} - """.trimMargin() - ) - - val missingLabel = FaultyJsonProvider( - """ - |{ - | "email": "user@email.de", - | "password": "password", - |} - """.trimMargin() - ) - - val missingPassword = FaultyJsonProvider( - """ - |{ - | "label": "label", - | "email": "user@email.de", - |} - """.trimMargin() - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/MockUnboundNetworkClient.kt b/tango-tests/src/integrationTest/kotlin/util/MockUnboundNetworkClient.kt deleted file mode 100644 index 05c88dcee15..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/MockUnboundNetworkClient.kt +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package util - -import com.wire.kalium.network.networkContainer.KaliumUserAgentProvider -import com.wire.kalium.network.tools.ApiVersionDTO -import com.wire.kalium.network.tools.ServerConfigDTO -import io.ktor.client.engine.mock.MockEngine -import io.ktor.client.engine.mock.respond -import io.ktor.client.request.HttpRequestData -import io.ktor.http.HeadersImpl -import io.ktor.http.HttpHeaders -import io.ktor.http.HttpMethod -import io.ktor.http.HttpStatusCode -import io.ktor.utils.io.ByteReadChannel -import kotlin.test.fail - -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -object MockUnboundNetworkClient { - init { - KaliumUserAgentProvider.setUserAgent("test/useragent") - } - - /** - * Creates a mock Ktor Http client - * @param responseBody the response body as a ByteArray - * @param statusCode the response http status code - * @param assertion lambda function to apply assertions to the request - * @return mock Ktor http client - */ - class TestRequestHandler( - val path: String, - val responseBody: String, - val statusCode: HttpStatusCode, - val assertion: (HttpRequestData.() -> Unit) = {}, - val headers: Map? = null, - val httpMethod: HttpMethod? = null - ) - - fun createMockEngine( - expectedRequests: List - ): MockEngine = MockEngine { currentRequest -> - expectedRequests.forEach { request -> - val head: Map> = (request.headers?.let { - mutableMapOf(HttpHeaders.ContentType to "application/json").plus(request.headers).mapValues { listOf(it.value) } - } ?: run { - mapOf(HttpHeaders.ContentType to "application/json").mapValues { listOf(it.value) } - }) - if (request.path == currentRequest.url.toString() && request.httpMethod == currentRequest.method) { - return@MockEngine respond( - content = ByteReadChannel(request.responseBody), - status = request.statusCode, - headers = HeadersImpl(head) - ) - } - } - fail("no expected response was found for ${currentRequest.method.value}:${currentRequest.url}") - } - - fun createMockEngine2( - responseBody: String, - statusCode: HttpStatusCode, - assertion: (HttpRequestData.() -> Unit) = {}, - headers: Map? = null - ): MockEngine { - - val newHeaders: Map> = (headers?.let { - headers.mapValues { listOf(it.value) } - } ?: run { - mapOf(HttpHeaders.ContentType to "application/json").mapValues { listOf(it.value) } - }) - - return MockEngine { request -> - request.assertion() - respond( - content = ByteReadChannel(responseBody), - status = statusCode, - headers = HeadersImpl(newHeaders) - ) - } - } - - val TEST_BACKEND_CONFIG = - ServerConfigDTO( - id = "id", - ServerConfigDTO.Links( - "https://test.api.com", - "https://test.account.com", - "https://test.ws.com", - "https://test.blacklist", - "https://test.teams.com", - "https://test.wire.com", - "Test Title", - false, - null - ), - ServerConfigDTO.MetaData( - false, - ApiVersionDTO.Valid(1), - null - ) - ) - - val TEST_BACKEND_LINKS = - ServerConfigDTO.Links( - "https://test.api.com", - "https://test.account.com", - "https://test.ws.com", - "https://test.blacklist", - "https://test.teams.com", - "https://test.wire.com", - "Test Title", - false, - null - ) - - val TEST_BACKEND = - ServerConfigDTO( - id = "id", - links = TEST_BACKEND_LINKS, - metaData = ServerConfigDTO.MetaData( - false, - ApiVersionDTO.Valid(0), - domain = null - ) - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/RegisterClientRequestJson.kt b/tango-tests/src/integrationTest/kotlin/util/RegisterClientRequestJson.kt deleted file mode 100644 index 0d7978a8628..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/RegisterClientRequestJson.kt +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.authenticated.client.ClientCapabilityDTO -import com.wire.kalium.network.api.base.authenticated.client.ClientTypeDTO -import com.wire.kalium.network.api.base.authenticated.client.DeviceTypeDTO -import com.wire.kalium.network.api.base.authenticated.client.RegisterClientRequest -import com.wire.kalium.network.api.base.authenticated.prekey.PreKeyDTO -import kotlinx.serialization.json.add -import kotlinx.serialization.json.addJsonObject -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.put -import kotlinx.serialization.json.putJsonArray -import kotlinx.serialization.json.putJsonObject - -object RegisterClientRequestJson { - - private val jsonProvider = { serializable: RegisterClientRequest -> - buildJsonObject { - // FIXME: Data is being created without being added to the json object - // Doing "key" to "value" does not add the key to the json object. - // We need to call put("key", "value") instead. - putJsonArray("prekeys") { - serializable.preKeys.forEach { - addJsonObject { - "id" to it.id - "key" to it.key - } - } - } - putJsonObject("lastkey") { - "id" to serializable.lastKey.id - "key" to serializable.lastKey.key - } - "type" to serializable.type - serializable.password?.let { "password" to it } - serializable.deviceType?.let { "class" to it } - serializable.label?.let { "label" to it } - serializable.model?.let { "model" to it } - serializable.cookieLabel?.let { "cookie" to it } - serializable.capabilities?.let { - putJsonArray("capabilities") { - it.forEach { clientCapabilityDTO -> - add(clientCapabilityDTO.toString()) - } - } - } - serializable.secondFactorVerificationCode?.let { - put("verification_code", it) - } - }.toString() - } - - val valid = ValidJsonProvider( - RegisterClientRequest( - password = "password", - deviceType = DeviceTypeDTO.Desktop, - type = ClientTypeDTO.Permanent, - label = "label", - preKeys = listOf(PreKeyDTO(1, "preykey_1"), PreKeyDTO(2, "prekey_2")), - lastKey = PreKeyDTO(999, "last_prekey"), - capabilities = listOf(ClientCapabilityDTO.LegalHoldImplicitConsent), - model = "model", - cookieLabel = "cookie label", - secondFactorVerificationCode = "123456" - ), - jsonProvider - ) - - val missingDeviceType = FaultyJsonProvider( - """ - |{ - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "permanent", - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingLabel = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "desktop", - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingPassword = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "desktop", - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingTye = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingPreKeys = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "type": "desktop", - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingLastKey = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "desktop", - | "capabilities": [ - | "legalhold-implicit-consent" - | ], - | "model": "model" - |} - """.trimMargin() - ) - - val missingCapabilities = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "permanent", - | "model": "model" - |} - """.trimMargin() - ) - - val missingModel = FaultyJsonProvider( - """ - |{ - | "class": "desktop", - | "label": "label", - | "lastkey": { - | "key": "last_prekey", - | "id": 9999 - | }, - | "password": "password", - | "prekeys": [ - | { - | "id": 1, - | "key": "prekey_1" - | }, - | { - | "id": 2, - | "key": "prekey_2"" - | } - | ], - | "type": "permanent", - | "capabilities": [ - | "legalhold-implicit-consent" - | ] - |} - """.trimMargin() - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ServerConfigDTOJson.kt b/tango-tests/src/integrationTest/kotlin/util/ServerConfigDTOJson.kt deleted file mode 100644 index e2555472e89..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ServerConfigDTOJson.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package util - -import com.wire.kalium.network.tools.ApiVersionDTO -import com.wire.kalium.network.tools.ServerConfigDTO -import io.ktor.websocket.Serializer - -object ServerConfigDTOJson { - - private val jsonProviderServerConfig = { serializable: Serializer-> - """ - |{ - | "domain":"example.com", - | "federation":false, - | "supported":[ - | 0, - | 1 - | ] - |} - """.trimMargin() - } - - val validServerConfigResponse = ValidJsonProvider( - Serializer(), - jsonProviderServerConfig - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/UserDTOJson.kt b/tango-tests/src/integrationTest/kotlin/util/UserDTOJson.kt deleted file mode 100644 index 5967b5efea8..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/UserDTOJson.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.model.SelfUserDTO -import com.wire.kalium.network.api.base.model.UserId -import kotlinx.serialization.json.addJsonObject -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.put -import kotlinx.serialization.json.putJsonArray -import kotlinx.serialization.json.putJsonObject - -object UserDTOJson { - - private val jsonProvider = { serializable: SelfUserDTO -> - buildJsonObject { - put("accent_id", serializable.accentId) - put("id", serializable.nonQualifiedId) - putJsonObject("qualified_id") { - put("id", serializable.id.value) - put("domain", serializable.id.domain) - } - put("name", serializable.name) - put("locale", serializable.locale) - putJsonArray("assets") { - if (serializable.assets.isNotEmpty()) { - addJsonObject { - serializable.assets.forEach { userAsset -> - put("key", userAsset.key) - put("type", userAsset.type.toString()) - userAsset.size?.let { put("size", it.toString()) } - } - } - } - } - serializable.deleted?.let { put("deleted", it) } - serializable.email?.let { put("email", it) } - serializable.phone?.let { put("phone", it) } - serializable.expiresAt?.let { put("expires_at", it) } - serializable.handle?.let { put("handle", it) } - serializable.service?.let { service -> - putJsonObject("service") { - put("id", service.id) - put("provider", service.provider) - } - } - serializable.teamId?.let { put("team", it) } - serializable.managedByDTO?.let { put("managed_by", it.toString()) } - serializable.ssoID?.let { userSsoID -> - putJsonObject("sso_id") { - userSsoID.subject?.let { put("subject", it) } - userSsoID.scimExternalId?.let { put("scim_external_id", it) } - userSsoID.tenant?.let { put("tenant", it) } - } - } - }.toString() - } - - fun createValid(userDTO: SelfUserDTO) = ValidJsonProvider(userDTO, jsonProvider) - - val valid = ValidJsonProvider( - SelfUserDTO( - id = UserId("user_id", "domain.com"), - name = "user_name_123", - accentId = 2, - assets = listOf(), - deleted = null, - email = null, - handle = null, - service = null, - teamId = null, - expiresAt = "", - nonQualifiedId = "", - locale = "", - managedByDTO = null, - phone = null, - ssoID = null - ), jsonProvider - ) -} diff --git a/tango-tests/src/integrationTest/kotlin/util/ValidSingleJsonObjectProvider.kt b/tango-tests/src/integrationTest/kotlin/util/ValidSingleJsonObjectProvider.kt deleted file mode 100644 index eeb0d2ec761..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/ValidSingleJsonObjectProvider.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -sealed interface JsonProvider { - val rawJson: String -} - -data class FaultyJsonProvider(override val rawJson: String) : JsonProvider - -data class ValidJsonProvider( - val serializableData: Serializable, - private val jsonProvider: (Serializable) -> String -) : JsonProvider { - override val rawJson: String = jsonProvider(serializableData).replace("\\s".toRegex(), "") -} - -data class AnyResponseProvider( - val data: T, - private val jsonProvider: (T) -> String -) : JsonProvider { - override val rawJson: String = jsonProvider(data).replace("\\s".toRegex(), "") -} diff --git a/tango-tests/src/integrationTest/kotlin/util/VersionInfoDTOJson.kt b/tango-tests/src/integrationTest/kotlin/util/VersionInfoDTOJson.kt deleted file mode 100644 index e6a943b639d..00000000000 --- a/tango-tests/src/integrationTest/kotlin/util/VersionInfoDTOJson.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Wire - * Copyright (C) 2023 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package util - -import com.wire.kalium.network.api.base.unbound.versioning.VersionInfoDTO -import kotlinx.serialization.json.add -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.put -import kotlinx.serialization.json.putJsonArray - -object VersionInfoDTOJson { - private val defaultParametersJson = { serializable: VersionInfoDTO -> - buildJsonObject { - serializable.developmentSupported?.let { - putJsonArray("development") { - it.forEach { add(it) } - } - } - putJsonArray("supported") { - serializable.supported.forEach { add(it) } - } - put("federation", serializable.federation) - serializable.domain?.let { put("domain", it) } - }.toString() - } - - val valid404Result = VersionInfoDTO(null, null, false, listOf(0)) - - val valid = ValidJsonProvider( - VersionInfoDTO(listOf(1), "test.api.com", true, listOf(0, 1)), - defaultParametersJson - ) -}