1
0
Fork 0
mirror of https://github.com/bitwarden/android.git synced 2025-01-30 19:53:47 +03:00

Reverts PM-14995 ()

This commit is contained in:
Dave Severns 2025-01-27 17:33:04 -05:00 committed by GitHub
parent d96494ebb7
commit 511954c9b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 56 additions and 320 deletions

View file

@ -18,5 +18,4 @@ data class Organization(
val shouldManageResetPassword: Boolean,
val shouldUseKeyConnector: Boolean,
val role: OrganizationType,
val shouldUsersGetPremium: Boolean,
)

View file

@ -22,7 +22,6 @@ fun SyncResponseJson.Profile.Organization.toOrganization(): Organization =
shouldUseKeyConnector = this.shouldUseKeyConnector,
role = this.type,
shouldManageResetPassword = this.permissions.shouldManageResetPassword,
shouldUsersGetPremium = this.shouldUsersGetPremium,
)
/**

View file

@ -9,7 +9,6 @@ import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardMan
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
import com.x8bit.bitwarden.data.vault.repository.model.GenerateTotpResult
import com.x8bit.bitwarden.ui.vault.feature.vault.util.getOrganizationPremiumStatusMap
import java.time.Clock
/**
@ -25,15 +24,8 @@ class AutofillTotpManagerImpl(
) : AutofillTotpManager {
override suspend fun tryCopyTotpToClipboard(cipherView: CipherView) {
if (settingsRepository.isAutoCopyTotpDisabled) return
val organizationPremiumStatusMap = authRepository
.userStateFlow
.value
?.activeAccount
?.getOrganizationPremiumStatusMap()
.orEmpty()
val isPremium = authRepository.userStateFlow.value?.activeAccount?.isPremium == true
val premiumStatus = organizationPremiumStatusMap[cipherView.organizationId] ?: isPremium
if (!premiumStatus && !cipherView.organizationUseTotp) return
if (!isPremium && !cipherView.organizationUseTotp) return
val totpCode = cipherView.login?.totp ?: return
val totpResult = vaultRepository.generateTotp(

View file

@ -122,7 +122,6 @@ class TotpCodeManagerImpl(
CipherRepromptType.NONE -> false
},
orgUsesTotp = cipher.organizationUseTotp,
orgId = cipher.organizationId,
)
}
.onFailure {

View file

@ -29,5 +29,4 @@ data class VerificationCodeItem(
val username: String?,
val hasPasswordReprompt: Boolean,
val orgUsesTotp: Boolean,
val orgId: String?,
)

View file

@ -46,7 +46,6 @@ import com.x8bit.bitwarden.ui.platform.feature.search.util.updateWithAdditionalD
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
import com.x8bit.bitwarden.ui.vault.feature.vault.util.getOrganizationPremiumStatusMap
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toFilteredList
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toVaultFilterData
import com.x8bit.bitwarden.ui.vault.model.TotpData
@ -108,9 +107,6 @@ class SearchViewModel @Inject constructor(
totpData = specialCircumstance?.toTotpDataOrNull(),
hasMasterPassword = userState.activeAccount.hasMasterPassword,
isPremium = userState.activeAccount.isPremium,
organizationPremiumStatusMap = userState
.activeAccount
.getOrganizationPremiumStatusMap(),
)
},
) {
@ -691,7 +687,6 @@ class SearchViewModel @Inject constructor(
isAutofill = state.isAutofill,
isTotp = state.isTotp,
isPremiumUser = state.isPremium,
organizationPremiumStatusMap = state.organizationPremiumStatusMap,
)
}
@ -738,7 +733,6 @@ data class SearchState(
val totpData: TotpData?,
val hasMasterPassword: Boolean,
val isPremium: Boolean,
val organizationPremiumStatusMap: Map<String, Boolean>,
) : Parcelable {
/**

View file

@ -153,7 +153,6 @@ fun List<CipherView>.toViewState(
isAutofill: Boolean,
isTotp: Boolean,
isPremiumUser: Boolean,
organizationPremiumStatusMap: Map<String, Boolean>,
): SearchState.ViewState =
when {
searchTerm.isEmpty() -> SearchState.ViewState.Empty(message = null)
@ -166,7 +165,6 @@ fun List<CipherView>.toViewState(
isAutofill = isAutofill,
isTotp = isTotp,
isPremiumUser = isPremiumUser,
organizationPremiumStatusMap = organizationPremiumStatusMap,
)
.sortAlphabetically(),
)
@ -187,17 +185,15 @@ private fun List<CipherView>.toDisplayItemList(
isAutofill: Boolean,
isTotp: Boolean,
isPremiumUser: Boolean,
organizationPremiumStatusMap: Map<String, Boolean>,
): List<SearchState.DisplayItem> =
this.map {
val premiumStatus = organizationPremiumStatusMap[it.organizationId] ?: isPremiumUser
it.toDisplayItem(
baseIconUrl = baseIconUrl,
hasMasterPassword = hasMasterPassword,
isIconLoadingDisabled = isIconLoadingDisabled,
isAutofill = isAutofill,
isTotp = isTotp,
isPremiumUser = premiumStatus,
isPremiumUser = isPremiumUser,
)
}

View file

@ -8,7 +8,6 @@ import com.bitwarden.vault.CipherView
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
import com.x8bit.bitwarden.data.auth.repository.model.BreachCountResult
import com.x8bit.bitwarden.data.auth.repository.model.Organization
import com.x8bit.bitwarden.data.auth.repository.model.UserState
import com.x8bit.bitwarden.data.auth.repository.model.ValidatePasswordResult
import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardManager
@ -1059,20 +1058,16 @@ class VaultItemViewModel @Inject constructor(
): VaultItemState.ViewState = this
.data
?.cipher
?.let { cipher ->
val ownerOrg: Organization? = account.organizations.find {
cipher.organizationId == it.id
}
cipher.toViewState(
previousState = state.viewState.asContentOrNull(),
isPremiumUser = ownerOrg?.shouldUsersGetPremium ?: account.isPremium,
hasMasterPassword = account.hasMasterPassword,
totpCodeItemData = this.data?.totpCodeItemData,
canDelete = this.data?.canDelete == true,
canAssignToCollections = this.data?.canAssociateToCollections == true,
canEdit = this.data?.canEdit == true,
)
}
?.toViewState(
previousState = state.viewState.asContentOrNull(),
isPremiumUser = account.isPremium,
hasMasterPassword = account.hasMasterPassword,
totpCodeItemData = this.data?.totpCodeItemData,
canDelete = this.data?.canDelete == true,
canAssignToCollections = this.data?.canAssociateToCollections == true,
canEdit = this.data?.canEdit == true,
)
?: VaultItemState.ViewState.Error(message = errorText)
private fun handleValidatePasswordReceive(

View file

@ -71,7 +71,6 @@ import com.x8bit.bitwarden.ui.vault.feature.itemlisting.util.toVaultItemCipherTy
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.util.toViewState
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.util.updateWithAdditionalDataIfNecessary
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
import com.x8bit.bitwarden.ui.vault.feature.vault.util.getOrganizationPremiumStatusMap
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toAccountSummaries
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toActiveAccountSummary
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toFilteredList
@ -106,8 +105,8 @@ class VaultItemListingViewModel @Inject constructor(
private val cipherMatchingManager: CipherMatchingManager,
private val specialCircumstanceManager: SpecialCircumstanceManager,
private val policyManager: PolicyManager,
private val fido2CredentialManager: Fido2CredentialManager,
private val fido2OriginManager: Fido2OriginManager,
private val fido2CredentialManager: Fido2CredentialManager,
private val organizationEventManager: OrganizationEventManager,
) : BaseViewModel<VaultItemListingState, VaultItemListingEvent, VaultItemListingsAction>(
initialState = run {
@ -141,9 +140,6 @@ class VaultItemListingViewModel @Inject constructor(
fido2GetCredentialsRequest = specialCircumstance?.toFido2GetCredentialsRequestOrNull(),
isPremium = userState.activeAccount.isPremium,
isRefreshing = false,
organizationPremiumStatusMap = userState
.activeAccount
.getOrganizationPremiumStatusMap(),
)
},
) {
@ -1586,7 +1582,6 @@ class VaultItemListingViewModel @Inject constructor(
.fido2CredentialAutofillViewList,
totpData = state.totpData,
isPremiumUser = state.isPremium,
organizationPremiumStatusMap = state.organizationPremiumStatusMap,
)
}
@ -1752,7 +1747,6 @@ data class VaultItemListingState(
val hasMasterPassword: Boolean,
val isPremium: Boolean,
val isRefreshing: Boolean,
val organizationPremiumStatusMap: Map<String, Boolean>,
) {
/**
* Whether or not the add FAB should be shown.

View file

@ -111,7 +111,6 @@ fun VaultData.toViewState(
fido2CredentialAutofillViews: List<Fido2CredentialAutofillView>?,
totpData: TotpData?,
isPremiumUser: Boolean,
organizationPremiumStatusMap: Map<String, Boolean>,
): VaultItemListingState.ViewState {
val filteredCipherViewList = cipherViewList
.filter { cipherView ->
@ -143,7 +142,6 @@ fun VaultData.toViewState(
fido2CredentialAutofillViews = fido2CredentialAutofillViews,
isPremiumUser = isPremiumUser,
isTotp = totpData != null,
organizationPremiumStatusMap = organizationPremiumStatusMap,
),
displayFolderList = folderList.map { folderView ->
VaultItemListingState.FolderDisplayItem(
@ -292,10 +290,8 @@ private fun List<CipherView>.toDisplayItemList(
fido2CredentialAutofillViews: List<Fido2CredentialAutofillView>?,
isPremiumUser: Boolean,
isTotp: Boolean,
organizationPremiumStatusMap: Map<String, Boolean>,
): List<VaultItemListingState.DisplayItem> =
this.map {
val premiumStatus = organizationPremiumStatusMap[it.organizationId] ?: isPremiumUser
it.toDisplayItem(
baseIconUrl = baseIconUrl,
hasMasterPassword = hasMasterPassword,
@ -306,7 +302,7 @@ private fun List<CipherView>.toDisplayItemList(
?.firstOrNull { fido2CredentialAutofillView ->
fido2CredentialAutofillView.cipherId == it.id
},
isPremiumUser = premiumStatus,
isPremiumUser = isPremiumUser,
isTotp = isTotp,
)
}

View file

@ -38,7 +38,6 @@ import com.x8bit.bitwarden.ui.platform.manager.snackbar.SnackbarRelayManager
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
import com.x8bit.bitwarden.ui.vault.feature.vault.util.getOrganizationPremiumStatusMap
import com.x8bit.bitwarden.ui.vault.feature.vault.util.initials
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toAccountSummaries
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toActiveAccountSummary
@ -105,9 +104,6 @@ class VaultViewModel @Inject constructor(
isRefreshing = false,
showImportActionCard = false,
showSshKeys = showSshKeys,
organizationPremiumStatusMap = userState
.activeAccount
.getOrganizationPremiumStatusMap(),
)
},
) {
@ -634,7 +630,6 @@ class VaultViewModel @Inject constructor(
hasMasterPassword = state.hasMasterPassword,
vaultFilterType = vaultFilterTypeOrDefault,
showSshKeys = showSshKeys,
organizationPremiumStatusMap = state.organizationPremiumStatusMap,
),
dialog = null,
isRefreshing = false,
@ -673,7 +668,6 @@ class VaultViewModel @Inject constructor(
hasMasterPassword = state.hasMasterPassword,
vaultFilterType = vaultFilterTypeOrDefault,
showSshKeys = state.showSshKeys,
organizationPremiumStatusMap = state.organizationPremiumStatusMap,
),
)
}
@ -745,7 +739,6 @@ data class VaultState(
val isRefreshing: Boolean,
val showImportActionCard: Boolean,
val showSshKeys: Boolean,
val organizationPremiumStatusMap: Map<String, Boolean>,
) : Parcelable {
/**
@ -1375,7 +1368,6 @@ private fun MutableStateFlow<VaultState>.updateToErrorStateOrDialog(
vaultFilterType = vaultFilterType,
isIconLoadingDisabled = isIconLoadingDisabled,
showSshKeys = it.showSshKeys,
organizationPremiumStatusMap = it.organizationPremiumStatusMap,
),
dialog = VaultState.DialogState.Error(
title = errorTitle,

View file

@ -71,11 +71,3 @@ fun UserState.Account.toVaultFilterData(
),
)
}
/**
* Returns a map of organization IDs and if they provide a premium status to the user for
* items owned by that organization.
*/
fun UserState.Account.getOrganizationPremiumStatusMap(): Map<String, Boolean> {
return organizations.associate { it.id to it.shouldUsersGetPremium }
}

View file

@ -40,7 +40,6 @@ fun VaultData.toViewState(
baseIconUrl: String,
vaultFilterType: VaultFilterType,
showSshKeys: Boolean,
organizationPremiumStatusMap: Map<String, Boolean>,
): VaultState.ViewState {
val filteredCipherViewListWithDeletedItems =
@ -74,22 +73,14 @@ fun VaultData.toViewState(
return if (filteredCipherViewListWithDeletedItems.isEmpty()) {
VaultState.ViewState.NoItems
} else {
val totpItemsGroupedByOwnership = filteredCipherViewList.groupBy {
!it.organizationId.isNullOrBlank()
}
val userOwnedTotpItems = totpItemsGroupedByOwnership[false]
?.filter {
it.login?.totp != null && isPremium
}.orEmpty()
val organizationOwnedTotpItems = totpItemsGroupedByOwnership[true]
?.filter {
it.login?.totp != null &&
(organizationPremiumStatusMap[it.id] == true || it.organizationUseTotp)
}.orEmpty()
val totpItems = filteredCipherViewList.filter { it.login?.totp != null }
VaultState.ViewState.Content(
itemTypesCount = itemTypesCount,
totpItemsCount = userOwnedTotpItems.count() +
organizationOwnedTotpItems.count(),
totpItemsCount = if (isPremium) {
totpItems.count()
} else {
totpItems.count { it.organizationUseTotp }
},
loginItemsCount = filteredCipherViewList.count { it.type == CipherType.LOGIN },
cardItemsCount = filteredCipherViewList.count { it.type == CipherType.CARD },
identityItemsCount = filteredCipherViewList.count { it.type == CipherType.IDENTITY },
@ -103,8 +94,7 @@ fun VaultData.toViewState(
hasMasterPassword = hasMasterPassword,
isIconLoadingDisabled = isIconLoadingDisabled,
baseIconUrl = baseIconUrl,
isPremiumUser = organizationPremiumStatusMap[it.organizationId]
?: isPremium,
isPremiumUser = isPremium,
)
},
folderItems = filteredFolderViewList
@ -138,8 +128,7 @@ fun VaultData.toViewState(
hasMasterPassword = hasMasterPassword,
isIconLoadingDisabled = isIconLoadingDisabled,
baseIconUrl = baseIconUrl,
isPremiumUser = organizationPremiumStatusMap[it.organizationId]
?: isPremium,
isPremiumUser = isPremium,
)
}
.takeIf { it.size < NO_FOLDER_ITEM_THRESHOLD }

View file

@ -18,7 +18,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.concat
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
import com.x8bit.bitwarden.ui.vault.feature.vault.util.getOrganizationPremiumStatusMap
import com.x8bit.bitwarden.ui.vault.feature.vault.util.toLoginIconData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.combine
@ -320,11 +319,8 @@ class VerificationCodeViewModel @Inject constructor(
authCodes: List<VerificationCodeItem>,
userAccount: UserState.Account?,
): DataState<List<VerificationCodeItem>> {
val orgPremiumStatusMap = userAccount?.getOrganizationPremiumStatusMap().orEmpty()
val filteredAuthCodes = authCodes.mapNotNull { authCode ->
val premiumStatus =
(authCode.orgId?.let { orgPremiumStatusMap[it] } ?: userAccount?.isPremium) == true
if (premiumStatus) {
if (userAccount?.isPremium == true) {
authCode
} else {
authCode.takeIf { it.orgUsesTotp }

View file

@ -4424,7 +4424,6 @@ class AuthRepositoryTest {
every { shouldUseKeyConnector } returns true
every { type } returns OrganizationType.USER
every { keyConnectorUrl } returns null
every { shouldUsersGetPremium } returns false
},
)
fakeAuthDiskSource.storeOrganizations(userId = USER_ID_1, organizations = organizations)
@ -4450,7 +4449,6 @@ class AuthRepositoryTest {
every { shouldUseKeyConnector } returns true
every { type } returns OrganizationType.USER
every { keyConnectorUrl } returns url
every { shouldUsersGetPremium } returns false
},
)
fakeAuthDiskSource.storeOrganizations(userId = USER_ID_1, organizations = organizations)
@ -4487,7 +4485,6 @@ class AuthRepositoryTest {
every { shouldUseKeyConnector } returns true
every { type } returns OrganizationType.USER
every { keyConnectorUrl } returns url
every { shouldUsersGetPremium } returns false
},
)
fakeAuthDiskSource.storeOrganizations(userId = USER_ID_1, organizations = organizations)

View file

@ -194,7 +194,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -207,7 +206,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -220,7 +218,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -368,7 +365,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -400,7 +396,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -413,7 +408,6 @@ class AuthDiskSourceExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),

View file

@ -23,7 +23,6 @@ class SyncResponseJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
createMockOrganization(number = 1).toOrganization(),
)
@ -39,7 +38,6 @@ class SyncResponseJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = true,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "mockId-2",
@ -47,7 +45,6 @@ class SyncResponseJsonExtensionsTest {
shouldManageResetPassword = true,
shouldUseKeyConnector = false,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
listOf(

View file

@ -366,7 +366,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -431,7 +430,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -476,7 +474,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = true,
@ -537,7 +534,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -583,7 +579,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -652,7 +647,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -698,7 +692,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -767,7 +760,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -813,7 +805,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -882,7 +873,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),
@ -929,7 +919,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = true,
shouldUseKeyConnector = false,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -1001,7 +990,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = true,
shouldUseKeyConnector = false,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
),
@ -1206,7 +1194,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -1277,7 +1264,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
),
@ -1323,7 +1309,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = false,
@ -1394,7 +1379,6 @@ class UserStateJsonExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
),

View file

@ -6,7 +6,6 @@ import com.bitwarden.vault.CipherView
import com.bitwarden.vault.LoginView
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
import com.x8bit.bitwarden.data.auth.repository.model.Organization
import com.x8bit.bitwarden.data.auth.repository.model.UserState
import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardManager
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
@ -95,10 +94,8 @@ class AutofillTotpManagerTest {
runTest {
every { settingsRepository.isAutoCopyTotpDisabled } returns false
every { cipherView.organizationUseTotp } returns false
every { cipherView.organizationId } returns null
mutableUserStateFlow.value = mockk {
every { activeAccount.isPremium } returns false
every { activeAccount.organizations } returns emptyList()
}
autofillTotpManager.tryCopyTotpToClipboard(cipherView = cipherView)
@ -118,10 +115,8 @@ class AutofillTotpManagerTest {
runTest {
every { settingsRepository.isAutoCopyTotpDisabled } returns false
every { cipherView.organizationUseTotp } returns true
every { cipherView.organizationId } returns null
mutableUserStateFlow.value = mockk {
every { activeAccount.isPremium } returns true
every { activeAccount.organizations } returns emptyList()
}
every { loginView.totp } returns null
@ -146,10 +141,8 @@ class AutofillTotpManagerTest {
)
every { settingsRepository.isAutoCopyTotpDisabled } returns false
every { cipherView.organizationUseTotp } returns true
every { cipherView.organizationId } returns null
mutableUserStateFlow.value = mockk {
every { activeAccount.isPremium } returns true
every { activeAccount.organizations } returns emptyList()
}
every { loginView.totp } returns TOTP_CODE
coEvery {
@ -167,34 +160,6 @@ class AutofillTotpManagerTest {
vaultRepository.generateTotp(time = FIXED_CLOCK.instant(), totpCode = TOTP_CODE)
}
}
@Suppress("MaxLineLength")
@Test
fun `tryCopyTotpToClipboard when isAutoCopyTotpDisabled is false, user has premium but item belongs to an org that doesn't should do nothing`() =
runTest {
val orgId = "orgId"
val mockOrganization = mockk<Organization>(relaxed = true) {
every { id } returns orgId
every { shouldUsersGetPremium } returns false
}
every { settingsRepository.isAutoCopyTotpDisabled } returns false
every { cipherView.organizationUseTotp } returns false
every { cipherView.organizationId } returns orgId
mutableUserStateFlow.value = mockk {
every { activeAccount.isPremium } returns true
every { activeAccount.organizations } returns listOf(mockOrganization)
}
autofillTotpManager.tryCopyTotpToClipboard(cipherView = cipherView)
verify(exactly = 0) {
clipboardManager.setText(text = TOTP_RESULT_VALUE)
toast.show()
}
coVerify(exactly = 0) {
vaultRepository.generateTotp(time = FIXED_CLOCK.instant(), totpCode = TOTP_CODE)
}
}
}
private val FIXED_CLOCK: Clock = Clock.fixed(

View file

@ -49,12 +49,10 @@ fun createMockCipherView(
clock: Clock = FIXED_CLOCK,
fido2Credentials: List<Fido2Credential>? = null,
sshKey: SshKeyView? = createMockSshKeyView(number = number),
organizationUsesTotp: Boolean = false,
organizationId: String? = "mockOrganizationId-$number",
): CipherView =
CipherView(
id = "mockId-$number",
organizationId = organizationId,
organizationId = "mockOrganizationId-$number",
folderId = folderId,
collectionIds = listOf("mockId-$number"),
key = "mockKey-$number",
@ -87,7 +85,7 @@ fun createMockCipherView(
reprompt = repromptType,
secureNote = createMockSecureNoteView().takeIf { cipherType == CipherType.SECURE_NOTE },
edit = true,
organizationUseTotp = organizationUsesTotp,
organizationUseTotp = false,
viewPassword = true,
localData = null,
)

View file

@ -48,7 +48,7 @@ class TotpCodeManagerTest {
vaultSdkSource.generateTotp(any(), any(), any())
} returns totpResponse.asSuccess()
val expected = createVerificationCodeItem().copy(orgId = "mockOrganizationId-1")
val expected = createVerificationCodeItem()
totpCodeManager.getTotpCodesStateFlow(userId, cipherList).test {
assertEquals(DataState.Loaded(listOf(expected)), awaitItem())
@ -106,10 +106,7 @@ class TotpCodeManagerTest {
repromptType = CipherRepromptType.PASSWORD,
)
val expected = createVerificationCodeItem().copy(
hasPasswordReprompt = true,
orgId = cipherView.organizationId,
)
val expected = createVerificationCodeItem().copy(hasPasswordReprompt = true)
totpCodeManager.getTotpCodeStateFlow(userId, cipherView).test {
assertEquals(DataState.Loaded(expected), awaitItem())

View file

@ -161,7 +161,6 @@ private val DEFAULT_ACCOUNT = UserState.Account(
shouldManageResetPassword = false,
shouldUseKeyConnector = true,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
needsMasterPassword = false,

View file

@ -387,7 +387,6 @@ class RootNavViewModelTest : BaseViewModelTest() {
shouldManageResetPassword = false,
shouldUseKeyConnector = true,
role = OrganizationType.USER,
shouldUsersGetPremium = false,
),
),
needsMasterPassword = false,

View file

@ -940,7 +940,6 @@ private val DEFAULT_STATE: SearchState = SearchState(
totpData = null,
autofillSelectionData = null,
isPremium = true,
organizationPremiumStatusMap = emptyMap(),
)
private fun createStateForAutofill(

View file

@ -1016,7 +1016,6 @@ class SearchViewModelTest : BaseViewModelTest() {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
} returns expectedViewState
val dataState = DataState.Loaded(
@ -1120,7 +1119,6 @@ class SearchViewModelTest : BaseViewModelTest() {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
} returns expectedViewState
mutableVaultDataStateFlow.tryEmit(
@ -1234,7 +1232,6 @@ class SearchViewModelTest : BaseViewModelTest() {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
} returns expectedViewState
val dataState = DataState.Error(
@ -1351,7 +1348,6 @@ class SearchViewModelTest : BaseViewModelTest() {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
} returns expectedViewState
val dataState = DataState.NoNetwork(
@ -1530,7 +1526,6 @@ class SearchViewModelTest : BaseViewModelTest() {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
} returns expectedViewState
val dataState = DataState.Loaded(
@ -1566,7 +1561,6 @@ private val DEFAULT_STATE: SearchState = SearchState(
totpData = null,
autofillSelectionData = null,
isPremium = true,
organizationPremiumStatusMap = emptyMap(),
)
private val DEFAULT_USER_STATE = UserState(

View file

@ -327,7 +327,6 @@ class SearchTypeDataExtensionsTest {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(SearchState.ViewState.Empty(message = null), result)
@ -354,7 +353,6 @@ class SearchTypeDataExtensionsTest {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -396,7 +394,6 @@ class SearchTypeDataExtensionsTest {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -448,7 +445,6 @@ class SearchTypeDataExtensionsTest {
hasMasterPassword = true,
isPremiumUser = true,
isTotp = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -479,7 +475,6 @@ class SearchTypeDataExtensionsTest {
isAutofill = false,
isPremiumUser = true,
isTotp = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(

View file

@ -4421,7 +4421,6 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = true,

View file

@ -565,7 +565,6 @@ class CipherViewExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
isBiometricsEnabled = true,

View file

@ -2160,7 +2160,6 @@ private val DEFAULT_STATE = VaultItemListingState(
hasMasterPassword = true,
isPremium = false,
isRefreshing = false,
organizationPremiumStatusMap = emptyMap(),
)
private val STATE_FOR_AUTOFILL = DEFAULT_STATE.copy(

View file

@ -4206,7 +4206,6 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
fido2CreateCredentialRequest = null,
isPremium = true,
isRefreshing = false,
organizationPremiumStatusMap = emptyMap(),
)
}

View file

@ -464,7 +464,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -558,7 +557,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = fido2CredentialAutofillViews,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -645,7 +643,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = fido2CredentialAutofillViews,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -705,7 +702,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -730,7 +726,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -753,7 +748,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -776,7 +770,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -803,7 +796,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -833,7 +825,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
@ -860,7 +851,6 @@ class VaultItemListingDataExtensionsTest {
every { issuer } returns "issuer"
},
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
),
)
}
@ -1065,7 +1055,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -1110,7 +1099,6 @@ class VaultItemListingDataExtensionsTest {
fido2CredentialAutofillViews = null,
totpData = null,
isPremiumUser = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(

View file

@ -496,7 +496,6 @@ private val DEFAULT_USER_STATE = UserState(
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "mockOrganizationId-2",
@ -504,7 +503,6 @@ private val DEFAULT_USER_STATE = UserState(
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "mockOrganizationId-3",
@ -512,7 +510,6 @@ private val DEFAULT_USER_STATE = UserState(
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,

View file

@ -108,7 +108,6 @@ private fun createMockUserState(hasOrganizations: Boolean = true): UserState =
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "mockOrganizationId-2",
@ -116,7 +115,6 @@ private fun createMockUserState(hasOrganizations: Boolean = true): UserState =
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "mockOrganizationId-3",
@ -124,7 +122,6 @@ private fun createMockUserState(hasOrganizations: Boolean = true): UserState =
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
)
} else {

View file

@ -1365,7 +1365,6 @@ private val DEFAULT_STATE: VaultState = VaultState(
isRefreshing = false,
showImportActionCard = false,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
private val DEFAULT_CONTENT_VIEW_STATE: VaultState.ViewState.Content = VaultState.ViewState.Content(

View file

@ -232,7 +232,6 @@ class VaultViewModelTest : BaseViewModelTest() {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -319,7 +318,6 @@ class VaultViewModelTest : BaseViewModelTest() {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -530,7 +528,6 @@ class VaultViewModelTest : BaseViewModelTest() {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = true,
),
),
),
@ -546,9 +543,7 @@ class VaultViewModelTest : BaseViewModelTest() {
baseIconUrl = viewModel.stateFlow.value.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = mapOf("testOrganizationId" to true),
),
organizationPremiumStatusMap = mapOf("testOrganizationId" to true),
)
.copy(
appBarTitle = R.string.vaults.asText(),
@ -561,22 +556,20 @@ class VaultViewModelTest : BaseViewModelTest() {
viewModel.trySendAction(VaultAction.VaultFilterTypeSelect(VaultFilterType.MyVault))
val resultingState = initialState.copy(
vaultFilterData = VAULT_FILTER_DATA.copy(
selectedVaultFilterType = VaultFilterType.MyVault,
),
viewState = vaultData.toViewState(
isPremium = true,
vaultFilterType = VaultFilterType.MyVault,
isIconLoadingDisabled = viewModel.stateFlow.value.isIconLoadingDisabled,
baseIconUrl = viewModel.stateFlow.value.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = mapOf("testOrganizationId" to true),
),
)
assertEquals(
resultingState,
initialState.copy(
vaultFilterData = VAULT_FILTER_DATA.copy(
selectedVaultFilterType = VaultFilterType.MyVault,
),
viewState = vaultData.toViewState(
isPremium = true,
vaultFilterType = VaultFilterType.MyVault,
isIconLoadingDisabled = viewModel.stateFlow.value.isIconLoadingDisabled,
baseIconUrl = viewModel.stateFlow.value.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
),
),
viewModel.stateFlow.value,
)
verify { vaultRepository.vaultFilterType = VaultFilterType.MyVault }
@ -680,7 +673,7 @@ class VaultViewModelTest : BaseViewModelTest() {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = CipherType.entries.size,
sshKeyItemsCount = 1,
),
@ -705,7 +698,7 @@ class VaultViewModelTest : BaseViewModelTest() {
collectionItems = listOf(),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -819,7 +812,7 @@ class VaultViewModelTest : BaseViewModelTest() {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -919,7 +912,7 @@ class VaultViewModelTest : BaseViewModelTest() {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -983,12 +976,7 @@ class VaultViewModelTest : BaseViewModelTest() {
mutableVaultDataStateFlow.tryEmit(
value = DataState.NoNetwork(
data = VaultData(
cipherViewList = listOf(
createMockCipherView(
number = 1,
organizationUsesTotp = true,
),
),
cipherViewList = listOf(createMockCipherView(number = 1)),
collectionViewList = listOf(createMockCollectionView(number = 1)),
folderViewList = listOf(createMockFolderView(number = 1)),
sendViewList = listOf(createMockSendView(number = 1)),
@ -1098,7 +1086,7 @@ class VaultViewModelTest : BaseViewModelTest() {
collectionItems = listOf(),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = CipherType.entries.size - 1,
sshKeyItemsCount = 0,
),
@ -1139,7 +1127,7 @@ class VaultViewModelTest : BaseViewModelTest() {
collectionItems = listOf(),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = CipherType.entries.size,
sshKeyItemsCount = 1,
),
@ -1938,7 +1926,6 @@ private fun createMockVaultState(
viewState: VaultState.ViewState,
dialog: VaultState.DialogState? = null,
showSshKeys: Boolean = false,
organizationPremiumStatusMap: Map<String, Boolean> = emptyMap(),
): VaultState =
VaultState(
appBarTitle = R.string.my_vault.asText(),
@ -1977,5 +1964,4 @@ private fun createMockVaultState(
showImportActionCard = true,
isRefreshing = false,
showSshKeys = showSshKeys,
organizationPremiumStatusMap = organizationPremiumStatusMap,
)

View file

@ -82,7 +82,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -110,7 +109,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -142,7 +140,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -174,7 +171,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -221,7 +217,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -266,7 +261,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -315,7 +309,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -394,7 +387,6 @@ class UserStateExtensionsTest {
shouldUseKeyConnector = false,
shouldManageResetPassword = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "organizationId-A",
@ -402,7 +394,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -454,7 +445,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "organizationId-A",
@ -462,7 +452,6 @@ class UserStateExtensionsTest {
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
),
trustedDevice = null,
@ -476,52 +465,4 @@ class UserStateExtensionsTest {
),
)
}
@Test
fun `getOrganizationPremiumStatusMap should map organizations to correct status`() {
val actualMap = UserState.Account(
userId = "userId",
name = "name",
email = "email",
avatarColorHex = "avatarColorHex",
environment = Environment.Us,
isPremium = false,
isLoggedIn = true,
isVaultUnlocked = false,
needsPasswordReset = false,
isBiometricsEnabled = false,
needsMasterPassword = false,
organizations = listOf(
Organization(
id = "1",
name = "organizationName",
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = false,
),
Organization(
id = "2",
name = "organizationName",
shouldManageResetPassword = false,
shouldUseKeyConnector = false,
role = OrganizationType.ADMIN,
shouldUsersGetPremium = true,
),
),
trustedDevice = null,
hasMasterPassword = true,
isUsingKeyConnector = false,
onboardingStatus = OnboardingStatus.COMPLETE,
firstTimeState = FirstTimeState(showImportLoginsCard = true),
).getOrganizationPremiumStatusMap()
assertEquals(
mapOf(
"1" to false,
"2" to true,
),
actualMap,
)
}
}

View file

@ -62,7 +62,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -99,7 +98,7 @@ class VaultDataExtensionsTest {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -127,7 +126,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.MyVault,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -184,7 +182,6 @@ class VaultDataExtensionsTest {
),
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -210,7 +207,7 @@ class VaultDataExtensionsTest {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -234,7 +231,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -259,7 +255,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -270,9 +265,9 @@ class VaultDataExtensionsTest {
@Suppress("MaxLineLength")
@Test
fun `toViewState should return 1 for totpItemsCount if user has premium and has one totp item and item is owned by user`() {
fun `toViewState should return 1 for totpItemsCount if user has premium and has one totp item`() {
val vaultData = VaultData(
cipherViewList = listOf(createMockCipherView(number = 1, organizationId = null)),
cipherViewList = listOf(createMockCipherView(number = 1)),
collectionViewList = listOf(),
folderViewList = listOf(),
sendViewList = listOf(),
@ -285,7 +280,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -324,7 +318,6 @@ class VaultDataExtensionsTest {
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -363,7 +356,6 @@ class VaultDataExtensionsTest {
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -404,7 +396,6 @@ class VaultDataExtensionsTest {
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -629,7 +620,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -643,7 +633,7 @@ class VaultDataExtensionsTest {
collectionItems = listOf(),
noFolderItems = listOf(),
trashItemsCount = 2,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -670,7 +660,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -700,7 +689,7 @@ class VaultDataExtensionsTest {
every { uriMock.host } returns "www.mockuri1.com"
val vaultData = VaultData(
cipherViewList = List(100) {
createMockCipherView(number = it, folderId = null, organizationUsesTotp = true)
createMockCipherView(number = it, folderId = null)
},
collectionViewList = listOf(),
folderViewList = listOf(),
@ -714,7 +703,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -771,7 +759,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -813,7 +800,7 @@ class VaultDataExtensionsTest {
),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
itemTypesCount = 4,
sshKeyItemsCount = 0,
),
@ -841,7 +828,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = false,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -857,7 +843,7 @@ class VaultDataExtensionsTest {
folderItems = listOf(),
noFolderItems = listOf(),
trashItemsCount = 0,
totpItemsCount = 0,
totpItemsCount = 1,
// Verify item types count excludes CipherType.SSH_KEY when showSshKeys is false.
itemTypesCount = 4,
),
@ -869,7 +855,7 @@ class VaultDataExtensionsTest {
fun `toViewState should include SSH key vault items and type count if showSshKeys is true`() {
val vaultData = VaultData(
cipherViewList = listOf(
createMockCipherView(number = 1, organizationId = null),
createMockCipherView(number = 1),
createMockCipherView(number = 2, cipherType = CipherType.SSH_KEY),
),
collectionViewList = listOf(),
@ -885,7 +871,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(
@ -944,7 +929,6 @@ class VaultDataExtensionsTest {
vaultFilterType = VaultFilterType.AllVaults,
hasMasterPassword = true,
showSshKeys = true,
organizationPremiumStatusMap = emptyMap(),
)
assertEquals(

View file

@ -57,7 +57,6 @@ class VerificationCodeViewModelTest : BaseViewModelTest() {
private val mockUserAccount: UserState.Account = mockk {
every { isPremium } returns true
every { organizations } returns emptyList()
}
private val mockUserState: UserState = mockk {

View file

@ -16,5 +16,4 @@ fun createVerificationCodeItem(number: Int = 1) =
username = "mockUsername-$number",
hasPasswordReprompt = false,
orgUsesTotp = false,
orgId = null,
)