commit 57f6556afa385bdb16db5ff95b90ad1b2b391415
parent cd7803da9af4062ffad227d0d9fadc1e20dcfbe9
Author: Sean Enck <sean@ttypty.com>
Date: Fri, 6 Dec 2024 23:18:46 -0500
change yes/no -> true/false
Diffstat:
11 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/internal/app/list_test.go b/internal/app/list_test.go
@@ -24,7 +24,7 @@ func fullSetup(t *testing.T, keep bool) *backend.Transaction {
if !keep {
os.Remove(file)
}
- t.Setenv("LOCKBOX_READONLY", "no")
+ t.Setenv("LOCKBOX_READONLY", "false")
t.Setenv("LOCKBOX_STORE", file)
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "test")
t.Setenv("LOCKBOX_CREDENTIALS_KEY_FILE", "")
diff --git a/internal/app/pwgen_test.go b/internal/app/pwgen_test.go
@@ -49,7 +49,7 @@ func TestGenerateError(t *testing.T) {
if err := app.GeneratePassword(m); err != nil {
t.Errorf("invalid error: %v", err)
}
- t.Setenv("LOCKBOX_PWGEN_ENABLED", "no")
+ t.Setenv("LOCKBOX_PWGEN_ENABLED", "false")
if err := app.GeneratePassword(m); err == nil || err.Error() != "password generation is disabled" {
t.Errorf("invalid error: %v", err)
}
@@ -75,7 +75,7 @@ func TestGenerate(t *testing.T) {
t.Setenv("LOCKBOX_PWGEN_WORDS_COMMAND", fmt.Sprintf("%s 1 1 1 1 1 1 1 1 1 1 1 1", pwgenPath))
testPasswordGen(t, "1-1-1-1-1-1-1-1-1-1")
t.Setenv("LOCKBOX_PWGEN_WORD_COUNT", "4")
- t.Setenv("LOCKBOX_PWGEN_TITLE", "yes")
+ t.Setenv("LOCKBOX_PWGEN_TITLE", "true")
t.Setenv("LOCKBOX_PWGEN_WORDS_COMMAND", fmt.Sprintf("%s a a a a a a a a a a a a a a a", pwgenPath))
testPasswordGen(t, "A-A-A-A")
t.Setenv("LOCKBOX_PWGEN_CHARACTERS", "bc")
@@ -83,8 +83,8 @@ func TestGenerate(t *testing.T) {
testPasswordGen(t, "Bc-Bc-Bc-Bc")
os.Unsetenv("LOCKBOX_PWGEN_CHARACTERS")
t.Setenv("LOCKBOX_PWGEN_WORDS_COMMAND", fmt.Sprintf("%s a a a a a a a a a a a a a a a", pwgenPath))
- t.Setenv("LOCKBOX_PWGEN_TITLE", "no")
- t.Setenv("LOCKBOX_PWGEN_TITLE", "no")
+ t.Setenv("LOCKBOX_PWGEN_TITLE", "false")
+ t.Setenv("LOCKBOX_PWGEN_TITLE", "false")
testPasswordGen(t, "a-a-a-a")
// NOTE: this allows templating below in golang
t.Setenv("DOLLAR", "$")
@@ -93,7 +93,7 @@ func TestGenerate(t *testing.T) {
t.Setenv("LOCKBOX_PWGEN_TEMPLATE", "{{range [%]idx, [%]val := .}}{{if lt [%]idx 5}}-{{end}}{{ [%]val.Text }}{{end}}")
testPasswordGen(t, "-a-a-a-a")
os.Unsetenv("LOCKBOX_PWGEN_TEMPLATE")
- t.Setenv("LOCKBOX_PWGEN_TITLE", "yes")
+ t.Setenv("LOCKBOX_PWGEN_TITLE", "true")
t.Setenv("LOCKBOX_PWGEN_WORDS_COMMAND", fmt.Sprintf("%s abc axy axY aZZZ aoijafea aoiajfoea afaeoa", pwgenPath))
m := newMockCommand(t)
if err := app.GeneratePassword(m); err != nil {
diff --git a/internal/app/totp_test.go b/internal/app/totp_test.go
@@ -43,7 +43,7 @@ func fullTOTPSetup(t *testing.T, keep bool) *backend.Transaction {
if !keep {
os.Remove(file)
}
- t.Setenv("LOCKBOX_READONLY", "no")
+ t.Setenv("LOCKBOX_READONLY", "false")
t.Setenv("LOCKBOX_STORE", file)
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "test")
t.Setenv("LOCKBOX_CREDENTIALS_KEY_FILE", "")
diff --git a/internal/backend/actions_test.go b/internal/backend/actions_test.go
@@ -27,7 +27,7 @@ func fullSetup(t *testing.T, keep bool) *backend.Transaction {
if !keep {
os.Remove(file)
}
- t.Setenv("LOCKBOX_READONLY", "no")
+ t.Setenv("LOCKBOX_READONLY", "false")
t.Setenv("LOCKBOX_STORE", file)
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "test")
t.Setenv("LOCKBOX_CREDENTIALS_KEY_FILE", "")
@@ -47,7 +47,7 @@ func TestKeyFile(t *testing.T) {
file := testFile("keyfile_test.kdbx")
keyFile := testFile("file.key")
os.Remove(file)
- t.Setenv("LOCKBOX_READONLY", "no")
+ t.Setenv("LOCKBOX_READONLY", "false")
t.Setenv("LOCKBOX_STORE", file)
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "test")
t.Setenv("LOCKBOX_CREDENTIALS_KEY_FILE", keyFile)
@@ -71,7 +71,7 @@ func setup(t *testing.T) *backend.Transaction {
func TestNoWriteOnRO(t *testing.T) {
setup(t)
- t.Setenv("LOCKBOX_READONLY", "yes")
+ t.Setenv("LOCKBOX_READONLY", "true")
tr, _ := backend.NewTransaction()
if err := tr.Insert("a/a/a", "a"); err.Error() != "unable to alter database in readonly mode" {
t.Errorf("wrong error: %v", err)
@@ -317,7 +317,7 @@ func TestReKey(t *testing.T) {
f := "rekey_test.kdbx"
file := testFile(f)
defer os.Remove(filepath.Join(testDir, f))
- t.Setenv("LOCKBOX_READONLY", "no")
+ t.Setenv("LOCKBOX_READONLY", "false")
t.Setenv("LOCKBOX_STORE", file)
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "test")
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD_MODE", "plaintext")
diff --git a/internal/backend/hooks_test.go b/internal/backend/hooks_test.go
@@ -59,7 +59,7 @@ func TestHooks(t *testing.T) {
if err := h.Run(backend.HookPre); strings.Contains("fork/exec", err.Error()) {
t.Errorf("wrong error: %v", err)
}
- t.Setenv("LOCKBOX_HOOKS_ENABLED", "no")
+ t.Setenv("LOCKBOX_HOOKS_ENABLED", "false")
h, err = backend.NewHook("a", backend.InsertAction)
if err != nil {
t.Errorf("invalid error: %v", err)
diff --git a/internal/config/core.go b/internal/config/core.go
@@ -20,8 +20,8 @@ const (
colorWindowDelimiter = " "
colorWindowSpan = ":"
exampleColorWindow = "start" + colorWindowSpan + "end"
- yes = "yes"
- no = "no"
+ yes = "true"
+ no = "false"
detectEnvironment = "detect"
noEnvironment = "none"
tomlFile = "lockbox.toml"
@@ -49,7 +49,7 @@ var (
configDirOffsetFile = filepath.Join(configDirName, tomlFile)
xdgPaths = []string{configDirOffsetFile, tomlFile}
homePaths = []string{filepath.Join(configDir, configDirOffsetFile), filepath.Join(configDir, tomlFile)}
- exampleColorWindows = []string{strings.Join([]string{exampleColorWindow, exampleColorWindow, exampleColorWindow + "..."}, colorWindowDelimiter)}
+ exampleColorWindows = []string{fmt.Sprintf("[%s]", strings.Join([]string{exampleColorWindow, exampleColorWindow, exampleColorWindow + "..."}, colorWindowDelimiter))}
registry = map[string]printer{}
)
diff --git a/internal/config/key_test.go b/internal/config/key_test.go
@@ -46,13 +46,13 @@ func TestNewKeyErrors(t *testing.T) {
if _, err := config.NewKey(config.IgnoreKeyMode); err == nil || err.Error() != "key MUST be set in this key mode" {
t.Errorf("invalid error: %v", err)
}
- t.Setenv("LOCKBOX_INTERACTIVE", "yes")
+ t.Setenv("LOCKBOX_INTERACTIVE", "true")
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD_MODE", "ask")
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "")
if _, err := config.NewKey(config.IgnoreKeyMode); err != nil {
t.Errorf("invalid error: %v", err)
}
- t.Setenv("LOCKBOX_INTERACTIVE", "no")
+ t.Setenv("LOCKBOX_INTERACTIVE", "false")
if _, err := config.NewKey(config.IgnoreKeyMode); err == nil || err.Error() != "ask key mode requested in non-interactive mode" {
t.Errorf("invalid error: %v", err)
}
@@ -67,14 +67,14 @@ func TestAskKey(t *testing.T) {
}
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD_MODE", "ask")
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "")
- t.Setenv("LOCKBOX_INTERACTIVE", "no")
+ t.Setenv("LOCKBOX_INTERACTIVE", "false")
k, _ = config.NewKey(config.IgnoreKeyMode)
if k.Ask() {
t.Error("invalid ask key")
}
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD_MODE", "ask")
t.Setenv("LOCKBOX_CREDENTIALS_PASSWORD", "")
- t.Setenv("LOCKBOX_INTERACTIVE", "yes")
+ t.Setenv("LOCKBOX_INTERACTIVE", "true")
k, _ = config.NewKey(config.IgnoreKeyMode)
if !k.Ask() {
t.Error("invalid ask key")
diff --git a/internal/config/toml_test.go b/internal/config/toml_test.go
@@ -194,7 +194,7 @@ enabled = true
if err != nil {
t.Errorf("invalid error: %v", err)
}
- if len(env) != 1 || env[0].Key != "LOCKBOX_TOTP_ENABLED" || env[0].Value != "yes" {
+ if len(env) != 1 || env[0].Key != "LOCKBOX_TOTP_ENABLED" || env[0].Value != "true" {
t.Errorf("invalid object: %v", env)
}
data = `include = []
@@ -208,7 +208,7 @@ enabled = false
if err != nil {
t.Errorf("invalid error: %v", err)
}
- if len(env) != 1 || env[0].Key != "LOCKBOX_TOTP_ENABLED" || env[0].Value != "no" {
+ if len(env) != 1 || env[0].Key != "LOCKBOX_TOTP_ENABLED" || env[0].Value != "false" {
t.Errorf("invalid object: %v", env)
}
}
diff --git a/internal/config/vars_test.go b/internal/config/vars_test.go
@@ -9,7 +9,7 @@ import (
)
func checkYesNo(key string, t *testing.T, obj config.EnvironmentBool, onEmpty bool) {
- t.Setenv(key, "yes")
+ t.Setenv(key, "true")
c, err := obj.Get()
if err != nil {
t.Errorf("invalid error: %v", err)
@@ -25,7 +25,7 @@ func checkYesNo(key string, t *testing.T, obj config.EnvironmentBool, onEmpty bo
if c != onEmpty {
t.Error("invalid setting")
}
- t.Setenv(key, "no")
+ t.Setenv(key, "false")
c, err = obj.Get()
if err != nil {
t.Errorf("invalid error: %v", err)
@@ -221,11 +221,11 @@ func TestCanColor(t *testing.T) {
} {
os.Clearenv()
key := fmt.Sprintf("LOCKBOX_%s", raw)
- t.Setenv(key, "yes")
+ t.Setenv(key, "true")
if can, _ := config.CanColor(); can != expect {
t.Errorf("expect != actual: %s", key)
}
- t.Setenv(key, "no")
+ t.Setenv(key, "false")
if can, _ := config.CanColor(); can == expect {
t.Errorf("expect == actual: %s", key)
}
diff --git a/internal/platform/clipboard_test.go b/internal/platform/clipboard_test.go
@@ -9,9 +9,9 @@ import (
)
func TestNoClipboard(t *testing.T) {
- t.Setenv("LOCKBOX_CLIP_OSC52", "no")
+ t.Setenv("LOCKBOX_CLIP_OSC52", "false")
t.Setenv("LOCKBOX_CLIP_TIMEOUT", "")
- t.Setenv("LOCKBOX_CLIP_ENABLED", "no")
+ t.Setenv("LOCKBOX_CLIP_ENABLED", "false")
_, err := platform.NewClipboard()
if err == nil || err.Error() != "clipboard is off" {
t.Errorf("invalid error: %v", err)
@@ -19,8 +19,8 @@ func TestNoClipboard(t *testing.T) {
}
func TestMaxTime(t *testing.T) {
- t.Setenv("LOCKBOX_CLIP_ENABLED", "yes")
- t.Setenv("LOCKBOX_CLIP_OSC52", "no")
+ t.Setenv("LOCKBOX_CLIP_ENABLED", "true")
+ t.Setenv("LOCKBOX_CLIP_OSC52", "false")
t.Setenv("LOCKBOX_PLATFORM", string(config.Platforms.LinuxWaylandPlatform))
t.Setenv("LOCKBOX_CLIP_TIMEOUT", "")
c, err := platform.NewClipboard()
@@ -51,9 +51,9 @@ func TestMaxTime(t *testing.T) {
}
func TestClipboardInstances(t *testing.T) {
- t.Setenv("LOCKBOX_CLIP_ENABLED", "yes")
+ t.Setenv("LOCKBOX_CLIP_ENABLED", "true")
t.Setenv("LOCKBOX_CLIP_TIMEOUT", "")
- t.Setenv("LOCKBOX_CLIP_OSC52", "no")
+ t.Setenv("LOCKBOX_CLIP_OSC52", "false")
for _, item := range config.Platforms.List() {
t.Setenv("LOCKBOX_PLATFORM", item)
_, err := platform.NewClipboard()
@@ -64,7 +64,7 @@ func TestClipboardInstances(t *testing.T) {
}
func TestOSC52(t *testing.T) {
- t.Setenv("LOCKBOX_CLIP_OSC52", "yes")
+ t.Setenv("LOCKBOX_CLIP_OSC52", "true")
c, _ := platform.NewClipboard()
_, _, ok := c.Args(true)
if ok {
@@ -78,7 +78,7 @@ func TestOSC52(t *testing.T) {
func TestArgsOverride(t *testing.T) {
t.Setenv("LOCKBOX_CLIP_PASTE_COMMAND", "abc xyz 111")
- t.Setenv("LOCKBOX_CLIP_OSC52", "no")
+ t.Setenv("LOCKBOX_CLIP_OSC52", "false")
t.Setenv("LOCKBOX_PLATFORM", string(config.Platforms.WindowsLinuxPlatform))
c, _ := platform.NewClipboard()
cmd, args, ok := c.Args(true)
diff --git a/tests/run.sh b/tests/run.sh
@@ -62,8 +62,8 @@ printf "%-10s ... " "$1"
export LOCKBOX_HOOKS_DIRECTORY=""
export LOCKBOX_STORE="${DATA}/passwords.kdbx"
export LOCKBOX_TOTP_ENTRY=totp
- export LOCKBOX_INTERACTIVE=no
- export LOCKBOX_READONLY=no
+ export LOCKBOX_INTERACTIVE=false
+ export LOCKBOX_READONLY=false
if [ "$LOCKBOX_CREDENTIALS_PASSWORD" = "" ]; then
export LOCKBOX_CREDENTIALS_PASSWORD_MODE=none
else
@@ -74,7 +74,7 @@ printf "%-10s ... " "$1"
OLDMODE="$LOCKBOX_CREDENTIALS_PASSWORD_MODE"
OLDKEY="$LOCKBOX_CREDENTIALS_PASSWORD"
if [ "$OLDKEY" != "" ]; then
- export LOCKBOX_INTERACTIVE=yes
+ export LOCKBOX_INTERACTIVE=true
export LOCKBOX_CREDENTIALS_PASSWORD_MODE=ask
export LOCKBOX_CREDENTIALS_PASSWORD=""
else
@@ -82,7 +82,7 @@ printf "%-10s ... " "$1"
fi
echo "$OLDKEY" | ${LB_BINARY} ls 2>/dev/null
if [ "$OLDKEY" != "" ]; then
- export LOCKBOX_INTERACTIVE=no
+ export LOCKBOX_INTERACTIVE=false
export LOCKBOX_CREDENTIALS_PASSWORD_MODE="$OLDMODE"
export LOCKBOX_CREDENTIALS_PASSWORD="$OLDKEY"
fi