config: factor Obscure and Reveal into its own package
This commit is contained in:
+3
-2
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/Unknwon/goconfig"
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/fs/accounting"
|
||||
"github.com/ncw/rclone/fs/config/obscure"
|
||||
"github.com/ncw/rclone/fs/driveletter"
|
||||
"github.com/ncw/rclone/fs/fshttp"
|
||||
"github.com/pkg/errors"
|
||||
@@ -694,7 +695,7 @@ func ChooseOption(o *fs.Option) string {
|
||||
default:
|
||||
fs.Errorf(nil, "Bad choice %c", i)
|
||||
}
|
||||
return MustObscure(password)
|
||||
return obscure.MustObscure(password)
|
||||
}
|
||||
if len(o.Examples) > 0 {
|
||||
var values []string
|
||||
@@ -749,7 +750,7 @@ func PasswordRemote(name string, keyValues []string) error {
|
||||
}
|
||||
// Suppress Confirm
|
||||
fs.Config.AutoConfirm = true
|
||||
passwd := MustObscure(keyValues[1])
|
||||
passwd := obscure.MustObscure(keyValues[1])
|
||||
if passwd != "" {
|
||||
configData.SetValue(name, keyValues[0], passwd)
|
||||
RemoteConfig(name)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/fs/config/obscure"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -89,7 +90,7 @@ func TestReveal(t *testing.T) {
|
||||
{"aGVsbG8", "input too short when revealing password - is it obscured?"},
|
||||
{"", "input too short when revealing password - is it obscured?"},
|
||||
} {
|
||||
gotString, gotErr := Reveal(test.in)
|
||||
gotString, gotErr := obscure.Reveal(test.in)
|
||||
assert.Equal(t, "", gotString)
|
||||
assert.Equal(t, test.wantErr, gotErr.Error())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Obscure and Reveal config values
|
||||
|
||||
package config
|
||||
// Package obscure contains the Obscure and Reveal commands
|
||||
package obscure
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package config
|
||||
package obscure
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
Reference in New Issue
Block a user