lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 49c7044f7bd6718b84e980c2fe1a30a260fa4659
parent ebbbd44da5a1db56e53f3096566c6cead286108a
Author: Sean Enck <sean@ttypty.com>
Date:   Mon,  9 Jun 2025 18:57:11 -0400

password and url are not really special, rather than being known

Diffstat:
Minternal/app/help/core.go | 1-
Minternal/kdbx/core.go | 6+-----
Minternal/kdbx/core_test.go | 14++++++++++++++
3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/internal/app/help/core.go b/internal/app/help/core.go @@ -124,7 +124,6 @@ func Usage(verbose bool, exe string) ([]string, error) { for _, field := range kdbx.AllowedFields { fields = append(fields, strings.ToLower(field)) } - sort.Strings(fields) document.Database.Fields = strings.Join(fields, ", ") var examples []string for _, example := range []string{commands.Insert, commands.Show} { diff --git a/internal/kdbx/core.go b/internal/kdbx/core.go @@ -17,7 +17,7 @@ import ( var ( errPath = errors.New("input paths must contain at LEAST 2 components") // AllowedFields are the same of allowed names for storing in a kdbx entry - AllowedFields = []string{NotesField, OTPField, PasswordField, URLField} + AllowedFields = []string{NotesField, OTPField, "Password", "URL"} ) const ( @@ -29,10 +29,6 @@ const ( OTPField = "otp" // NotesField is the multiline notes key NotesField = "Notes" - // PasswordField is where the password is stored - PasswordField = "Password" - // URLField is the URL field in the kdbx - URLField = "URL" ) type ( diff --git a/internal/kdbx/core_test.go b/internal/kdbx/core_test.go @@ -2,11 +2,25 @@ package kdbx_test import ( "errors" + "fmt" + "slices" + "strings" "testing" "git.sr.ht/~enckse/lockbox/internal/kdbx" ) +func TestAllowedSort(t *testing.T) { + set := fmt.Sprintf("%v", kdbx.AllowedFields) + have := kdbx.AllowedFields + slices.SortFunc(have, func(x, y string) int { + return strings.Compare(strings.ToLower(x), strings.ToLower(y)) + }) + if fmt.Sprintf("%v", have) != set { + t.Error("allowed fields has incorrect sort") + } +} + func TestLoad(t *testing.T) { if _, err := kdbx.Load(" "); err.Error() != "no store set" { t.Errorf("invalid error: %v", err)