diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 73b55b343c8a37031a91eddcd797d56000395757..e257ba1e5c8a8c251c696cd7cf86fe240ddd3caf 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 0000000000000000000000000000000000000000..d01fb8c80574bba4f6acc13a3097f2ac6b881699 --- /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 36a94c671c1eea9bdea19df3b41382cf4fd479e0..fbaa4cd2e7a96bb285753f670080bdf771673c32 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 &&