lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 3bb07d2fe41caf6143c14b9f25e72b7f6fb9531c
parent 0f3c9ca0edd6796095bd39869416b53fa71f051c
Author: Sean Enck <sean@ttypty.com>
Date:   Sat, 16 Jul 2022 17:51:46 -0400

improve this test

Diffstat:
Minternal/encrypt/core_test.go | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/internal/encrypt/core_test.go b/internal/encrypt/core_test.go @@ -1,6 +1,7 @@ package encrypt import ( + "fmt" "os" "path/filepath" "testing" @@ -51,7 +52,18 @@ func TestEmptyKey(t *testing.T) { if err == nil || err.Error() != "key is empty" { t.Errorf("invalid error: %v", err) } - _, err = NewLockbox(LockboxOptions{KeyMode: CommandKeyMode, Key: "echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}) +} + +func TestKeyLength(t *testing.T) { + val := "" + for i := 0; i < 32; i++ { + val = fmt.Sprintf("a%s", val) + _, err := NewLockbox(LockboxOptions{KeyMode: PlainKeyMode, Key: val}) + if err != nil { + t.Error("no error expected") + } + } + _, err := NewLockbox(LockboxOptions{KeyMode: PlainKeyMode, Key: fmt.Sprintf("%sa", val)}) if err == nil || err.Error() != "key is too large for use" { t.Errorf("invalid error: %v", err) }