master
sh 37 lines 1.11 KB
Raw
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2016 Lars Gierth
4 # MIT Licensed; see the LICENSE file in this repository.
5 #
6
7 test_description="Test API security"
8
9 . lib/test-lib.sh
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.
23 # if you know what you're doing, go ahead and pass --unrestricted-api.
24
25 test_launch_ipfs_daemon
26 test_expect_success "Gateway on API unavailable" '
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" '
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
36
37 test_done