@cryptotaxi247 / kubo / commits / 3ed8f394e

test: use car fixtures in sharness t0400

Laurent Senta committed Feb 20, 2023 at 16:45 UTC 3ed8f394e00fb3a7dc18af567b04512db51e6dbb
3 files changed +22 -2
test/sharness/t0400-api-no-gateway.sh
+7 -2
@@ -10,6 +10,13 @@ test_description="Test API security"
10
11 test_init_ipfs
12
13 +# Import test case
14 +# See the static fixtures in ./t0400-api-no-gateway/
15 +test_expect_success "Add the test directory" '
16 + ipfs dag import ../t0400-api-no-gateway/fixtures.car
17 +'
18 +HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing"
19 +
20 # by default, we don't let you load arbitrary ipfs objects through the api,
21 # because this would open up the api to scripting vulnerabilities.
22 # only the webui objects are allowed.
@@ -17,14 +24,12 @@ test_init_ipfs
24
25 test_launch_ipfs_daemon
26 test_expect_success "Gateway on API unavailable" '
20 - HASH=$(echo "testing" | ipfs add -q)
27 test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found"
28 '
29 test_kill_ipfs_daemon
30
31 test_launch_ipfs_daemon --unrestricted-api
32 test_expect_success "Gateway on --unrestricted-api API available" '
27 - HASH=$(echo "testing" | ipfs add -q)
33 test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK"
34 '
35 test_kill_ipfs_daemon
test/sharness/t0400-api-no-gateway/README.md new
+15
@@ -0,0 +1,15 @@
1 +# Dataset description/sources
2 +
3 +- fixtures.car
4 + - raw CARv1
5 +
6 +generated with:
7 +
8 +```sh
9 +HASH=$(echo "testing" | ipfs add -q)
10 +ipfs dag export $HASH > fixtures.car
11 +
12 +echo HASH=${HASH} # a file containing the string "testing"
13 +
14 +# HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing"
15 +```
test/sharness/t0400-api-no-gateway/fixtures.car
Binary files /dev/null and b/test/sharness/t0400-api-no-gateway/fixtures.car differ