Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class FeatureFlagManagerImpl(

override val sdkFeatureFlags: Map<String, Boolean>
get() = mapOf(
CIPHER_KEY_ENCRYPTION_KEY to
getCipherKeyEncryptionFlagState(),
CIPHER_KEY_ENCRYPTION_KEY to serverConfigRepository.isCipherKeyEncryptionEnabled,
)

override fun <T : Any> getFeatureFlagFlow(key: FlagKey<T>): Flow<T> =
Expand All @@ -43,18 +42,14 @@ class FeatureFlagManagerImpl(
.serverConfigStateFlow
.value
.getFlagValueOrDefault(key = key)

/**
* Get the computed value of the cipher key encryption flag based on server version and
* remote flag.
*/
private fun getCipherKeyEncryptionFlagState() =
isServerVersionAtLeast(
serverConfigRepository.serverConfigStateFlow.value,
CIPHER_KEY_ENC_MIN_SERVER_VERSION,
) && getFeatureFlag(FlagKey.CipherKeyEncryption)
}

/**
* Get the computed value of the cipher key encryption flag based on server version.
*/
private val ServerConfigRepository.isCipherKeyEncryptionEnabled: Boolean
get() = isServerVersionAtLeast(serverConfigStateFlow.value, CIPHER_KEY_ENC_MIN_SERVER_VERSION)

/**
* Extract the value of a [FlagKey] from the [ServerConfig]. If there is an issue with retrieving
* or if the value is null, the default value will be returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FeatureFlagManagerTest {

@Test
fun `sdkFeatureFlags should return set feature flags`() {
val expected = mapOf("enableCipherKeyEncryption" to false)
val expected = mapOf("enableCipherKeyEncryption" to true)

val actual = manager.sdkFeatureFlags

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ class DebugMenuViewModelTest : BaseViewModelTest() {
@Test
fun `handleUpdateFeatureFlag should update the feature flag via the repository`() {
val viewModel = createViewModel()
viewModel.trySendAction(
DebugMenuAction.UpdateFeatureFlag(FlagKey.CipherKeyEncryption, false),
)
viewModel.trySendAction(DebugMenuAction.UpdateFeatureFlag(FlagKey.DummyBoolean, false))
verify(exactly = 1) {
mockDebugMenuRepository.updateFeatureFlag(FlagKey.CipherKeyEncryption, false)
mockDebugMenuRepository.updateFeatureFlag(FlagKey.DummyBoolean, false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ sealed class FlagKey<out T : Any> {
CredentialExchangeProtocolImport,
CredentialExchangeProtocolExport,
ForceUpdateKdfSettings,
CipherKeyEncryption,
NoLogoutOnKdfChange,
MigrateMyVaultToMyItems,
ArchiveItems,
Expand All @@ -60,14 +59,6 @@ sealed class FlagKey<out T : Any> {
override val defaultValue: Boolean = false
}

/**
* Data object holding the feature flag key for the Cipher Key Encryption feature.
*/
data object CipherKeyEncryption : FlagKey<Boolean>() {
override val keyName: String = "cipher-key-encryption"
override val defaultValue: Boolean = false
}

/**
* Indicates the state of Bitwarden authentication.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ class FlagKeyTest {
FlagKey.CredentialExchangeProtocolExport.keyName,
"cxp-export-mobile",
)
assertEquals(
FlagKey.CipherKeyEncryption.keyName,
"cipher-key-encryption",
)
assertEquals(
FlagKey.BitwardenAuthenticationEnabled.keyName,
"bitwarden-authentication-enabled",
Expand Down Expand Up @@ -48,7 +44,6 @@ class FlagKeyTest {
listOf(
FlagKey.CredentialExchangeProtocolImport,
FlagKey.CredentialExchangeProtocolExport,
FlagKey.CipherKeyEncryption,
FlagKey.BitwardenAuthenticationEnabled,
FlagKey.ForceUpdateKdfSettings,
FlagKey.MigrateMyVaultToMyItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fun <T : Any> FlagKey<T>.ListItemContent(
FlagKey.BitwardenAuthenticationEnabled,
FlagKey.CredentialExchangeProtocolImport,
FlagKey.CredentialExchangeProtocolExport,
FlagKey.CipherKeyEncryption,
FlagKey.ForceUpdateKdfSettings,
FlagKey.NoLogoutOnKdfChange,
FlagKey.MigrateMyVaultToMyItems,
Expand Down Expand Up @@ -75,7 +74,6 @@ private fun <T : Any> FlagKey<T>.getDisplayLabel(): String = when (this) {

FlagKey.CredentialExchangeProtocolImport -> stringResource(BitwardenString.cxp_import)
FlagKey.CredentialExchangeProtocolExport -> stringResource(BitwardenString.cxp_export)
FlagKey.CipherKeyEncryption -> stringResource(BitwardenString.cipher_key_encryption)
FlagKey.ForceUpdateKdfSettings -> stringResource(BitwardenString.force_update_kdf_settings)
FlagKey.NoLogoutOnKdfChange -> stringResource(BitwardenString.avoid_logout_on_kdf_change)
FlagKey.BitwardenAuthenticationEnabled -> {
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values/strings_non_localized.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<string name="restart_onboarding_details">This will reset the onboarding status for the current user, if available. After clicking the button you will immediately be redirected to the onboarding flow. Onboarding flag must be enabled.</string>
<string name="restart_onboarding_carousel">Show Onboarding Carousel</string>
<string name="restart_onboarding_carousel_details">This will force the change to app state which will cause the first time carousel to show. The carousel will continue to show for any \"new\" account until a login is completed. May need to exit debug menu manually.</string>
<string name="cipher_key_encryption">Cipher Key Encryption</string>
<string name="reset_coach_mark_tour_status">Reset all coach mark tours</string>
<string name="generate_crash">Generate crash</string>
<string name="generate_error_report">Generate error report</string>
Expand Down
Loading