Skip to content

Commit

Permalink
fixes after cherry pick
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk committed Oct 16, 2023
1 parent 1cedb9f commit 618ec62
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ class UserSessionScope internal constructor(
sessionManager,
UserIdDTO(userId.value, userId.domain),
userAgent,
certificatePinning = kaliumConfigs.certPinningConfig,
mockEngine = kaliumConfigs.kaliumMockEngine?.mockEngine,
kaliumLogger = userScopedLogger
)
private val featureSupport: FeatureSupport = FeatureSupportImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ import io.ktor.client.engine.HttpClientEngine
internal class AuthenticatedNetworkContainerV0 internal constructor(
private val networkStateObserver: NetworkStateObserver,
private val sessionManager: SessionManager,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
engine: HttpClientEngine = defaultHttpEngine(sessionManager.serverConfig().links.apiProxy, sessionManager.proxyCredentials())
engine: HttpClientEngine = mockEngine ?: defaultHttpEngine(
serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy,
proxyCredentials = sessionManager.proxyCredentials(),
certificatePinning = certificatePinning
)
) : AuthenticatedNetworkContainer,
AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl(
sessionManager,
networkStateObserver,
{ httpClient -> AccessTokenApiV0(httpClient) },
engine,
kaliumLogger
sessionManager = sessionManager,
networkStateObserver = networkStateObserver,
accessTokenApi = { httpClient -> AccessTokenApiV0(httpClient) },
engine = engine,
kaliumLogger = kaliumLogger
) {

override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV0(networkClient.httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ internal class AuthenticatedNetworkContainerV2 internal constructor(
private val networkStateObserver: NetworkStateObserver,
private val sessionManager: SessionManager,
private val selfUserId: UserId,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
engine: HttpClientEngine = defaultHttpEngine(sessionManager.serverConfig().links.apiProxy, sessionManager.proxyCredentials())
engine: HttpClientEngine = mockEngine ?: defaultHttpEngine(
serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy,
proxyCredentials = sessionManager.proxyCredentials(),
certificatePinning = certificatePinning
)
) : AuthenticatedNetworkContainer,
AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl(
sessionManager,
networkStateObserver,
{ httpClient -> AccessTokenApiV2(httpClient) },
engine,
kaliumLogger
sessionManager = sessionManager,
networkStateObserver = networkStateObserver,
accessTokenApi = { httpClient -> AccessTokenApiV2(httpClient) },
engine = engine,
kaliumLogger = kaliumLogger
) {

override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV2(networkClient.httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,21 @@ internal class AuthenticatedNetworkContainerV3 internal constructor(
private val networkStateObserver: NetworkStateObserver,
private val sessionManager: SessionManager,
private val selfUserId: UserId,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
engine: HttpClientEngine = defaultHttpEngine(sessionManager.serverConfig().links.apiProxy, sessionManager.proxyCredentials())
engine: HttpClientEngine = mockEngine ?: defaultHttpEngine(
serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy,
proxyCredentials = sessionManager.proxyCredentials(),
certificatePinning = certificatePinning
)
) : AuthenticatedNetworkContainer,
AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl(
sessionManager,
networkStateObserver,
{ httpClient -> AccessTokenApiV3(httpClient) },
engine,
kaliumLogger
sessionManager = sessionManager,
networkStateObserver = networkStateObserver,
accessTokenApi = { httpClient -> AccessTokenApiV3(httpClient) },
engine = engine,
kaliumLogger = kaliumLogger
) {

override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV3(networkClient.httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,21 @@ internal class AuthenticatedNetworkContainerV4 internal constructor(
private val networkStateObserver: NetworkStateObserver,
private val sessionManager: SessionManager,
private val selfUserId: UserId,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
engine: HttpClientEngine = defaultHttpEngine(
sessionManager.serverConfig().links.apiProxy,
sessionManager.proxyCredentials()
engine: HttpClientEngine = mockEngine ?: defaultHttpEngine(
serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy,
proxyCredentials = sessionManager.proxyCredentials(),
certificatePinning = certificatePinning
)
) : AuthenticatedNetworkContainer,
AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl(
sessionManager,
networkStateObserver,
{ httpClient -> AccessTokenApiV4(httpClient) },
engine,
kaliumLogger
sessionManager = sessionManager,
networkStateObserver = networkStateObserver,
accessTokenApi = { httpClient -> AccessTokenApiV4(httpClient) },
engine = engine,
kaliumLogger = kaliumLogger
) {

override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV4(networkClient.httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,21 @@ internal class AuthenticatedNetworkContainerV5 internal constructor(
private val networkStateObserver: NetworkStateObserver,
private val sessionManager: SessionManager,
private val selfUserId: UserId,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
engine: HttpClientEngine = defaultHttpEngine(
sessionManager.serverConfig().links.apiProxy,
sessionManager.proxyCredentials()
engine: HttpClientEngine = mockEngine ?: defaultHttpEngine(
serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy,
proxyCredentials = sessionManager.proxyCredentials(),
certificatePinning = certificatePinning
)
) : AuthenticatedNetworkContainer,
AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl(
sessionManager,
networkStateObserver,
{ httpClient -> AccessTokenApiV5(httpClient) },
engine,
kaliumLogger
sessionManager = sessionManager,
networkStateObserver = networkStateObserver,
accessTokenApi = { httpClient -> AccessTokenApiV5(httpClient) },
engine = engine,
kaliumLogger = kaliumLogger
) {

override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV5(networkClient.httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ interface AuthenticatedNetworkContainer {
sessionManager: SessionManager,
selfUserId: UserId,
userAgent: String,
certificatePinning: CertificatePinning,
mockEngine: HttpClientEngine?,
kaliumLogger: KaliumLogger,
): AuthenticatedNetworkContainer {

Expand All @@ -123,40 +125,52 @@ interface AuthenticatedNetworkContainer {
0 -> AuthenticatedNetworkContainerV0(
networkStateObserver,
sessionManager,
certificatePinning,
mockEngine,
kaliumLogger,
)

1 -> AuthenticatedNetworkContainerV0(
networkStateObserver,
sessionManager,
certificatePinning,
mockEngine,
kaliumLogger,
)

2 -> AuthenticatedNetworkContainerV2(
networkStateObserver,
sessionManager,
selfUserId,
certificatePinning,
mockEngine,
kaliumLogger,
)

3 -> AuthenticatedNetworkContainerV3(
networkStateObserver,
sessionManager,
selfUserId,
certificatePinning,
mockEngine,
kaliumLogger,
)

4 -> AuthenticatedNetworkContainerV4(
networkStateObserver,
sessionManager,
selfUserId,
certificatePinning,
mockEngine,
kaliumLogger,
)

5 -> AuthenticatedNetworkContainerV5(
networkStateObserver,
sessionManager,
selfUserId,
certificatePinning,
mockEngine,
kaliumLogger,
)

Expand All @@ -178,7 +192,7 @@ internal class AuthenticatedHttpClientProviderImpl(
private val sessionManager: SessionManager,
private val networkStateObserver: NetworkStateObserver,
private val accessTokenApi: (httpClient: HttpClient) -> AccessTokenApi,
private val engine: HttpClientEngine = defaultHttpEngine(sessionManager.serverConfig().links.apiProxy),
private val engine: HttpClientEngine,
private val kaliumLogger: KaliumLogger,
) : AuthenticatedHttpClientProvider {

Expand Down
6 changes: 6 additions & 0 deletions network/src/commonTest/kotlin/com/wire/kalium/api/ApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ internal abstract class ApiTest {
engine = mockEngine,
sessionManager = TEST_SESSION_MANAGER,
networkStateObserver = networkStateObserver,
certificatePinning = emptyMap(),
mockEngine = null,
kaliumLogger = kaliumLogger
).networkClient
}
Expand All @@ -128,6 +130,8 @@ internal abstract class ApiTest {
engine = mockEngine,
sessionManager = TEST_SESSION_MANAGER,
networkStateObserver = networkStateObserver,
certificatePinning = emptyMap(),
mockEngine = null,
kaliumLogger = kaliumLogger
).websocketClient
}
Expand Down Expand Up @@ -253,6 +257,8 @@ internal abstract class ApiTest {
engine = mockEngine,
sessionManager = TEST_SESSION_MANAGER,
networkStateObserver = networkStateObserver,
certificatePinning = emptyMap(),
mockEngine = null,
kaliumLogger = kaliumLogger
).networkClient
}
Expand Down

0 comments on commit 618ec62

Please sign in to comment.