From f300e97c508640d40917d07b2d70f6e8754394bd Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet <juan@benet.ai> Date: Fri, 19 Jun 2015 05:53:00 -0700 Subject: [PATCH] added sharness/t0061-daemon-opts Test odd daemon options, like: - unrestricted-api - disable-transport-encryption (known breakage atm) License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai> --- test/sharness/lib/test-lib.sh | 4 ++- test/sharness/t0061-daemon-opts.sh | 39 ++++++++++++++++++++++++++++++ test/sharness/t0110-gateway.sh | 4 +++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 test/sharness/t0061-daemon-opts.sh diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 73b55b343..e257ba1e5 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -193,8 +193,10 @@ test_config_ipfs_gateway_writable() { test_launch_ipfs_daemon() { + args=$1 + test_expect_success "'ipfs daemon' succeeds" ' - ipfs daemon >actual_daemon 2>daemon_err & + ipfs daemon $args >actual_daemon 2>daemon_err & ' # we say the daemon is ready when the API server is ready. diff --git a/test/sharness/t0061-daemon-opts.sh b/test/sharness/t0061-daemon-opts.sh new file mode 100755 index 000000000..d01fb8c80 --- /dev/null +++ b/test/sharness/t0061-daemon-opts.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (c) 2014 Juan Batiz-Benet +# MIT Licensed; see the LICENSE file in this repository. +# + +test_description="Test daemon command" + +. lib/test-lib.sh + + +test_init_ipfs + +test_launch_ipfs_daemon '--unrestricted-api --disable-transport-encryption' + +gwyport=$PORT_GWAY +apiport=$PORT_API + +test_expect_success 'api gateway should be unrestricted' ' + echo "hello mars :$gwyport :$apiport" >expected && + HASH=$(ipfs add -q expected) && + curl -sfo actual1 "http://127.0.0.1:$gwyport/ipfs/$HASH" && + curl -sfo actual2 "http://127.0.0.1:$apiport/ipfs/$HASH" && + test_cmp expected actual1 && + test_cmp expected actual2 +' + +# Odd. this fails here, but the inverse works on t0060-daemon. +test_expect_failure 'transport should be unencrypted' ' + nc 127.0.0.1 "$PORT_SWARM" >swarmnc & + go-sleep 0.1s && + ! grep -q "AES-256,AES-128" swarmnc && + grep -q "/ipfs/identify" swarmnc || + test_fsh cat swarmnc +' + +test_kill_ipfs_daemon + +test_done diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 36a94c671..fbaa4cd2e 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -33,6 +33,10 @@ test_expect_success "GET IPFS path output looks good" ' rm actual ' +test_expect_success "GET IPFS path on API forbidden" ' + test_curl_resp_http_code "http://127.0.0.1:$apiport/ipfs/$HASH" "HTTP/1.1 403 Forbidden" +' + test_expect_success "GET IPFS directory path succeeds" ' mkdir dir && echo "12345" >dir/test && -- GitLab