1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-27 16:07:42 +08:00

core/commands/config: error out if config replace contains privkey

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera
2016-07-08 16:51:35 +02:00
parent ea9327dd3c
commit 2b682f95d0
2 changed files with 15 additions and 1 deletions

View File

@ -273,7 +273,10 @@ func editConfig(filename string) error {
func replaceConfig(r repo.Repo, file io.Reader) error {
var cfg config.Config
if err := json.NewDecoder(file).Decode(&cfg); err != nil {
return errors.New("Failed to decode file as config")
return errors.New("failed to decode file as config")
}
if len(cfg.Identity.PrivKey) != 0 {
return errors.New("setting private key with API is not supported")
}
keyF, err := getConfig(r, "Identity.PrivKey")

View File

@ -100,6 +100,17 @@ test_config_cmd() {
ipfs config replace show_config &&
grep PrivKey "$IPFS_PATH/config" | grep -v ": null" >/dev/null
'
test_expect_success "'ipfs config replace' with privkey erors out" '
cp "$IPFS_PATH/config" real_config &&
test_expect_code 1 ipfs config replace - < real_config 2> replace_out
'
test_expect_success "output looks good" '
echo "Error: setting private key with API is not supported" > replace_expected
test_cmp replace_out replace_expected
'
}
test_init_ipfs