@@ -72,6 +72,25 @@ test_config_cmd() {
72
72
grep "\"beep3\": false," actual
73
73
'
74
74
75
+ test_expect_success " setup for config replace test" '
76
+ cp "$IPFS_PATH/config" newconfig.json &&
77
+ sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json &&
78
+ sed -i"~" -e ' " '" ' /PeerID/ {' " '" ' -e ' " '" ' s/,$// ' " '" ' -e ' " '" ' } ' " '" ' newconfig.json
79
+ '
80
+
81
+ test_expect_success " run 'ipfs config replace'" '
82
+ ipfs config replace - < newconfig.json
83
+ '
84
+
85
+ test_expect_success " check resulting config after 'ipfs config replace'" '
86
+ sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json &&
87
+ sed -i"~" -e ' " '" ' /PeerID/ {' " '" ' -e ' " '" ' s/,$// ' " '" ' -e ' " '" ' } ' " '" ' replconfig.json &&
88
+ test_cmp replconfig.json newconfig.json
89
+ '
90
+
91
+ # SECURITY
92
+ # Those tests are here to prevent exposing the PrivKey on the network
93
+
75
94
test_expect_success " 'ipfs config Identity' fails" '
76
95
test_expect_code 1 ipfs config Identity 2> ident_out
77
96
'
@@ -81,8 +100,6 @@ test_config_cmd() {
81
100
test_cmp ident_exp ident_out
82
101
'
83
102
84
- # SECURITY
85
- # Those tests are here to prevent exposing the PrivKey on the network
86
103
test_expect_success " 'ipfs config Identity.PrivKey' fails" '
87
104
test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
88
105
'
@@ -92,7 +109,7 @@ test_config_cmd() {
92
109
'
93
110
94
111
test_expect_success " lower cased PrivKey" '
95
- sed -i -e ' \' ' s/PrivKey/privkey/' \' ' "$IPFS_PATH/config" &&
112
+ sed -i"~" -e ' \' ' s/PrivKey/privkey/' \' ' "$IPFS_PATH/config" &&
96
113
test_expect_code 1 ipfs config Identity.privkey 2> ident_out
97
114
'
98
115
@@ -101,7 +118,7 @@ test_config_cmd() {
101
118
'
102
119
103
120
test_expect_success " fix it back" '
104
- sed -i -e ' \' ' s/privkey/PrivKey/' \' ' "$IPFS_PATH/config"
121
+ sed -i"~" -e ' \' ' s/privkey/PrivKey/' \' ' "$IPFS_PATH/config"
105
122
'
106
123
107
124
test_expect_success " 'ipfs config show' doesn't include privkey" '
0 commit comments