Skip to content

Commit

Permalink
Sharness: use curl -X POST on requests against the API
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Apr 4, 2020
1 parent 52262c3 commit 1fbfad8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions test/sharness/t0051-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ test_object_cmd() {
test_object_content_type() {

test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" '
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
'

test_expect_success "'ipfs object get --encoding=json' returns the correct content type" '
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
'

test_expect_success "'ipfs object get --encoding=text' returns the correct content type" '
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
'

test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" '
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
'
}

Expand Down
6 changes: 3 additions & 3 deletions test/sharness/t0060-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ test_expect_success "ipfs peer id looks good" '
# this is for checking SetAllowedOrigins race condition for the api and gateway
# See https://github.com/ipfs/go-ipfs/pull/1966
test_expect_success "ipfs API works with the correct allowed origin port" '
curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version"
curl -s -X POST -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version"
'

test_expect_success "ipfs gateway works with the correct allowed origin port" '
curl -s -X GET -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version"
curl -s -X POST -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version"
'

test_expect_success "ipfs daemon output looks good" '
Expand Down Expand Up @@ -134,7 +134,7 @@ test_expect_success SOCAT "transport should be encrypted ( needs socat )" '
'

test_expect_success "output from streaming commands works" '
test_expect_code 28 curl -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout
test_expect_code 28 curl -X POST -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout
'

test_expect_success "output looks good" '
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0090-get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ test_launch_ipfs_daemon
test_get_cmd

test_expect_success "empty request to get doesn't panic and returns error" '
curl "http://$API_ADDR/api/v0/get" > curl_out || true &&
curl -X POST "http://$API_ADDR/api/v0/get" > curl_out || true &&
grep "argument \"ipfs-path\" is required" curl_out
'
test_kill_ipfs_daemon
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ test_expect_success "resolve output looks good" '
'

test_expect_success "empty request to name publish doesn't panic and returns error" '
curl "http://$API_ADDR/api/v0/name/publish" > curl_out || true &&
curl -X POST "http://$API_ADDR/api/v0/name/publish" > curl_out || true &&
grep "argument \"ipfs-path\" is required" curl_out
'

Expand Down
4 changes: 2 additions & 2 deletions test/sharness/t0230-channel-streaming-http-content-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_ls_cmd() {
mkdir -p testdir &&
echo "hello test" >testdir/test.txt &&
ipfs add -r testdir &&
curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output
curl -X POST -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output
'

test_expect_success "Text encoded channel-streaming command output looks good" '
Expand All @@ -39,7 +39,7 @@ test_ls_cmd() {
mkdir -p testdir &&
echo "hello test" >testdir/test.txt &&
ipfs add -r testdir &&
curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output
curl -X POST -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output
'

test_expect_success "JSON encoded channel-streaming command output looks good" '
Expand Down
12 changes: 6 additions & 6 deletions test/sharness/t0600-issues-and-regressions-online.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ test_launch_ipfs_daemon
# Tests go here

test_expect_success "commands command with flag flags works via HTTP API - #2301" '
curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
curl -X POST "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
'

test_expect_success "ipfs refs local over HTTP API returns NDJOSN not flat - #2803" '
echo "Hello World" | ipfs add &&
curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
curl -X POST "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
'

test_expect_success "args expecting stdin dont crash when not given" '
curl "$API_ADDR/api/v0/bootstrap/add" > result
curl -X POST "$API_ADDR/api/v0/bootstrap/add" > result
'

test_expect_success "no panic traces on daemon" '
test_must_fail grep "nil pointer dereference" daemon_err
'

test_expect_success "metrics work" '
curl "$API_ADDR/debug/metrics/prometheus" > pro_data &&
curl -X POST "$API_ADDR/debug/metrics/prometheus" > pro_data &&
grep "ipfs_bs_cache_arc_hits_total" < pro_data ||
test_fsh cat pro_data
'

test_expect_success "pin add api looks right - #3753" '
HASH=$(echo "foo" | ipfs add -q) &&
curl "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out &&
curl -X POST "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out &&
echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinadd_exp &&
test_cmp pinadd_out pinadd_exp
'

test_expect_success "pin add api looks right - #3753" '
curl "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out &&
curl -X POST "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out &&
echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinrm_exp &&
test_cmp pinrm_out pinrm_exp
'
Expand Down

0 comments on commit 1fbfad8

Please sign in to comment.