mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
cmd: include case where PrivKey is stored in lower case
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
repo "github.com/ipfs/go-ipfs/repo"
|
||||
@ -59,8 +60,8 @@ Set the value of the 'datastore.path' key:
|
||||
key := args[0]
|
||||
|
||||
// This is a temporary fix until we move the private key out of the config file
|
||||
switch key {
|
||||
case "Identity", "Identity.PrivKey":
|
||||
switch strings.ToLower(key) {
|
||||
case "identity", "identity.privkey":
|
||||
res.SetError(fmt.Errorf("cannot show or change private key through API"), cmds.ErrNormal)
|
||||
return
|
||||
default:
|
||||
|
@ -87,10 +87,19 @@ test_config_cmd() {
|
||||
test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
|
||||
'
|
||||
|
||||
test_expect_success "lower cased PrivKey" '
|
||||
sed -i -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
|
||||
test_expect_code 1 ipfs config Identity.privkey 2> ident_out
|
||||
'
|
||||
|
||||
test_expect_success "output looks good" '
|
||||
test_cmp ident_exp ident_out
|
||||
'
|
||||
|
||||
test_expect_success "fix it back" '
|
||||
sed -i -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config"
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs config show' doesn't include privkey" '
|
||||
ipfs config show > show_config &&
|
||||
test_expect_code 1 grep PrivKey show_config
|
||||
|
Reference in New Issue
Block a user