mirror of
https://github.com/bitwarden/android.git
synced 2026-05-10 15:16:52 -05:00
[PM-15149] Remove ssh feature flag (#4761)
This commit is contained in:
@@ -31,7 +31,6 @@ sealed class FlagKey<out T : Any> {
|
||||
OnboardingFlow,
|
||||
OnboardingCarousel,
|
||||
ImportLoginsFlow,
|
||||
SshKeyCipherItems,
|
||||
VerifiedSsoDomainEndpoint,
|
||||
CredentialExchangeProtocolImport,
|
||||
CredentialExchangeProtocolExport,
|
||||
@@ -94,15 +93,6 @@ sealed class FlagKey<out T : Any> {
|
||||
override val isRemotelyConfigured: Boolean = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Data object holding the feature flag key for the SSH key cipher items feature.
|
||||
*/
|
||||
data object SshKeyCipherItems : FlagKey<Boolean>() {
|
||||
override val keyName: String = "ssh-key-vault-item"
|
||||
override val defaultValue: Boolean = false
|
||||
override val isRemotelyConfigured: Boolean = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Data object holding the feature flag key for the new verified SSO domain endpoint feature.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,6 @@ fun <T : Any> FlagKey<T>.ListItemContent(
|
||||
FlagKey.OnboardingCarousel,
|
||||
FlagKey.OnboardingFlow,
|
||||
FlagKey.ImportLoginsFlow,
|
||||
FlagKey.SshKeyCipherItems,
|
||||
FlagKey.VerifiedSsoDomainEndpoint,
|
||||
FlagKey.CredentialExchangeProtocolImport,
|
||||
FlagKey.CredentialExchangeProtocolExport,
|
||||
@@ -87,7 +86,6 @@ private fun <T : Any> FlagKey<T>.getDisplayLabel(): String = when (this) {
|
||||
FlagKey.OnboardingCarousel -> stringResource(R.string.onboarding_carousel)
|
||||
FlagKey.OnboardingFlow -> stringResource(R.string.onboarding_flow)
|
||||
FlagKey.ImportLoginsFlow -> stringResource(R.string.import_logins_flow)
|
||||
FlagKey.SshKeyCipherItems -> stringResource(R.string.ssh_key_cipher_item_types)
|
||||
FlagKey.VerifiedSsoDomainEndpoint -> stringResource(R.string.verified_sso_domain_verified)
|
||||
FlagKey.CredentialExchangeProtocolImport -> stringResource(R.string.cxp_import)
|
||||
FlagKey.CredentialExchangeProtocolExport -> stringResource(R.string.cxp_export)
|
||||
|
||||
@@ -37,7 +37,6 @@ fun VaultContent(
|
||||
state: VaultState.ViewState.Content,
|
||||
vaultHandlers: VaultHandlers,
|
||||
onOverflowOptionClick: (action: ListingItemOverflowAction.VaultAction) -> Unit,
|
||||
showSshKeys: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
LazyColumn(
|
||||
@@ -192,11 +191,7 @@ fun VaultContent(
|
||||
supportingLabel = state.secureNoteItemsCount.toString(),
|
||||
onClick = vaultHandlers.secureNoteGroupClick,
|
||||
showDivider = false,
|
||||
cardStyle = if (showSshKeys) {
|
||||
CardStyle.Middle(dividerPadding = 56.dp)
|
||||
} else {
|
||||
CardStyle.Bottom
|
||||
},
|
||||
cardStyle = CardStyle.Middle(dividerPadding = 56.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("SecureNoteFilter")
|
||||
@@ -204,22 +199,20 @@ fun VaultContent(
|
||||
)
|
||||
}
|
||||
|
||||
if (showSshKeys) {
|
||||
item {
|
||||
BitwardenGroupItem(
|
||||
startIcon = rememberVectorPainter(id = R.drawable.ic_ssh_key),
|
||||
startIconTestTag = "SshKeyCipherIcon",
|
||||
label = stringResource(id = R.string.type_ssh_key),
|
||||
supportingLabel = state.sshKeyItemsCount.toString(),
|
||||
onClick = vaultHandlers.sshKeyGroupClick,
|
||||
showDivider = false,
|
||||
cardStyle = CardStyle.Bottom,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("SshKeyFilter")
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
}
|
||||
item {
|
||||
BitwardenGroupItem(
|
||||
startIcon = rememberVectorPainter(id = R.drawable.ic_ssh_key),
|
||||
startIconTestTag = "SshKeyCipherIcon",
|
||||
label = stringResource(id = R.string.type_ssh_key),
|
||||
supportingLabel = state.sshKeyItemsCount.toString(),
|
||||
onClick = vaultHandlers.sshKeyGroupClick,
|
||||
showDivider = false,
|
||||
cardStyle = CardStyle.Bottom,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("SshKeyFilter")
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
|
||||
@@ -352,7 +352,6 @@ private fun VaultScreenScaffold(
|
||||
when (val viewState = state.viewState) {
|
||||
is VaultState.ViewState.Content -> VaultContent(
|
||||
state = viewState,
|
||||
showSshKeys = state.showSshKeys,
|
||||
vaultHandlers = vaultHandlers,
|
||||
onOverflowOptionClick = { masterPasswordRepromptAction = it },
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
||||
@@ -98,7 +98,6 @@ class VaultViewModel @Inject constructor(
|
||||
.any(),
|
||||
)
|
||||
val appBarTitle = vaultFilterData.toAppBarTitle()
|
||||
val showSshKeys = featureFlagManager.getFeatureFlag(FlagKey.SshKeyCipherItems)
|
||||
VaultState(
|
||||
appBarTitle = appBarTitle,
|
||||
initials = activeAccountSummary.initials,
|
||||
@@ -113,7 +112,6 @@ class VaultViewModel @Inject constructor(
|
||||
hasMasterPassword = userState.activeAccount.hasMasterPassword,
|
||||
isRefreshing = false,
|
||||
showImportActionCard = false,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
},
|
||||
) {
|
||||
@@ -141,15 +139,9 @@ class VaultViewModel @Inject constructor(
|
||||
.onEach(::sendAction)
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
combine(
|
||||
vaultRepository.vaultDataStateFlow,
|
||||
featureFlagManager.getFeatureFlagFlow(FlagKey.SshKeyCipherItems),
|
||||
) { vaultData, sshKeyCipherItemsEnabled ->
|
||||
VaultAction.Internal.VaultDataReceive(
|
||||
vaultData = vaultData,
|
||||
showSshKeys = sshKeyCipherItemsEnabled,
|
||||
)
|
||||
}
|
||||
vaultRepository
|
||||
.vaultDataStateFlow
|
||||
.map { VaultAction.Internal.VaultDataReceive(it) }
|
||||
.onEach(::sendAction)
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
@@ -266,7 +258,6 @@ class VaultViewModel @Inject constructor(
|
||||
|
||||
updateViewState(
|
||||
vaultData = vaultRepository.vaultDataStateFlow.value,
|
||||
showSshKeys = state.showSshKeys,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -405,7 +396,6 @@ class VaultViewModel @Inject constructor(
|
||||
// Re-process the current vault data with the new filter
|
||||
updateViewState(
|
||||
vaultData = vaultRepository.vaultDataStateFlow.value,
|
||||
showSshKeys = state.showSshKeys,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -694,22 +684,19 @@ class VaultViewModel @Inject constructor(
|
||||
|
||||
updateViewState(
|
||||
vaultData = action.vaultData,
|
||||
showSshKeys = action.showSshKeys,
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateViewState(vaultData: DataState<VaultData>, showSshKeys: Boolean) {
|
||||
private fun updateViewState(vaultData: DataState<VaultData>) {
|
||||
when (vaultData) {
|
||||
is DataState.Error -> vaultErrorReceive(vaultData = vaultData)
|
||||
is DataState.Loaded -> vaultLoadedReceive(
|
||||
vaultData = vaultData,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
|
||||
is DataState.Loading -> vaultLoadingReceive()
|
||||
is DataState.NoNetwork -> vaultNoNetworkReceive(
|
||||
vaultData = vaultData,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
|
||||
is DataState.Pending -> vaultPendingReceive(vaultData = vaultData)
|
||||
@@ -730,7 +717,7 @@ class VaultViewModel @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun vaultLoadedReceive(vaultData: DataState.Loaded<VaultData>, showSshKeys: Boolean) {
|
||||
private fun vaultLoadedReceive(vaultData: DataState.Loaded<VaultData>) {
|
||||
if (state.dialog == VaultState.DialogState.Syncing) {
|
||||
sendEvent(
|
||||
VaultEvent.ShowToast(
|
||||
@@ -738,12 +725,11 @@ class VaultViewModel @Inject constructor(
|
||||
),
|
||||
)
|
||||
}
|
||||
updateVaultState(vaultData.data, showSshKeys)
|
||||
updateVaultState(vaultData.data)
|
||||
}
|
||||
|
||||
private fun updateVaultState(
|
||||
vaultData: VaultData,
|
||||
showSshKeys: Boolean,
|
||||
) {
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
@@ -753,11 +739,9 @@ class VaultViewModel @Inject constructor(
|
||||
isPremium = state.isPremium,
|
||||
hasMasterPassword = state.hasMasterPassword,
|
||||
vaultFilterType = vaultFilterTypeOrDefault,
|
||||
showSshKeys = showSshKeys,
|
||||
),
|
||||
dialog = null,
|
||||
isRefreshing = false,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -768,7 +752,6 @@ class VaultViewModel @Inject constructor(
|
||||
|
||||
private fun vaultNoNetworkReceive(
|
||||
vaultData: DataState.NoNetwork<VaultData>,
|
||||
showSshKeys: Boolean,
|
||||
) {
|
||||
val data = vaultData.data ?: VaultData(
|
||||
cipherViewList = emptyList(),
|
||||
@@ -778,7 +761,6 @@ class VaultViewModel @Inject constructor(
|
||||
)
|
||||
updateVaultState(
|
||||
vaultData = data,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -791,7 +773,6 @@ class VaultViewModel @Inject constructor(
|
||||
isPremium = state.isPremium,
|
||||
hasMasterPassword = state.hasMasterPassword,
|
||||
vaultFilterType = vaultFilterTypeOrDefault,
|
||||
showSshKeys = state.showSshKeys,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -862,7 +843,6 @@ data class VaultState(
|
||||
val isIconLoadingDisabled: Boolean,
|
||||
val isRefreshing: Boolean,
|
||||
val showImportActionCard: Boolean,
|
||||
val showSshKeys: Boolean,
|
||||
) : Parcelable {
|
||||
|
||||
/**
|
||||
@@ -1486,7 +1466,6 @@ sealed class VaultAction {
|
||||
*/
|
||||
data class VaultDataReceive(
|
||||
val vaultData: DataState<VaultData>,
|
||||
val showSshKeys: Boolean,
|
||||
) : Internal()
|
||||
|
||||
/**
|
||||
@@ -1527,7 +1506,6 @@ private fun MutableStateFlow<VaultState>.updateToErrorStateOrDialog(
|
||||
hasMasterPassword = hasMasterPassword,
|
||||
vaultFilterType = vaultFilterType,
|
||||
isIconLoadingDisabled = isIconLoadingDisabled,
|
||||
showSshKeys = it.showSshKeys,
|
||||
),
|
||||
dialog = VaultState.DialogState.Error(
|
||||
title = errorTitle,
|
||||
|
||||
@@ -39,7 +39,6 @@ fun VaultData.toViewState(
|
||||
isIconLoadingDisabled: Boolean,
|
||||
baseIconUrl: String,
|
||||
vaultFilterType: VaultFilterType,
|
||||
showSshKeys: Boolean,
|
||||
): VaultState.ViewState {
|
||||
|
||||
val filteredCipherViewListWithDeletedItems =
|
||||
@@ -47,7 +46,6 @@ fun VaultData.toViewState(
|
||||
|
||||
val filteredCipherViewList = filteredCipherViewListWithDeletedItems
|
||||
.filter { it.deletedDate == null }
|
||||
.filterSshKeysIfNecessary(showSshKeys)
|
||||
|
||||
val filteredFolderViewList = folderViewList
|
||||
.toFilteredList(
|
||||
@@ -63,12 +61,7 @@ fun VaultData.toViewState(
|
||||
val noFolderItems = filteredCipherViewList
|
||||
.filter { it.folderId.isNullOrBlank() }
|
||||
|
||||
val itemTypesCount: Int = if (showSshKeys) {
|
||||
CipherType.entries
|
||||
} else {
|
||||
CipherType.entries.filterNot { it == CipherType.SSH_KEY }
|
||||
}
|
||||
.size
|
||||
val itemTypesCount: Int = CipherType.entries.size
|
||||
|
||||
return if (filteredCipherViewListWithDeletedItems.isEmpty()) {
|
||||
VaultState.ViewState.NoItems
|
||||
@@ -355,16 +348,3 @@ fun List<CollectionView>.toFilteredList(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out all [CipherView]s that are of type [CipherType.SSH_KEY] if [showSshKeys] is false.
|
||||
*
|
||||
* @param showSshKeys Whether to show SSH keys in the vault.
|
||||
*/
|
||||
@JvmName("filterSshKeysIfNecessary")
|
||||
fun List<CipherView>.filterSshKeysIfNecessary(showSshKeys: Boolean): List<CipherView> =
|
||||
if (showSshKeys) {
|
||||
this
|
||||
} else {
|
||||
filter { it.type != CipherType.SSH_KEY }
|
||||
}
|
||||
|
||||
@@ -1104,7 +1104,6 @@ Do you want to switch to this account?</string>
|
||||
<string name="save_the_exported_file_somewhere_on_your_computer_you_can_find_easily"><annotation emphasis="bold">Save the exported file</annotation> somewhere on your computer you can find easily.</string>
|
||||
<string name="this_is_not_a_recognized_bitwarden_server_you_may_need_to_check_with_your_provider_or_update_your_server">This is not a recognized Bitwarden server. You may need to check with your provider or update your server.</string>
|
||||
<string name="syncing_logins_loading_message">Syncing logins...</string>
|
||||
<string name="ssh_key_cipher_item_types">SSH Key Cipher Item Types</string>
|
||||
<string name="download_the_browser_extension">Download the browser extension</string>
|
||||
<string name="go_to_bitwarden_com_download_to_integrate_bitwarden_into_browser">Go to bitwarden.com/download to integrate Bitwarden into your favorite browser for a seamless experience.</string>
|
||||
<string name="use_the_web_app">Use the web app</string>
|
||||
|
||||
@@ -29,10 +29,6 @@ class FlagKeyTest {
|
||||
FlagKey.ImportLoginsFlow.keyName,
|
||||
"import-logins-flow",
|
||||
)
|
||||
assertEquals(
|
||||
FlagKey.SshKeyCipherItems.keyName,
|
||||
"ssh-key-vault-item",
|
||||
)
|
||||
assertEquals(
|
||||
FlagKey.VerifiedSsoDomainEndpoint.keyName,
|
||||
"pm-12337-refactor-sso-details-endpoint",
|
||||
@@ -96,7 +92,6 @@ class FlagKeyTest {
|
||||
FlagKey.OnboardingCarousel,
|
||||
FlagKey.OnboardingFlow,
|
||||
FlagKey.ImportLoginsFlow,
|
||||
FlagKey.SshKeyCipherItems,
|
||||
FlagKey.VerifiedSsoDomainEndpoint,
|
||||
FlagKey.CredentialExchangeProtocolImport,
|
||||
FlagKey.CredentialExchangeProtocolExport,
|
||||
@@ -124,7 +119,6 @@ class FlagKeyTest {
|
||||
FlagKey.OnboardingCarousel,
|
||||
FlagKey.OnboardingFlow,
|
||||
FlagKey.ImportLoginsFlow,
|
||||
FlagKey.SshKeyCipherItems,
|
||||
FlagKey.VerifiedSsoDomainEndpoint,
|
||||
FlagKey.CredentialExchangeProtocolImport,
|
||||
FlagKey.CredentialExchangeProtocolExport,
|
||||
|
||||
@@ -123,7 +123,6 @@ private val DEFAULT_MAP_VALUE: Map<FlagKey<Any>, Any> = mapOf(
|
||||
FlagKey.OnboardingCarousel to true,
|
||||
FlagKey.OnboardingFlow to true,
|
||||
FlagKey.ImportLoginsFlow to true,
|
||||
FlagKey.SshKeyCipherItems to true,
|
||||
FlagKey.VerifiedSsoDomainEndpoint to true,
|
||||
FlagKey.CredentialExchangeProtocolImport to true,
|
||||
FlagKey.CredentialExchangeProtocolExport to true,
|
||||
@@ -145,7 +144,6 @@ private val UPDATED_MAP_VALUE: Map<FlagKey<Any>, Any> = mapOf(
|
||||
FlagKey.OnboardingCarousel to true,
|
||||
FlagKey.OnboardingFlow to false,
|
||||
FlagKey.ImportLoginsFlow to false,
|
||||
FlagKey.SshKeyCipherItems to false,
|
||||
FlagKey.VerifiedSsoDomainEndpoint to false,
|
||||
FlagKey.CredentialExchangeProtocolImport to false,
|
||||
FlagKey.CredentialExchangeProtocolExport to false,
|
||||
|
||||
@@ -11,7 +11,6 @@ import androidx.compose.ui.test.hasScrollToNodeAction
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.isDialog
|
||||
import androidx.compose.ui.test.isDisplayed
|
||||
import androidx.compose.ui.test.isNotDisplayed
|
||||
import androidx.compose.ui.test.isPopup
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
@@ -1276,7 +1275,6 @@ class VaultScreenTest : BaseComposeTest() {
|
||||
// Verify SSH key group is displayed when showSshKeys is true
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
showSshKeys = true,
|
||||
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
|
||||
sshKeyItemsCount = count,
|
||||
),
|
||||
@@ -1286,12 +1284,6 @@ class VaultScreenTest : BaseComposeTest() {
|
||||
.onNodeWithText("SSH key")
|
||||
.assertTextEquals("SSH key", count.toString())
|
||||
.assertIsDisplayed()
|
||||
|
||||
// Verify SSH key group is hidden when showSshKeys is false
|
||||
mutableStateFlow.update { it.copy(showSshKeys = false) }
|
||||
composeTestRule
|
||||
.onNodeWithText("SSH key")
|
||||
.assertIsNotDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1299,7 +1291,6 @@ class VaultScreenTest : BaseComposeTest() {
|
||||
// Verify SSH key vault items are displayed when showSshKeys is true
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
showSshKeys = true,
|
||||
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
|
||||
noFolderItems = listOf(
|
||||
VaultState.ViewState.VaultItem.SshKey(
|
||||
@@ -1318,12 +1309,6 @@ class VaultScreenTest : BaseComposeTest() {
|
||||
composeTestRule
|
||||
.onNodeWithTextAfterScroll("mockSshKey")
|
||||
.isDisplayed()
|
||||
|
||||
// Verify SSH key vault items are hidden when showSshKeys is false
|
||||
mutableStateFlow.update { it.copy(showSshKeys = false) }
|
||||
composeTestRule
|
||||
.onNodeWithText("mockSshKey")
|
||||
.isNotDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1440,7 +1425,6 @@ private val DEFAULT_STATE: VaultState = VaultState(
|
||||
hasMasterPassword = true,
|
||||
isRefreshing = false,
|
||||
showImportActionCard = false,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
private val DEFAULT_CONTENT_VIEW_STATE: VaultState.ViewState.Content = VaultState.ViewState.Content(
|
||||
|
||||
@@ -145,12 +145,6 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
every {
|
||||
getFeatureFlagFlow(FlagKey.ImportLoginsFlow)
|
||||
} returns mutableImportLoginsFeatureFlow
|
||||
every {
|
||||
getFeatureFlagFlow(FlagKey.SshKeyCipherItems)
|
||||
} returns mutableSshKeyVaultItemsEnabledFlow
|
||||
every {
|
||||
getFeatureFlag(FlagKey.SshKeyCipherItems)
|
||||
} returns mutableSshKeyVaultItemsEnabledFlow.value
|
||||
}
|
||||
private val reviewPromptManager: ReviewPromptManager = mockk()
|
||||
|
||||
@@ -582,7 +576,6 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
isIconLoadingDisabled = viewModel.stateFlow.value.isIconLoadingDisabled,
|
||||
baseIconUrl = viewModel.stateFlow.value.baseIconUrl,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
),
|
||||
)
|
||||
.copy(
|
||||
@@ -607,7 +600,6 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
isIconLoadingDisabled = viewModel.stateFlow.value.isIconLoadingDisabled,
|
||||
baseIconUrl = viewModel.stateFlow.value.baseIconUrl,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
),
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
@@ -717,7 +709,6 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
itemTypesCount = CipherType.entries.size,
|
||||
sshKeyItemsCount = 1,
|
||||
),
|
||||
showSshKeys = true,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
@@ -739,7 +730,7 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
)
|
||||
@@ -853,7 +844,7 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
),
|
||||
@@ -953,7 +944,7 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
dialog = VaultState.DialogState.Error(
|
||||
@@ -1051,7 +1042,7 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
dialog = null,
|
||||
@@ -1096,47 +1087,7 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `vaultDataStateFlow Loaded should exclude SSH key vault items when showSshKeys is false`() =
|
||||
runTest {
|
||||
mutableVaultDataStateFlow.tryEmit(
|
||||
value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
cipherViewList = listOf(
|
||||
createMockCipherView(number = 1),
|
||||
createMockCipherView(number = 1, cipherType = CipherType.SSH_KEY),
|
||||
),
|
||||
collectionViewList = listOf(),
|
||||
folderViewList = listOf(),
|
||||
sendViewList = listOf(),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
val viewModel = createViewModel()
|
||||
|
||||
assertEquals(
|
||||
createMockVaultState(
|
||||
viewState = VaultState.ViewState.Content(
|
||||
loginItemsCount = 1,
|
||||
cardItemsCount = 0,
|
||||
identityItemsCount = 0,
|
||||
secureNoteItemsCount = 0,
|
||||
favoriteItems = listOf(),
|
||||
folderItems = listOf(),
|
||||
collectionItems = listOf(),
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = CipherType.entries.size - 1,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `vaultDataStateFlow Loaded should include SSH key vault items when showSshKeys is true`() =
|
||||
fun `vaultDataStateFlow Loaded should include SSH key vault items`() =
|
||||
runTest {
|
||||
mutableSshKeyVaultItemsEnabledFlow.value = true
|
||||
mutableVaultDataStateFlow.tryEmit(
|
||||
@@ -1171,7 +1122,6 @@ class VaultViewModelTest : BaseViewModelTest() {
|
||||
itemTypesCount = CipherType.entries.size,
|
||||
sshKeyItemsCount = 1,
|
||||
),
|
||||
showSshKeys = true,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
@@ -2099,7 +2049,6 @@ private val DEFAULT_USER_STATE = UserState(
|
||||
private fun createMockVaultState(
|
||||
viewState: VaultState.ViewState,
|
||||
dialog: VaultState.DialogState? = null,
|
||||
showSshKeys: Boolean = false,
|
||||
): VaultState =
|
||||
VaultState(
|
||||
appBarTitle = R.string.my_vault.asText(),
|
||||
@@ -2137,5 +2086,4 @@ private fun createMockVaultState(
|
||||
hasMasterPassword = true,
|
||||
showImportActionCard = true,
|
||||
isRefreshing = false,
|
||||
showSshKeys = showSshKeys,
|
||||
)
|
||||
|
||||
@@ -61,7 +61,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -99,7 +98,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -125,7 +124,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.MyVault,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -146,7 +144,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -181,7 +179,6 @@ class VaultDataExtensionsTest {
|
||||
organizationName = "Mock Organization 1",
|
||||
),
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -208,7 +205,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -230,7 +227,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -254,7 +250,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -279,7 +274,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -294,7 +288,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -317,7 +311,6 @@ class VaultDataExtensionsTest {
|
||||
isIconLoadingDisabled = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -332,7 +325,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 0,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -355,7 +348,6 @@ class VaultDataExtensionsTest {
|
||||
isIconLoadingDisabled = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -370,7 +362,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -395,7 +387,6 @@ class VaultDataExtensionsTest {
|
||||
isIconLoadingDisabled = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -410,7 +401,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -619,7 +610,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -634,7 +624,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 2,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -659,7 +649,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -674,7 +663,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 2,
|
||||
totpItemsCount = 0,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -702,7 +691,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -723,7 +711,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 100,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -758,7 +746,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -801,7 +788,7 @@ class VaultDataExtensionsTest {
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
itemTypesCount = 4,
|
||||
itemTypesCount = 5,
|
||||
sshKeyItemsCount = 0,
|
||||
),
|
||||
actual,
|
||||
@@ -809,7 +796,7 @@ class VaultDataExtensionsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toViewState should exclude SSH keys if showSshKeys is false`() {
|
||||
fun `toViewState should include SSH key vault items and type count`() {
|
||||
val vaultData = VaultData(
|
||||
cipherViewList = listOf(
|
||||
createMockCipherView(number = 1),
|
||||
@@ -827,50 +814,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = false,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
VaultState.ViewState.Content(
|
||||
loginItemsCount = 1,
|
||||
cardItemsCount = 0,
|
||||
identityItemsCount = 0,
|
||||
secureNoteItemsCount = 0,
|
||||
// Verify SSH key vault items are not counted when showSshKeys is false.
|
||||
sshKeyItemsCount = 0,
|
||||
favoriteItems = listOf(),
|
||||
collectionItems = listOf(),
|
||||
folderItems = listOf(),
|
||||
noFolderItems = listOf(),
|
||||
trashItemsCount = 0,
|
||||
totpItemsCount = 1,
|
||||
// Verify item types count excludes CipherType.SSH_KEY when showSshKeys is false.
|
||||
itemTypesCount = 4,
|
||||
),
|
||||
actual,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toViewState should include SSH key vault items and type count if showSshKeys is true`() {
|
||||
val vaultData = VaultData(
|
||||
cipherViewList = listOf(
|
||||
createMockCipherView(number = 1),
|
||||
createMockCipherView(number = 2, cipherType = CipherType.SSH_KEY),
|
||||
),
|
||||
collectionViewList = listOf(),
|
||||
folderViewList = listOf(),
|
||||
sendViewList = listOf(),
|
||||
fido2CredentialAutofillViewList = null,
|
||||
)
|
||||
|
||||
val actual = vaultData.toViewState(
|
||||
isPremium = true,
|
||||
isIconLoadingDisabled = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = true,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
@@ -928,7 +871,6 @@ class VaultDataExtensionsTest {
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = true,
|
||||
showSshKeys = true,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
|
||||
Reference in New Issue
Block a user