File tree Expand file tree Collapse file tree 2 files changed +36
-8
lines changed
main/java/com/x8bit/bitwarden/ui/vault/feature/item
test/java/com/x8bit/bitwarden/ui/vault/feature/item Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Original file line number Diff line number Diff line change @@ -804,6 +804,16 @@ class VaultItemViewModel @Inject constructor(
804
804
action : VaultItemAction .ItemType .SshKey .PrivateKeyVisibilityClicked ,
805
805
) {
806
806
onSshKeyContent { content, sshKey ->
807
+ if (content.common.requiresReprompt) {
808
+ updateDialogState(
809
+ VaultItemState .DialogState .MasterPasswordDialog (
810
+ action = PasswordRepromptAction .ViewPrivateKeyClicked (
811
+ isVisible = action.isVisible,
812
+ ),
813
+ ),
814
+ )
815
+ return @onSshKeyContent
816
+ }
807
817
mutableStateFlow.update { currentState ->
808
818
currentState.copy(
809
819
viewState = content.copy(
@@ -2231,4 +2241,18 @@ sealed class PasswordRepromptAction : Parcelable {
2231
2241
override val vaultItemAction: VaultItemAction
2232
2242
get() = VaultItemAction .Common .RestoreVaultItemClick
2233
2243
}
2244
+
2245
+ /* *
2246
+ * Indicates that we should launch the
2247
+ * [VaultItemAction.ItemType.SshKey.PrivateKeyVisibilityClicked] upon password validation.
2248
+ */
2249
+ @Parcelize
2250
+ data class ViewPrivateKeyClicked (
2251
+ val isVisible : Boolean ,
2252
+ ) : PasswordRepromptAction() {
2253
+ override val vaultItemAction: VaultItemAction
2254
+ get() = VaultItemAction .ItemType .SshKey .PrivateKeyVisibilityClicked (
2255
+ isVisible = isVisible,
2256
+ )
2257
+ }
2234
2258
}
Original file line number Diff line number Diff line change @@ -2492,9 +2492,6 @@ class VaultItemViewModelTest : BaseViewModelTest() {
2492
2492
@Test
2493
2493
fun `on PrivateKeyVisibilityClick should show password dialog when re-prompt is required` () =
2494
2494
runTest {
2495
- val sshKeyViewState = createViewState(
2496
- common = DEFAULT_COMMON .copy(requiresReprompt = false ),
2497
- )
2498
2495
val sshKeyState = DEFAULT_STATE .copy(viewState = SSH_KEY_VIEW_STATE )
2499
2496
every {
2500
2497
mockCipherView.toViewState(
@@ -2518,15 +2515,22 @@ class VaultItemViewModelTest : BaseViewModelTest() {
2518
2515
)
2519
2516
assertEquals(
2520
2517
sshKeyState.copy(
2521
- viewState = sshKeyViewState.copy(
2522
- common = DEFAULT_COMMON ,
2523
- type = DEFAULT_SSH_KEY_TYPE .copy(
2524
- showPrivateKey = true ,
2525
- ),
2518
+ dialog = VaultItemState .DialogState .MasterPasswordDialog (
2519
+ PasswordRepromptAction .ViewPrivateKeyClicked (isVisible = true ),
2526
2520
),
2527
2521
),
2528
2522
viewModel.stateFlow.value,
2529
2523
)
2524
+ verify(exactly = 1 ) {
2525
+ mockCipherView.toViewState(
2526
+ previousState = null ,
2527
+ isPremiumUser = true ,
2528
+ hasMasterPassword = true ,
2529
+ totpCodeItemData = null ,
2530
+ canDelete = true ,
2531
+ canAssignToCollections = true ,
2532
+ )
2533
+ }
2530
2534
}
2531
2535
2532
2536
@Test
You can’t perform that action at this time.
0 commit comments