Clear KeePassGO master password after use
This commit is contained in:
@@ -196,6 +196,9 @@ func TestUILifecycleActionsCreateSaveOpenLockAndUnlockLocalVault(t *testing.T) {
|
||||
if err := u.createVaultAction(); err != nil {
|
||||
t.Fatalf("createVaultAction() error = %v", err)
|
||||
}
|
||||
if got := u.masterPassword.Text(); got != "" {
|
||||
t.Fatalf("masterPassword after create = %q, want empty", got)
|
||||
}
|
||||
if err := u.state.UpsertEntry(vault.Entry{
|
||||
ID: "git-server",
|
||||
Title: "Git Server",
|
||||
@@ -222,6 +225,7 @@ func TestUILifecycleActionsCreateSaveOpenLockAndUnlockLocalVault(t *testing.T) {
|
||||
t.Fatalf("filteredTitles() = %v, want empty while locked", got)
|
||||
}
|
||||
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
if err := u.unlockAction(); err != nil {
|
||||
t.Fatalf("unlockAction() error = %v", err)
|
||||
}
|
||||
@@ -236,6 +240,9 @@ func TestUILifecycleActionsCreateSaveOpenLockAndUnlockLocalVault(t *testing.T) {
|
||||
if err := reopened.openVaultAction(); err != nil {
|
||||
t.Fatalf("openVaultAction() error = %v", err)
|
||||
}
|
||||
if got := reopened.masterPassword.Text(); got != "" {
|
||||
t.Fatalf("masterPassword after open = %q, want empty", got)
|
||||
}
|
||||
reopened.state.NavigateToPath([]string{"Root", "Internet"})
|
||||
reopened.filter()
|
||||
if got := reopened.filteredTitles(); !slices.Equal(got, []string{"Git Server"}) {
|
||||
@@ -243,6 +250,32 @@ func TestUILifecycleActionsCreateSaveOpenLockAndUnlockLocalVault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUILockAndUnlockClearMasterPasswordField(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
if err := u.createVaultAction(); err != nil {
|
||||
t.Fatalf("createVaultAction() error = %v", err)
|
||||
}
|
||||
|
||||
u.masterPassword.SetText("should-be-cleared")
|
||||
if err := u.lockAction(); err != nil {
|
||||
t.Fatalf("lockAction() error = %v", err)
|
||||
}
|
||||
if got := u.masterPassword.Text(); got != "" {
|
||||
t.Fatalf("masterPassword after lock = %q, want empty", got)
|
||||
}
|
||||
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
if err := u.unlockAction(); err != nil {
|
||||
t.Fatalf("unlockAction() error = %v", err)
|
||||
}
|
||||
if got := u.masterPassword.Text(); got != "" {
|
||||
t.Fatalf("masterPassword after unlock = %q, want empty", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIMasterKeyModesCreateOpenAndUnlockLocalVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -311,6 +344,8 @@ func TestUIMasterKeyModesCreateOpenAndUnlockLocalVault(t *testing.T) {
|
||||
if err := u.lockAction(); err != nil {
|
||||
t.Fatalf("lockAction() error = %v", err)
|
||||
}
|
||||
u.masterPassword.SetText(tt.password)
|
||||
u.keyFilePath.SetText(keyFile)
|
||||
if err := u.unlockAction(); err != nil {
|
||||
t.Fatalf("unlockAction() error = %v", err)
|
||||
}
|
||||
@@ -2060,6 +2095,7 @@ func TestUILocalLifecycleActionsUpdateVisibleStatusMessages(t *testing.T) {
|
||||
t.Fatalf("error after lock = %q, want empty", got)
|
||||
}
|
||||
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
u.runAction("unlock vault", u.unlockAction)
|
||||
if got := u.state.StatusMessage; got != "unlock vault complete" {
|
||||
t.Fatalf("status after unlock = %q, want %q", got, "unlock vault complete")
|
||||
|
||||
Reference in New Issue
Block a user