mirror of
https://github.com/bitwarden/android.git
synced 2026-06-12 14:07:54 -05:00
Compare commits
3 Commits
debug-rele
...
authentica
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88e23a4130 | ||
|
|
3a75ba5110 | ||
|
|
29882c9df8 |
@@ -1,6 +1,5 @@
|
|||||||
package com.bitwarden.authenticator.data.platform.repository
|
package com.bitwarden.authenticator.data.platform.repository
|
||||||
|
|
||||||
import com.bitwarden.authenticator.BuildConfig
|
|
||||||
import com.bitwarden.authenticator.data.platform.datasource.disk.FeatureFlagOverrideDiskSource
|
import com.bitwarden.authenticator.data.platform.datasource.disk.FeatureFlagOverrideDiskSource
|
||||||
import com.bitwarden.authenticator.data.platform.manager.getFlagValueOrDefault
|
import com.bitwarden.authenticator.data.platform.manager.getFlagValueOrDefault
|
||||||
import com.bitwarden.authenticator.data.platform.manager.model.FlagKey
|
import com.bitwarden.authenticator.data.platform.manager.model.FlagKey
|
||||||
@@ -22,7 +21,7 @@ class DebugMenuRepositoryImpl(
|
|||||||
.onSubscription { emit(Unit) }
|
.onSubscription { emit(Unit) }
|
||||||
|
|
||||||
override val isDebugMenuEnabled: Boolean
|
override val isDebugMenuEnabled: Boolean
|
||||||
get() = BuildConfig.HAS_DEBUG_MENU
|
get() = true // BuildConfig.HAS_DEBUG_MENU
|
||||||
|
|
||||||
override fun <T : Any> updateFeatureFlag(key: FlagKey<T>, value: T) {
|
override fun <T : Any> updateFeatureFlag(key: FlagKey<T>, value: T) {
|
||||||
featureFlagOverrideDiskSource.saveFeatureFlag(key = key, value = value)
|
featureFlagOverrideDiskSource.saveFeatureFlag(key = key, value = value)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bitwarden.data.repository
|
package com.bitwarden.data.repository
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.bitwarden.data.datasource.disk.ConfigDiskSource
|
import com.bitwarden.data.datasource.disk.ConfigDiskSource
|
||||||
import com.bitwarden.data.datasource.disk.model.ServerConfig
|
import com.bitwarden.data.datasource.disk.model.ServerConfig
|
||||||
import com.bitwarden.data.manager.DispatcherManager
|
import com.bitwarden.data.manager.DispatcherManager
|
||||||
@@ -40,6 +41,8 @@ internal class ServerConfigRepositoryImpl(
|
|||||||
.isAfter(
|
.isAfter(
|
||||||
clock.instant().plusSeconds(MINIMUM_CONFIG_SYNC_INTERVAL_SEC),
|
clock.instant().plusSeconds(MINIMUM_CONFIG_SYNC_INTERVAL_SEC),
|
||||||
)
|
)
|
||||||
|
Log.d("ServerConfigRepository", "needsRefresh: $needsRefresh")
|
||||||
|
Log.d("ServerConfigRepository", "lastSync: ${localConfig?.lastSync}")
|
||||||
|
|
||||||
if (needsRefresh || forceRefresh) {
|
if (needsRefresh || forceRefresh) {
|
||||||
configService
|
configService
|
||||||
@@ -50,6 +53,23 @@ internal class ServerConfigRepositoryImpl(
|
|||||||
serverData = configResponse,
|
serverData = configResponse,
|
||||||
)
|
)
|
||||||
configDiskSource.serverConfig = serverConfig
|
configDiskSource.serverConfig = serverConfig
|
||||||
|
val featureStatesMap = serverConfig.serverData.featureStates
|
||||||
|
|
||||||
|
Log.d("ServerConfigRepository", "Will check for flags")
|
||||||
|
if (featureStatesMap != null) {
|
||||||
|
val specificValue = featureStatesMap["enable-pm-bwa-sync"]
|
||||||
|
if (specificValue != null) {
|
||||||
|
Log.d(
|
||||||
|
"ServerConfigRepository",
|
||||||
|
"Feature 'enable-pm-bwa-sync': $specificValue",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Log.d(
|
||||||
|
"ServerConfigRepository",
|
||||||
|
"Feature 'enable-pm-bwa-sync' not found.",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
return serverConfig
|
return serverConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bitwarden.data.repository
|
package com.bitwarden.data.repository
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.bitwarden.core.data.util.asSuccess
|
import com.bitwarden.core.data.util.asSuccess
|
||||||
import com.bitwarden.data.datasource.disk.base.FakeDispatcherManager
|
import com.bitwarden.data.datasource.disk.base.FakeDispatcherManager
|
||||||
@@ -11,9 +12,13 @@ import com.bitwarden.network.model.ConfigResponseJson.EnvironmentJson
|
|||||||
import com.bitwarden.network.model.ConfigResponseJson.ServerJson
|
import com.bitwarden.network.model.ConfigResponseJson.ServerJson
|
||||||
import com.bitwarden.network.service.ConfigService
|
import com.bitwarden.network.service.ConfigService
|
||||||
import io.mockk.coEvery
|
import io.mockk.coEvery
|
||||||
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
import io.mockk.mockkStatic
|
||||||
|
import io.mockk.unmockkStatic
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import kotlinx.serialization.json.JsonPrimitive
|
import kotlinx.serialization.json.JsonPrimitive
|
||||||
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Assertions.assertNotEquals
|
import org.junit.jupiter.api.Assertions.assertNotEquals
|
||||||
import org.junit.jupiter.api.Assertions.assertNull
|
import org.junit.jupiter.api.Assertions.assertNull
|
||||||
@@ -47,6 +52,15 @@ class ServerConfigRepositoryTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
fakeConfigDiskSource.serverConfig = null
|
fakeConfigDiskSource.serverConfig = null
|
||||||
|
|
||||||
|
mockkStatic(Log::class)
|
||||||
|
every { Log.d(any(), any()) } returns 1
|
||||||
|
every { Log.d(any(), any(), any()) } returns 1
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
fun tearDown() {
|
||||||
|
unmockkStatic(Log::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user