config: add --obscure and --no-obscure flags to config create/update

Before this change there was some ambiguity about whether passwords
were obscured on not passing them into config create or config update.

This change adds the --obscure and --no-obscure flags to make the
intent clear.

It also updates the remote control and the tests.

Fixes #3728
This commit is contained in:
Nick Craig-Wood
2020-05-12 14:24:53 +01:00
parent c4bc249b66
commit 98c34e413d
5 changed files with 107 additions and 53 deletions

View File

@@ -101,11 +101,12 @@ func TestRc(t *testing.T) {
t.Run("Password", func(t *testing.T) {
call := rc.Calls.Get("config/password")
assert.NotNil(t, call)
pw2 := obscure.MustObscure("password")
in := rc.Params{
"name": testName,
"parameters": rc.Params{
"test_key": "rutabaga",
"test_key2": "cabbage",
"test_key2": pw2, // check we encode an already encoded password
},
}
out, err := call.Fn(context.Background(), in)
@@ -114,7 +115,7 @@ func TestRc(t *testing.T) {
assert.Equal(t, "local", config.FileGet(testName, "type"))
assert.Equal(t, "rutabaga", obscure.MustReveal(config.FileGet(testName, "test_key")))
assert.Equal(t, "cabbage", obscure.MustReveal(config.FileGet(testName, "test_key2")))
assert.Equal(t, pw2, obscure.MustReveal(config.FileGet(testName, "test_key2")))
})
// Delete the test remote