From b1492fbdb6639dcedba6bcd3928dbeb22cd78d71 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 16:45:28 +0100 Subject: [PATCH] test: use car fixtures in sharness t0400 --- test/sharness/t0400-api-no-gateway.sh | 9 +++++++-- test/sharness/t0400-api-no-gateway/README.md | 15 +++++++++++++++ test/sharness/t0400-api-no-gateway/fixtures.car | Bin 0 -> 108 bytes 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/sharness/t0400-api-no-gateway/README.md create mode 100644 test/sharness/t0400-api-no-gateway/fixtures.car diff --git a/test/sharness/t0400-api-no-gateway.sh b/test/sharness/t0400-api-no-gateway.sh index 137f99a950ec..d0daeece3da2 100755 --- a/test/sharness/t0400-api-no-gateway.sh +++ b/test/sharness/t0400-api-no-gateway.sh @@ -10,6 +10,13 @@ test_description="Test API security" test_init_ipfs +# Import test case +# See the static fixtures in ./t0400-api-no-gateway/ +test_expect_success "Add the test directory" ' + ipfs dag import ../t0400-api-no-gateway/fixtures.car +' +HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing" + # by default, we don't let you load arbitrary ipfs objects through the api, # because this would open up the api to scripting vulnerabilities. # only the webui objects are allowed. @@ -17,14 +24,12 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "Gateway on API unavailable" ' - HASH=$(echo "testing" | ipfs add -q) test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found" ' test_kill_ipfs_daemon test_launch_ipfs_daemon --unrestricted-api test_expect_success "Gateway on --unrestricted-api API available" ' - HASH=$(echo "testing" | ipfs add -q) test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK" ' test_kill_ipfs_daemon diff --git a/test/sharness/t0400-api-no-gateway/README.md b/test/sharness/t0400-api-no-gateway/README.md new file mode 100644 index 000000000000..83d184d4a42b --- /dev/null +++ b/test/sharness/t0400-api-no-gateway/README.md @@ -0,0 +1,15 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +HASH=$(echo "testing" | ipfs add -q) +ipfs dag export $HASH > fixtures.car + +echo HASH=${HASH} # a file containing the string "testing" + +# HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing" +``` diff --git a/test/sharness/t0400-api-no-gateway/fixtures.car b/test/sharness/t0400-api-no-gateway/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..1e090db6dc1e7d3a07c8523de752e61dc744bd1f GIT binary patch literal 108 zcmcCmlv