mirror of
https://github.com/bitwarden/android.git
synced 2026-06-13 07:29:20 -05:00
Compare commits
4 Commits
PM-39006-s
...
release/20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de0ce5e979 | ||
|
|
511954c9b8 | ||
|
|
d96494ebb7 | ||
|
|
91d7cf4b7d |
@@ -18,5 +18,4 @@ data class Organization(
|
||||
val shouldManageResetPassword: Boolean,
|
||||
val shouldUseKeyConnector: Boolean,
|
||||
val role: OrganizationType,
|
||||
val shouldUsersGetPremium: Boolean,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,6 @@ fun SyncResponseJson.Profile.Organization.toOrganization(): Organization =
|
||||
shouldUseKeyConnector = this.shouldUseKeyConnector,
|
||||
role = this.type,
|
||||
shouldManageResetPassword = this.permissions.shouldManageResetPassword,
|
||||
shouldUsersGetPremium = this.shouldUsersGetPremium,
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -189,7 +189,7 @@ sealed class FlagKey<out T : Any> {
|
||||
data object SingleTapPasskeyCreation : FlagKey<Boolean>() {
|
||||
override val keyName: String = "single-tap-passkey-creation"
|
||||
override val defaultValue: Boolean = false
|
||||
override val isRemotelyConfigured: Boolean = false
|
||||
override val isRemotelyConfigured: Boolean = true
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ sealed class FlagKey<out T : Any> {
|
||||
data object SingleTapPasskeyAuthentication : FlagKey<Boolean>() {
|
||||
override val keyName: String = "single-tap-passkey-authentication"
|
||||
override val defaultValue: Boolean = false
|
||||
override val isRemotelyConfigured: Boolean = false
|
||||
override val isRemotelyConfigured: Boolean = true
|
||||
}
|
||||
|
||||
//region Dummy keys for testing
|
||||
|
||||
@@ -122,7 +122,6 @@ class TotpCodeManagerImpl(
|
||||
CipherRepromptType.NONE -> false
|
||||
},
|
||||
orgUsesTotp = cipher.organizationUseTotp,
|
||||
orgId = cipher.organizationId,
|
||||
)
|
||||
}
|
||||
.onFailure {
|
||||
|
||||
@@ -29,5 +29,4 @@ data class VerificationCodeItem(
|
||||
val username: String?,
|
||||
val hasPasswordReprompt: Boolean,
|
||||
val orgUsesTotp: Boolean,
|
||||
val orgId: String?,
|
||||
)
|
||||
|
||||
@@ -255,9 +255,9 @@ private fun CompleteRegistrationContent(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
},
|
||||
passwordFieldTestTag = "MasterPasswordEntry",
|
||||
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("MasterPasswordEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
@@ -272,9 +272,9 @@ private fun CompleteRegistrationContent(
|
||||
showPasswordChange = { showPassword = it },
|
||||
onValueChange = handler.onConfirmPasswordInputChange,
|
||||
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
|
||||
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
|
||||
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("ConfirmMasterPasswordEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
|
||||
@@ -219,9 +219,9 @@ fun CreateAccountScreen(
|
||||
color = BitwardenTheme.colorScheme.text.secondary,
|
||||
)
|
||||
},
|
||||
passwordFieldTestTag = "MasterPasswordEntry",
|
||||
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("MasterPasswordEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
@@ -234,9 +234,9 @@ fun CreateAccountScreen(
|
||||
{ viewModel.trySendAction(ConfirmPasswordInputChange(it)) }
|
||||
},
|
||||
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
|
||||
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
|
||||
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("ConfirmMasterPasswordEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
|
||||
@@ -253,9 +253,9 @@ private fun LoginScreenContent(
|
||||
modifier = Modifier.testTag("GetMasterPasswordHintLabel"),
|
||||
)
|
||||
},
|
||||
passwordFieldTestTag = "MasterPasswordEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("MasterPasswordEntry")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -105,10 +105,10 @@ private fun RemovePasswordScreenContent(
|
||||
value = state.input,
|
||||
onValueChange = onInputChanged,
|
||||
showPasswordTestTag = "PasswordVisibilityToggle",
|
||||
textFieldTestTag = "MasterPasswordEntry",
|
||||
autoFocus = true,
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag(tag = "MasterPasswordEntry")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -185,9 +185,9 @@ private fun ResetPasswordScreenContent(
|
||||
label = stringResource(id = R.string.current_master_password),
|
||||
value = state.currentPasswordInput,
|
||||
onValueChange = onCurrentPasswordInputChanged,
|
||||
textFieldTestTag = "MasterPasswordField",
|
||||
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("MasterPasswordField")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
@@ -200,6 +200,7 @@ private fun ResetPasswordScreenContent(
|
||||
onValueChange = onPasswordInputChanged,
|
||||
showPassword = isPasswordVisible,
|
||||
showPasswordChange = { isPasswordVisible = it },
|
||||
passwordFieldTestTag = "NewPasswordField",
|
||||
cardStyle = if (
|
||||
state.resetReason == ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN) {
|
||||
CardStyle.Middle(dividerPadding = 0.dp)
|
||||
@@ -207,7 +208,6 @@ private fun ResetPasswordScreenContent(
|
||||
CardStyle.Top(dividerPadding = 0.dp)
|
||||
},
|
||||
modifier = Modifier
|
||||
.testTag("NewPasswordField")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
@@ -218,9 +218,9 @@ private fun ResetPasswordScreenContent(
|
||||
onValueChange = onRetypePasswordInputChanged,
|
||||
showPassword = isPasswordVisible,
|
||||
showPasswordChange = { isPasswordVisible = it },
|
||||
passwordFieldTestTag = "RetypePasswordField",
|
||||
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("RetypePasswordField")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -146,9 +146,9 @@ private fun SetPasswordScreenContent(
|
||||
showPassword = isPasswordVisible,
|
||||
showPasswordChange = { isPasswordVisible = it },
|
||||
supportingText = stringResource(id = R.string.master_password_description),
|
||||
passwordFieldTestTag = "NewPasswordField",
|
||||
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("NewPasswordField")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
@@ -159,9 +159,9 @@ private fun SetPasswordScreenContent(
|
||||
onValueChange = onRetypePasswordInputChanged,
|
||||
showPassword = isPasswordVisible,
|
||||
showPasswordChange = { isPasswordVisible = it },
|
||||
passwordFieldTestTag = "RetypePasswordField",
|
||||
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
|
||||
modifier = Modifier
|
||||
.testTag("RetypePasswordField")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -270,9 +270,9 @@ fun VaultUnlockScreen(
|
||||
},
|
||||
),
|
||||
supportingText = state.vaultUnlockType.unlockScreenMessage(),
|
||||
textFieldTestTag = state.vaultUnlockType.unlockScreenInputTestTag,
|
||||
cardStyle = CardStyle.Top(hasDivider = false),
|
||||
modifier = Modifier
|
||||
.testTag(tag = state.vaultUnlockType.unlockScreenInputTestTag)
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -78,10 +78,9 @@ fun BitwardenMasterPasswordDialog(
|
||||
value = masterPassword,
|
||||
onValueChange = { masterPassword = it },
|
||||
autoFocus = true,
|
||||
textFieldTestTag = "AlertInputField",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("AlertInputField")
|
||||
.imePadding(),
|
||||
modifier = Modifier.imePadding(),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -66,9 +66,9 @@ fun BitwardenPinDialog(
|
||||
value = pin,
|
||||
onValueChange = { pin = it },
|
||||
autoFocus = true,
|
||||
textFieldTestTag = "AlertInputField",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("AlertInputField")
|
||||
.fillMaxWidth()
|
||||
.imePadding(),
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalTextToolbar
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
@@ -24,6 +25,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
* @param label Label for the text field.
|
||||
* @param value Current text on the text field.
|
||||
* @param modifier Modifier for the composable.
|
||||
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Composable
|
||||
@@ -31,13 +33,15 @@ fun BitwardenHiddenPasswordField(
|
||||
label: String?,
|
||||
value: String,
|
||||
modifier: Modifier = Modifier,
|
||||
passwordFieldTestTag: String? = null,
|
||||
cardStyle: CardStyle? = null,
|
||||
) {
|
||||
CompositionLocalProvider(value = LocalTextToolbar provides BitwardenEmptyTextToolbar) {
|
||||
TextField(
|
||||
modifier = modifier
|
||||
.cardBackground(cardStyle = cardStyle)
|
||||
.cardPadding(cardStyle = cardStyle, vertical = 6.dp),
|
||||
.cardPadding(cardStyle = cardStyle, vertical = 6.dp)
|
||||
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this },
|
||||
textStyle = BitwardenTheme.typography.sensitiveInfoSmall,
|
||||
label = label?.let { { Text(text = it) } },
|
||||
value = value,
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalTextToolbar
|
||||
import androidx.compose.ui.platform.TextToolbar
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
@@ -74,6 +75,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
* @param imeAction the preferred IME action for the keyboard to have.
|
||||
* @param keyboardActions the callbacks of keyboard actions.
|
||||
* @param textToolbarType The type of [TextToolbar] to use on the text field.
|
||||
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Suppress("LongMethod", "CyclomaticComplexMethod")
|
||||
@@ -94,6 +96,7 @@ fun BitwardenPasswordField(
|
||||
imeAction: ImeAction = ImeAction.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
|
||||
passwordFieldTestTag: String? = null,
|
||||
cardStyle: CardStyle? = null,
|
||||
) {
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
@@ -165,7 +168,9 @@ fun BitwardenPasswordField(
|
||||
onClick = { showPasswordChange.invoke(!showPassword) },
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this }
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
supportingTextContent?.let {
|
||||
Spacer(modifier = Modifier.height(height = 8.dp))
|
||||
@@ -211,6 +216,7 @@ fun BitwardenPasswordField(
|
||||
* @param imeAction the preferred IME action for the keyboard to have.
|
||||
* @param keyboardActions the callbacks of keyboard actions.
|
||||
* @param textToolbarType The type of [TextToolbar] to use on the text field.
|
||||
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Composable
|
||||
@@ -230,6 +236,7 @@ fun BitwardenPasswordField(
|
||||
imeAction: ImeAction = ImeAction.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
|
||||
passwordFieldTestTag: String? = null,
|
||||
cardStyle: CardStyle? = null,
|
||||
) {
|
||||
BitwardenPasswordField(
|
||||
@@ -257,6 +264,7 @@ fun BitwardenPasswordField(
|
||||
imeAction = imeAction,
|
||||
keyboardActions = keyboardActions,
|
||||
textToolbarType = textToolbarType,
|
||||
passwordFieldTestTag = passwordFieldTestTag,
|
||||
cardStyle = cardStyle,
|
||||
)
|
||||
}
|
||||
@@ -285,6 +293,7 @@ fun BitwardenPasswordField(
|
||||
* @param imeAction the preferred IME action for the keyboard to have.
|
||||
* @param keyboardActions the callbacks of keyboard actions.
|
||||
* @param textToolbarType The type of [TextToolbar] to use on the text field.
|
||||
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Composable
|
||||
@@ -303,6 +312,7 @@ fun BitwardenPasswordField(
|
||||
imeAction: ImeAction = ImeAction.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
|
||||
passwordFieldTestTag: String? = null,
|
||||
cardStyle: CardStyle? = null,
|
||||
) {
|
||||
var showPassword by rememberSaveable { mutableStateOf(value = initialShowPassword) }
|
||||
@@ -322,6 +332,7 @@ fun BitwardenPasswordField(
|
||||
imeAction = imeAction,
|
||||
keyboardActions = keyboardActions,
|
||||
textToolbarType = textToolbarType,
|
||||
passwordFieldTestTag = passwordFieldTestTag,
|
||||
cardStyle = cardStyle,
|
||||
)
|
||||
}
|
||||
@@ -347,6 +358,7 @@ fun BitwardenPasswordField(
|
||||
* the password field.
|
||||
* @param imeAction the preferred IME action for the keyboard to have.
|
||||
* @param keyboardActions the callbacks of keyboard actions.
|
||||
* @param textFieldTestTag The optional test tag associated with the inner text field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Composable
|
||||
@@ -364,6 +376,7 @@ fun BitwardenPasswordField(
|
||||
keyboardType: KeyboardType = KeyboardType.Password,
|
||||
imeAction: ImeAction = ImeAction.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
textFieldTestTag: String? = null,
|
||||
cardStyle: CardStyle? = null,
|
||||
) {
|
||||
var showPassword by rememberSaveable { mutableStateOf(initialShowPassword) }
|
||||
@@ -382,6 +395,7 @@ fun BitwardenPasswordField(
|
||||
keyboardType = keyboardType,
|
||||
imeAction = imeAction,
|
||||
keyboardActions = keyboardActions,
|
||||
passwordFieldTestTag = textFieldTestTag,
|
||||
cardStyle = cardStyle,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.TextToolbar
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
@@ -95,10 +94,9 @@ fun BitwardenPasswordFieldWithActions(
|
||||
readOnly = readOnly,
|
||||
singleLine = singleLine,
|
||||
showPasswordTestTag = showPasswordTestTag,
|
||||
passwordFieldTestTag = passwordFieldTestTag,
|
||||
textToolbarType = textToolbarType,
|
||||
modifier = Modifier
|
||||
.semantics { passwordFieldTestTag?.let { testTag = it } }
|
||||
.weight(weight = 1f),
|
||||
modifier = Modifier.weight(weight = 1f),
|
||||
)
|
||||
BitwardenRowOfActions(
|
||||
modifier = Modifier.padding(paddingValues = actionsPadding),
|
||||
|
||||
@@ -78,6 +78,7 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
* @param visualTransformation Transforms the visual representation of the input [value].
|
||||
* @param keyboardType the preferred type of keyboard input.
|
||||
* @param textToolbarType The type of [TextToolbar] to use on the text field.
|
||||
* @param textFieldTestTag The optional test tag associated with the inner text field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Composable
|
||||
@@ -161,6 +162,7 @@ fun BitwardenTextField(
|
||||
* @param visualTransformation Transforms the visual representation of the input [value].
|
||||
* @param keyboardType the preferred type of keyboard input.
|
||||
* @param textToolbarType The type of [TextToolbar] to use on the text field.
|
||||
* @param textFieldTestTag The optional test tag associated with the inner text field.
|
||||
* @param cardStyle Indicates the type of card style to be applied.
|
||||
*/
|
||||
@Suppress("LongMethod", "CyclomaticComplexMethod")
|
||||
|
||||
@@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +249,9 @@ private fun ExportVaultScreenContent(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
},
|
||||
showPasswordTestTag = "FilePasswordEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("FilePasswordEntry")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
@@ -264,9 +264,9 @@ private fun ExportVaultScreenContent(
|
||||
onValueChange = onConfirmFilePasswordInputChanged,
|
||||
showPassword = showPassword,
|
||||
showPasswordChange = { showPassword = it },
|
||||
passwordFieldTestTag = "ConfirmFilePasswordEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("ConfirmFilePasswordEntry")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
@@ -321,9 +321,9 @@ private fun ExportVaultScreenContent(
|
||||
value = state.passwordInput,
|
||||
readOnly = state.policyPreventsExport,
|
||||
onValueChange = onPasswordInputChanged,
|
||||
textFieldTestTag = "MasterPasswordEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("MasterPasswordEntry")
|
||||
.standardHorizontalMargin()
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -910,10 +910,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiAccessToken,
|
||||
onValueChange = forwardedEmailAliasHandlers.onAddyIoAccessTokenTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -937,10 +937,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiKey,
|
||||
onValueChange = forwardedEmailAliasHandlers.onDuckDuckGoApiKeyTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
@@ -951,10 +951,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiKey,
|
||||
onValueChange = forwardedEmailAliasHandlers.onFastMailApiKeyTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
@@ -965,10 +965,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiAccessToken,
|
||||
onValueChange = forwardedEmailAliasHandlers.onFirefoxRelayAccessTokenTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
@@ -979,10 +979,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiKey,
|
||||
onValueChange = forwardedEmailAliasHandlers.onForwardEmailApiKeyTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
@@ -1006,10 +1006,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = usernameTypeState.selectedServiceType.apiKey,
|
||||
onValueChange = forwardedEmailAliasHandlers.onSimpleLoginApiKeyTextChange,
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
@@ -1021,10 +1021,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
|
||||
value = obfuscatedTextField,
|
||||
onValueChange = { obfuscatedTextField = it },
|
||||
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
|
||||
textFieldTestTag = "ForwardedEmailApiSecretEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.standardHorizontalMargin()
|
||||
.testTag("ForwardedEmailApiSecretEntry")
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -420,9 +420,9 @@ private fun AddSendOptions(
|
||||
readOnly = sendRestrictionPolicy,
|
||||
value = state.common.passwordInput,
|
||||
onValueChange = addSendHandlers.onPasswordChange,
|
||||
textFieldTestTag = "SendNewPasswordEntry",
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = Modifier
|
||||
.testTag("SendNewPasswordEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
|
||||
@@ -85,9 +85,9 @@ fun LazyListScope.vaultAddEditCardItems(
|
||||
cardHandlers.onNumberVisibilityChange(showNumber)
|
||||
},
|
||||
showPasswordTestTag = "ShowCardNumberButton",
|
||||
passwordFieldTestTag = "CardNumberEntry",
|
||||
cardStyle = CardStyle.Middle(),
|
||||
modifier = Modifier
|
||||
.testTag("CardNumberEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
@@ -164,9 +164,9 @@ fun LazyListScope.vaultAddEditCardItems(
|
||||
},
|
||||
keyboardType = KeyboardType.NumberPassword,
|
||||
showPasswordTestTag = "CardShowSecurityCodeButton",
|
||||
passwordFieldTestTag = "CardSecurityCodeEntry",
|
||||
cardStyle = CardStyle.Bottom,
|
||||
modifier = Modifier
|
||||
.testTag("CardSecurityCodeEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
|
||||
@@ -578,8 +578,9 @@ private fun CoachMarkScope<AddEditItemCoachMark>.PasswordRow(
|
||||
BitwardenHiddenPasswordField(
|
||||
label = stringResource(id = R.string.password),
|
||||
value = password,
|
||||
passwordFieldTestTag = "LoginPasswordEntry",
|
||||
cardStyle = CardStyle.Bottom,
|
||||
modifier = modifier.testTag("LoginPasswordEntry"),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ fun LazyListScope.vaultAddEditSshKeyItems(
|
||||
showPassword = sshKeyState.showPrivateKey,
|
||||
showPasswordChange = { sshKeyTypeHandlers.onPrivateKeyVisibilityChange(it) },
|
||||
showPasswordTestTag = "ViewPrivateKeyButton",
|
||||
passwordFieldTestTag = "PrivateKeyEntry",
|
||||
cardStyle = CardStyle.Middle(),
|
||||
modifier = Modifier
|
||||
.testTag("PrivateKeyEntry")
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
|
||||
@@ -376,9 +376,9 @@ private fun PasswordField(
|
||||
BitwardenHiddenPasswordField(
|
||||
label = stringResource(id = R.string.password),
|
||||
value = passwordData.password,
|
||||
passwordFieldTestTag = "LoginPasswordEntry",
|
||||
cardStyle = cardStyle,
|
||||
modifier = modifier
|
||||
.testTag("LoginPasswordEntry"),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -161,7 +161,6 @@ private val DEFAULT_ACCOUNT = UserState.Account(
|
||||
shouldManageResetPassword = false,
|
||||
shouldUseKeyConnector = true,
|
||||
role = OrganizationType.USER,
|
||||
shouldUsersGetPremium = false,
|
||||
),
|
||||
),
|
||||
needsMasterPassword = false,
|
||||
|
||||
@@ -387,7 +387,6 @@ class RootNavViewModelTest : BaseViewModelTest() {
|
||||
shouldManageResetPassword = false,
|
||||
shouldUseKeyConnector = true,
|
||||
role = OrganizationType.USER,
|
||||
shouldUsersGetPremium = false,
|
||||
),
|
||||
),
|
||||
needsMasterPassword = false,
|
||||
|
||||
@@ -940,7 +940,6 @@ private val DEFAULT_STATE: SearchState = SearchState(
|
||||
totpData = null,
|
||||
autofillSelectionData = null,
|
||||
isPremium = true,
|
||||
organizationPremiumStatusMap = emptyMap(),
|
||||
)
|
||||
|
||||
private fun createStateForAutofill(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -4421,7 +4421,6 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
|
||||
shouldManageResetPassword = false,
|
||||
shouldUseKeyConnector = false,
|
||||
role = OrganizationType.ADMIN,
|
||||
shouldUsersGetPremium = false,
|
||||
),
|
||||
),
|
||||
isBiometricsEnabled = true,
|
||||
|
||||
@@ -565,7 +565,6 @@ class CipherViewExtensionsTest {
|
||||
shouldManageResetPassword = false,
|
||||
shouldUseKeyConnector = false,
|
||||
role = OrganizationType.ADMIN,
|
||||
shouldUsersGetPremium = false,
|
||||
),
|
||||
),
|
||||
isBiometricsEnabled = true,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -4206,7 +4206,6 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
|
||||
fido2CreateCredentialRequest = null,
|
||||
isPremium = true,
|
||||
isRefreshing = false,
|
||||
organizationPremiumStatusMap = emptyMap(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -16,5 +16,4 @@ fun createVerificationCodeItem(number: Int = 1) =
|
||||
username = "mockUsername-$number",
|
||||
hasPasswordReprompt = false,
|
||||
orgUsesTotp = false,
|
||||
orgId = null,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user