@cryptotaxi247 / kubo / commits / 2fded41ff

core/commands: do not show PrivKey in config if it is null

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

Jakub Sztandera committed Jul 8, 2016 at 23:21 UTC 2fded41ff534b79c493e7a1734000f388ba3d144
3 files changed +4 -4
core/commands/config.go
+1 -1
@@ -161,7 +161,7 @@ included in the output of this command.
161 return
162 }
163
164 - cfg["Identity"].(map[string]interface{})["PrivKey"] = nil
164 + delete(cfg["Identity"].(map[string]interface{}), "PrivKey")
165
166 output, err := config.HumanOutput(cfg)
167 if err != nil {
repo/config/identity.go
+1 -1
@@ -8,7 +8,7 @@ import (
8 // Identity tracks the configuration of the local node's identity.
9 type Identity struct {
10 PeerID string
11 - PrivKey string
11 + PrivKey string `json:",omitempty"`
12 }
13
14 // DecodePrivateKey is a helper to decode the users PrivateKey
test/sharness/t0021-config.sh
+2 -2
@@ -93,12 +93,12 @@ test_config_cmd() {
93
94 test_expect_success "'ipfs config show' doesn't include privkey" '
95 ipfs config show > show_config &&
96 - grep PrivKey show_config | grep "\"PrivKey\": null"
96 + test_expect_code 1 grep PrivKey show_config
97 '
98
99 test_expect_success "'ipfs config replace' injects privkey back" '
100 ipfs config replace show_config &&
101 - grep PrivKey "$IPFS_PATH/config" | grep -v ": null" >/dev/null
101 + grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".*\"" >/dev/null
102 '
103
104 test_expect_success "'ipfs config replace' with privkey erors out" '