Reset password peek across view changes
This commit is contained in:
@@ -2097,6 +2097,60 @@ func TestEnterOnRemoteLifecycleScreenDefaultsToOpenRemoteVault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMasterPasswordPeekResetsAfterOpeningVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
path := filepath.Join(t.TempDir(), "vault.kdbx")
|
||||
var encoded bytes.Buffer
|
||||
if err := vault.SaveKDBX(&encoded, vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "vault-console", Title: "Vault Console", Password: "token-1", Path: []string{"Root", "Internet"}},
|
||||
},
|
||||
}, "correct horse battery staple"); err != nil {
|
||||
t.Fatalf("SaveKDBX() error = %v", err)
|
||||
}
|
||||
if err := os.WriteFile(path, encoded.Bytes(), 0o600); err != nil {
|
||||
t.Fatalf("WriteFile(vault.kdbx) error = %v", err)
|
||||
}
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
u.vaultPath.SetText(path)
|
||||
u.showPassword = true
|
||||
|
||||
if err := u.openVaultAction(); err != nil {
|
||||
t.Fatalf("openVaultAction() error = %v", err)
|
||||
}
|
||||
if u.showPassword {
|
||||
t.Fatal("showPassword = true after openVaultAction(), want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPasswordPeekResetsWhenChangingSelectedEntry(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "vault-console", Title: "Vault Console", Password: "token-1", Path: []string{"Root", "Internet"}},
|
||||
{ID: "bellagio", Title: "Bellagio", Password: "token-2", Path: []string{"Root", "Internet"}},
|
||||
},
|
||||
})
|
||||
u.showEntriesSection()
|
||||
u.state.NavigateToPath([]string{"Root", "Internet"})
|
||||
u.filter()
|
||||
|
||||
u.state.SelectedEntryID = "vault-console"
|
||||
u.loadSelectedEntryIntoEditor()
|
||||
u.showPassword = true
|
||||
|
||||
u.state.SelectedEntryID = "bellagio"
|
||||
u.loadSelectedEntryIntoEditor()
|
||||
|
||||
if u.showPassword {
|
||||
t.Fatal("showPassword = true after selecting a different entry, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnterOnLockedScreenDefaultsToUnlockVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user