mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* [CLEANUP] Moving options to the correct config section This adds an easy migration path to our config handling, which should allow us to migrate option names around much more easily in the future. Any system level config or env variables options are not migrated. This also fixes a bug in our test code, where the root mount path was not properly set in our config, because we used "path:" instead of "path=" to set it. Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [DOCUMENTATION] Document legacy options and their migration path This also makes sure that legacy options aren't used in the code anymore using the docs test and its regexp Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [n/a] Removing weird spaces from changelog Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [DOCUMENTATION] Reformatting our Markdown tables properly Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [TESTING] Patching a timezone bug in tests This is a fun one where if your Timezone isn't UTC and you are past midnight but it's not past midnight UTC, the tests would fail because you're not using the right date to validate it. Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [n/a] Fix a typo and use the correct Env variables in the doc about the custom Env variables Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [BREAKING] Custom Env options moved from GOPASS_CONFIG_CONFIG_KEY_i to GOPASS_CONFIG_KEY_i As discussed in #2617, this actually reflects the way GIT_CONFIG works. It also fixes a potential Panic in our codebase when IsSet was called without any Preset config on a non-existing key. Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [CLEANUP] Patching all of the new linter complaints Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [CLEANUP] Use Go1.21 everywhere Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [n/a] Increase our Golangci timeout Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> * [n/a] code review comment and extra regression test Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com> --------- Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package tests
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMove(t *testing.T) {
|
|
ts := newTester(t)
|
|
defer ts.teardown()
|
|
|
|
t.Run("move before init", func(t *testing.T) {
|
|
_, err := ts.run("move")
|
|
require.Error(t, err)
|
|
})
|
|
|
|
// init store so it does exist, but empty so far
|
|
ts.initStore()
|
|
|
|
t.Run("move w/o args", func(t *testing.T) {
|
|
out, err := ts.run("move")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "\nError: Usage: "+filepath.Base(ts.Binary)+" mv old-path new-path\n", out)
|
|
})
|
|
|
|
t.Run("move w/o destination", func(t *testing.T) {
|
|
out, err := ts.run("move foo")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "\nError: Usage: "+filepath.Base(ts.Binary)+" mv old-path new-path\n", out)
|
|
})
|
|
|
|
t.Run("move non existing source", func(t *testing.T) {
|
|
out, err := ts.run("move foo bar")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "\nError: source foo does not exist in source store : entry is not in the password store\n", out)
|
|
})
|
|
|
|
// populate store with secrets
|
|
ts.initSecrets("")
|
|
|
|
t.Run("move a secret", func(t *testing.T) {
|
|
_, err := ts.run("move foo bar")
|
|
require.NoError(t, err)
|
|
})
|
|
|
|
t.Run("move existing secret from non-existing destination", func(t *testing.T) {
|
|
out, _ := ts.run("move foo/bar foo/baz")
|
|
assert.Equal(t, "\nError: source foo/bar does not exist in source store : entry is not in the password store\n", out)
|
|
})
|
|
|
|
t.Run("show source secret", func(t *testing.T) {
|
|
_, err := ts.run("show -f bar/bar")
|
|
require.NoError(t, err)
|
|
})
|
|
|
|
t.Run("show secret", func(t *testing.T) {
|
|
_, err := ts.run("show -f baz")
|
|
require.NoError(t, err)
|
|
})
|
|
}
|