@cryptotaxi247 / kubo / commits / ea9327dd3

test/sharness: add more tests against exposing PrivKey on network

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

Jakub Sztandera committed Jul 8, 2016 at 16:42 UTC ea9327dd3c6161545c2eccd892a99843cc4cc2e0
1 file changed +13 -1
test/sharness/t0021-config.sh
+13 -1
@@ -77,10 +77,12 @@ test_config_cmd() {
77 '
78
79 test_expect_success "output looks good" '
80 - echo "Error: cannot show private key through API" > ident_exp &&
80 + echo "Error: cannot show or change private key through API" > ident_exp &&
81 test_cmp ident_exp ident_out
82 '
83
84 + # SECURITY
85 + # Those tests are here to prevent exposing the PrivKey on the network
86 test_expect_success "'ipfs config Identity.PrivKey' fails" '
87 test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
88 '
@@ -88,6 +90,16 @@ test_config_cmd() {
90 test_expect_success "output looks good" '
91 test_cmp ident_exp ident_out
92 '
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"
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
102 + '
103 }
104
105 test_init_ipfs