Skip to content

Commit

Permalink
[BUGFIX] Use 'en' as default language for the xkcd generator (#2793)
Browse files Browse the repository at this point in the history
* [BUGFIX] Use 'en' as default language for the xkcd generator

Fixes #2792

Signed-off-by: Yolan Romailler <[email protected]>

* [n/a] massaging integration tests

Signed-off-by: Yolan Romailler <[email protected]>

---------

Signed-off-by: Yolan Romailler <[email protected]>
  • Loading branch information
AnomalRoil authored Feb 10, 2024
1 parent 14ae67f commit d3c64f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
10 changes: 7 additions & 3 deletions internal/action/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ core.nopager = true
core.notifications = true
generate.autoclip = true
`
want += "mounts.path = " + u.StoreDir("") + "\n"
want += "mounts.path = " + u.StoreDir("") + "\n" +
"pwgen.xkcd-lang = en\n"
assert.Equal(t, want, buf.String())
})

Expand Down Expand Up @@ -87,8 +88,10 @@ core.nopager = true
core.notifications = true
generate.autoclip = true
`
want += "mounts.path = " + u.StoreDir("")
assert.Equal(t, want, strings.TrimSpace(buf.String()), "action.printConfigValues")
want += "mounts.path = " + u.StoreDir("") + "\n" +
"pwgen.xkcd-lang = en\n"

assert.Equal(t, want, buf.String(), "action.printConfigValues")
})

t.Run("show autoimport value", func(t *testing.T) {
Expand Down Expand Up @@ -120,6 +123,7 @@ core.nopager
core.notifications
generate.autoclip
mounts.path
pwgen.xkcd-lang
`
assert.Equal(t, want, buf.String())
})
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var defaults = map[string]string{
"core.cliptimeout": "45",
"core.exportkeys": "true",
"core.notifications": "true",
"pwgen.xkcd-lang": "en",
}

// Config is a gopass config handler.
Expand Down
12 changes: 9 additions & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ func TestConfig(t *testing.T) {
require.NoError(t, cfg.SetEnv("env.string", "foo"))
assert.Equal(t, "foo", cfg.Get("env.string"))

assert.Equal(t, []string{"core.autopush", "core.autosync", "core.bool", "core.cliptimeout", "core.exportkeys", "core.int", "core.notifications", "core.string", "env.string", "mounts.path"}, cfg.Keys(""))
// test default values
assert.Equal(t, []string{"core.autopush", "core.autosync", "core.bool", "core.cliptimeout", "core.exportkeys", "core.int", "core.notifications", "core.string", "env.string", "mounts.path", "pwgen.xkcd-lang"}, cfg.Keys(""))
for key, expected := range defaults {
assert.Equal(t, expected, cfg.Get(key))
}
require.NoError(t, cfg.Set("", "pwgen.xkcd-lang", "de"))
assert.Equal(t, "de", cfg.Get("pwgen.xkcd-lang"))

ctx := cfg.WithConfig(context.Background())
assert.True(t, Bool(ctx, "core.bool"))
assert.Equal(t, "foo", String(ctx, "core.string"))
assert.Equal(t, 42, Int(ctx, "core.int"))

require.NoError(t, cfg.SetEnv("generate.length", "16"))
actual_length, _ := DefaultPasswordLengthFromEnv(ctx)
assert.Equal(t, 16, actual_length)
actualLength, _ := DefaultPasswordLengthFromEnv(ctx)
assert.Equal(t, 16, actualLength)
}

func TestEnvConfig(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion tests/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ core.cliptimeout = 45
core.exportkeys = false
core.notifications = true
`
wanted += "mounts.path = " + ts.storeDir("root")
wanted += "mounts.path = " + ts.storeDir("root") + "\n" +
"pwgen.xkcd-lang = en"

assert.Equal(t, wanted, out)

Expand Down Expand Up @@ -74,6 +75,7 @@ core.notifications = true
`
wanted += "mounts.mnt/m1.path = " + ts.storeDir("m1") + "\n"
wanted += "mounts.path = " + ts.storeDir("root") + "\n"
wanted += "pwgen.xkcd-lang = en\n"
wanted += "recipients.mnt/m1.hash = 9a4c4b1e0eb9ade2e692ff948f43d9668145eca3df88ffff67e0e21426252907\n"

out, err := ts.run("config")
Expand Down

0 comments on commit d3c64f2

Please sign in to comment.