Skip to content

Commit

Permalink
test: use car fixtures in sharness t0400
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Feb 20, 2023
1 parent 6ca4190 commit b1492fb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/sharness/t0400-api-no-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ 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.
# if you know what you're doing, go ahead and pass --unrestricted-api.

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
Expand Down
15 changes: 15 additions & 0 deletions test/sharness/t0400-api-no-gateway/README.md
Original file line number Diff line number Diff line change
@@ -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"
```
Binary file added test/sharness/t0400-api-no-gateway/fixtures.car
Binary file not shown.

0 comments on commit b1492fb

Please sign in to comment.