@cryptotaxi247 / kubo / commits / 6b9758826

cmd: include case where PrivKey is stored in lower case

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Jul 13, 2016 at 18:44 UTC 6b97588266e53ba63586dba8a6bd7489d654d1fa
2 files changed +12 -2
core/commands/config.go
+3 -2
@@ -9,6 +9,7 @@ import (
9 "io/ioutil"
10 "os"
11 "os/exec"
12 + "strings"
13
14 cmds "github.com/ipfs/go-ipfs/commands"
15 repo "github.com/ipfs/go-ipfs/repo"
@@ -59,8 +60,8 @@ Set the value of the 'datastore.path' key:
60 key := args[0]
61
62 // This is a temporary fix until we move the private key out of the config file
62 - switch key {
63 - case "Identity", "Identity.PrivKey":
63 + switch strings.ToLower(key) {
64 + case "identity", "identity.privkey":
65 res.SetError(fmt.Errorf("cannot show or change private key through API"), cmds.ErrNormal)
66 return
67 default:
test/sharness/t0021-config.sh
+9
@@ -87,10 +87,19 @@ test_config_cmd() {
87 test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
88 '
89
90 + test_expect_success "lower cased PrivKey" '
91 + sed -i -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
92 + test_expect_code 1 ipfs config Identity.privkey 2> ident_out
93 + '
94 +
95 test_expect_success "output looks good" '
96 test_cmp ident_exp ident_out
97 '
98
99 + test_expect_success "fix it back" '
100 + sed -i -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config"
101 + '
102 +
103 test_expect_success "'ipfs config show' doesn't include privkey" '
104 ipfs config show > show_config &&
105 test_expect_code 1 grep PrivKey show_config