Fix extra string actions
This commit is contained in:
@@ -3830,6 +3830,21 @@ func TestUILoadSelectedEntryIntoEditorPopulatesStructuredCustomFields(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoveCustomFieldRowToleratesMissingClickables(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
u.customFieldKeys = []widget.Editor{{SingleLine: true}}
|
||||
u.customFieldValues = []widget.Editor{{SingleLine: true}}
|
||||
u.removeCustomFields = nil
|
||||
|
||||
u.removeCustomFieldRow(0)
|
||||
|
||||
if len(u.customFieldKeys) != 1 || len(u.customFieldValues) != 1 || len(u.removeCustomFields) != 1 {
|
||||
t.Fatalf("custom field rows after remove with missing clickables = %d/%d/%d, want one blank row", len(u.customFieldKeys), len(u.customFieldValues), len(u.removeCustomFields))
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIEditingEntryPathMovesEntryBetweenGroups(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -9126,6 +9141,76 @@ func TestUIPasswordRevealTogglesDisplayedPasswordAndLockResetsIt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIExtraStringValuesAreMaskedUntilRevealed(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{
|
||||
ID: "vault-console",
|
||||
Title: "Vault Console",
|
||||
Path: []string{"Root", "Internet"},
|
||||
Fields: map[string]string{
|
||||
"OTPSeed": "green-light",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
u.showEntriesSection()
|
||||
u.state.NavigateToPath([]string{"Root", "Internet"})
|
||||
u.filter()
|
||||
u.state.SelectedEntryID = "vault-console"
|
||||
|
||||
fields := u.detailExtraStrings()
|
||||
if len(fields) != 1 {
|
||||
t.Fatalf("len(detailExtraStrings()) = %d, want 1", len(fields))
|
||||
}
|
||||
if fields[0].Value != strings.Repeat("•", len("green-light")) {
|
||||
t.Fatalf("detailExtraStrings()[0].Value hidden = %q, want masked value", fields[0].Value)
|
||||
}
|
||||
|
||||
u.toggleExtraStringReveal("OTPSeed")
|
||||
fields = u.detailExtraStrings()
|
||||
if fields[0].Value != "green-light" {
|
||||
t.Fatalf("detailExtraStrings()[0].Value revealed = %q, want green-light", fields[0].Value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUICopyExtraStringWritesClipboardWithoutLeakingStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{
|
||||
ID: "vault-console",
|
||||
Title: "Vault Console",
|
||||
Path: []string{"Root", "Internet"},
|
||||
Fields: map[string]string{
|
||||
"OTPSeed": "green-light",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
writer := &memoryClipboardWriter{}
|
||||
u.clipboardWriter = writer
|
||||
u.showEntriesSection()
|
||||
u.state.NavigateToPath([]string{"Root", "Internet"})
|
||||
u.filter()
|
||||
u.state.SelectedEntryID = "vault-console"
|
||||
|
||||
u.runAction("copy extra string", func() error { return u.copySelectedCustomFieldAction("OTPSeed") })
|
||||
|
||||
if writer.content != "green-light" {
|
||||
t.Fatalf("clipboard content = %q, want green-light", writer.content)
|
||||
}
|
||||
if u.state.StatusMessage != "copy extra string complete" {
|
||||
t.Fatalf("state.StatusMessage = %q, want copy extra string complete", u.state.StatusMessage)
|
||||
}
|
||||
if strings.Contains(u.state.StatusMessage, "green-light") {
|
||||
t.Fatalf("state.StatusMessage = %q, must not contain copied extra string value", u.state.StatusMessage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIPasswordTogglePresentationMatchesVisibility(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user