@cryptotaxi247 / kubo / commits / 90b6490a3

Add test for readonly gateway api sanitation

License: MIT Signed-off-by: rht <rhtbot@gmail.com>

rht committed Aug 17, 2015 at 13:47 UTC 90b6490a35a1ddd5f5b1a898d6c1a81b0996d6b6
1 file changed +13 -2
test/sharness/t0110-gateway.sh
+13 -2
@@ -92,8 +92,13 @@ test_expect_success "log output looks good" '
92 '
93
94 # test ipfs readonly api
95 +
96 +test_curl_gateway_api() {
97 + curl -sfo actual "http://127.0.0.1:$port/api/v0/$1"
98 +}
99 +
100 test_expect_success "get IPFS directory file through readonly API succeeds" '
96 - curl -sfo actual "http://127.0.0.1:$port/api/v0/cat?arg=$HASH2/test"
101 + test_curl_gateway_api "cat?arg=$HASH2/test"
102 '
103
104 test_expect_success "get IPFS directory file through readonly API output looks good" '
@@ -101,7 +106,13 @@ test_expect_success "get IPFS directory file through readonly API output looks g
106 '
107
108 test_expect_success "refs IPFS directory file through readonly API succeeds" '
104 - curl -sfo actual "http://127.0.0.1:$port/api/v0/refs?arg=$HASH2/test"
109 + test_curl_gateway_api "refs?arg=$HASH2/test"
110 +'
111 +
112 +test_expect_success "test gateway api is sanitized" '
113 +for cmd in "add" "block/put" "bootstrap" "config" "dht" "diag" "dns" "get" "id" "mount" "name/publish" "object/put" "object/new" "object/patch" "pin" "ping" "refs/local" "repo" "resolve" "stats" "swarm" "tour" "file" "update" "version" "bitswap"; do
114 + test_curl_resp_http_code "http://127.0.0.1:$port/api/v0/$cmd" "HTTP/1.1 404 Not Found"
115 + done
116 '
117
118 test_kill_ipfs_daemon