From 077948ab38f70efeab4314e391e1a48d9c3798f3 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 11 Aug 2016 13:39:53 +0200 Subject: [PATCH 1/8] sharness: add test for 'ipfs config replace' License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 1fc35e176..223a6c9ae 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -72,6 +72,19 @@ test_config_cmd() { grep "\"beep3\": false," actual ' + test_expect_success "'ipfs config replace' works" ' + cp "$IPFS_PATH/config" newconfig.json && + sed -i -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && + sed -i '"'"'/PeerID/ { s/,$// } '"'"' newconfig.json && + ipfs config replace - < newconfig.json && + sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && + sed -i -e'"'"'/PeerID/ { s/,$// } '"'"' replconfig.json && + test_cmp replconfig.json newconfig.json + ' + + # SECURITY + # Those tests are here to prevent exposing the PrivKey on the network + test_expect_success "'ipfs config Identity' fails" ' test_expect_code 1 ipfs config Identity 2> ident_out ' @@ -81,8 +94,6 @@ test_config_cmd() { test_cmp ident_exp ident_out ' - # SECURITY - # Those tests are here to prevent exposing the PrivKey on the network test_expect_success "'ipfs config Identity.PrivKey' fails" ' test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out ' From 2a2e3eb1858f8523e2c111699939bad7a130574f Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 11 Aug 2016 13:40:13 +0200 Subject: [PATCH 2/8] sharness: remove mixed indentation License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 223a6c9ae..f4511eaa7 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -122,7 +122,7 @@ test_config_cmd() { test_expect_success "'ipfs config replace' injects privkey back" ' ipfs config replace show_config && - grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null + grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null ' test_expect_success "'ipfs config replace' with privkey erors out" ' From a680b1bd7b8cea48dadb6913ffe07906b8ae4173 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 8 Sep 2016 11:13:28 +0200 Subject: [PATCH 3/8] test: split 'ipfs config replace' test into parts License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index f4511eaa7..2222e9f1d 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -72,11 +72,17 @@ test_config_cmd() { grep "\"beep3\": false," actual ' - test_expect_success "'ipfs config replace' works" ' + test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && sed -i -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && - sed -i '"'"'/PeerID/ { s/,$// } '"'"' newconfig.json && - ipfs config replace - < newconfig.json && + sed -i '"'"'/PeerID/ { s/,$// } '"'"' newconfig.json + ' + + test_expect_success "run 'ipfs config replace'" ' + ipfs config replace - < newconfig.json + ' + + test_expect_success "check resulting config after 'ipfs config replace'" ' sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && sed -i -e'"'"'/PeerID/ { s/,$// } '"'"' replconfig.json && test_cmp replconfig.json newconfig.json From 25a035f92c3a1a6f05386f1d6742738679ad0bc5 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 8 Sep 2016 13:12:12 +0200 Subject: [PATCH 4/8] test: attempt to fix sed on travis License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 2222e9f1d..fb7eabe1f 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -74,8 +74,8 @@ test_config_cmd() { test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && - sed -i -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && - sed -i '"'"'/PeerID/ { s/,$// } '"'"' newconfig.json + sed -e /PrivKey/d -e s/10GB/11GB/ -i newconfig.json && + sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i newconfig.json ' test_expect_success "run 'ipfs config replace'" ' @@ -84,7 +84,7 @@ test_config_cmd() { test_expect_success "check resulting config after 'ipfs config replace'" ' sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && - sed -i -e'"'"'/PeerID/ { s/,$// } '"'"' replconfig.json && + sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i replconfig.json && test_cmp replconfig.json newconfig.json ' From 92d1d65fc2bb033617247e5b87a9c98179f5c2a6 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 12 Sep 2016 13:28:18 +0200 Subject: [PATCH 5/8] test: fix sed usage on OSX License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index fb7eabe1f..7d8e97dd5 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -74,8 +74,8 @@ test_config_cmd() { test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && - sed -e /PrivKey/d -e s/10GB/11GB/ -i newconfig.json && - sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i newconfig.json + Date: Wed, 28 Sep 2016 13:57:25 +0200 Subject: [PATCH 6/8] try to fix travis on BSDs again License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 7d8e97dd5..fdfe94b96 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -74,8 +74,8 @@ test_config_cmd() { test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && - replconfig.json && - sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i replconfig.json && + sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i"~" replconfig.json && test_cmp replconfig.json newconfig.json ' @@ -109,7 +109,7 @@ test_config_cmd() { ' test_expect_success "lower cased PrivKey" ' - sed -i -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" && + sed -i"~" -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" && test_expect_code 1 ipfs config Identity.privkey 2> ident_out ' From 5b4a6eac10834d1290131b5202f893f53d791741 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 28 Sep 2016 14:55:09 +0200 Subject: [PATCH 7/8] more bsd sed fixes License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index fdfe94b96..8347f9135 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -74,8 +74,8 @@ test_config_cmd() { test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && - replconfig.json && - sed -e '"'"'/PeerID/ { s/,$// } '"'"' -i"~" replconfig.json && + sed -i"~" -e '"'"'/PeerID/ { s/,$// } '"'"' replconfig.json && test_cmp replconfig.json newconfig.json ' @@ -118,7 +118,7 @@ test_config_cmd() { ' test_expect_success "fix it back" ' - sed -i -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config" + sed -i"~" -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config" ' test_expect_success "'ipfs config show' doesn't include privkey" ' From 80a776286c25ed7cbeb2c9070c2d84f2d28584f7 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 28 Sep 2016 16:22:32 +0200 Subject: [PATCH 8/8] more fixes for standard sed License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0021-config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 8347f9135..7eef9cd4a 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -75,7 +75,7 @@ test_config_cmd() { test_expect_success "setup for config replace test" ' cp "$IPFS_PATH/config" newconfig.json && sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && - sed -i"~" -e '"'"'/PeerID/ { s/,$// } '"'"' newconfig.json + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' newconfig.json ' test_expect_success "run 'ipfs config replace'" ' @@ -84,7 +84,7 @@ test_config_cmd() { test_expect_success "check resulting config after 'ipfs config replace'" ' sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && - sed -i"~" -e '"'"'/PeerID/ { s/,$// } '"'"' replconfig.json && + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' replconfig.json && test_cmp replconfig.json newconfig.json '