diff --git a/test/sharness/t0235-cli-request.sh b/test/sharness/t0235-cli-request.sh index 42931a2c5bd6..4450e30cbef0 100755 --- a/test/sharness/t0235-cli-request.sh +++ b/test/sharness/t0235-cli-request.sh @@ -10,11 +10,38 @@ test_description="test http requests made by cli" test_init_ipfs -test_expect_success "can make http request against nc server" ' - nc -ld 5005 > nc_out & +test_expect_success "start nc" ' + rm -f nc_out nc_outp nc_inp nc_statusp && mkfifo nc_inp nc_outp nc_statusp + + nc -v -l 127.0.0.1 5005 nc_outp 2>nc_statusp & NCPID=$! - go-sleep 0.5s && kill "$NCPID" & - ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true + + exec 6>nc_inp 7nc_out && + + echo -e "HTTP/1.1 200 OK\r" >&6 && + echo -e "Content-Type: text/plain\r" >&6 && + echo -e "Content-Length: 0\r" >&6 && + echo -e "\r" >&6 && + exec 6<&- && + + # Wait for IPFS and netcat + wait $IPFSPID $NCPID ' test_expect_success "output does not contain multipart info" ' diff --git a/test/sharness/t0236-cli-api-dns-resolve.sh b/test/sharness/t0236-cli-api-dns-resolve.sh index 18aa2246019a..e29d77591444 100755 --- a/test/sharness/t0236-cli-api-dns-resolve.sh +++ b/test/sharness/t0236-cli-api-dns-resolve.sh @@ -10,11 +10,38 @@ test_description="test dns resolution of api endpoint by cli" test_init_ipfs -test_expect_success "can make http request against dns resolved nc server" ' - nc -ld 5005 > nc_out & +test_expect_success "start nc" ' + rm -f nc_out nc_outp nc_inp nc_statusp && mkfifo nc_inp nc_outp nc_statusp + + nc -v -l 127.0.0.1 5006 nc_outp 2>nc_statusp & NCPID=$! - go-sleep 1s && kill "$NCPID" & - ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5005 || true + + exec 6>nc_inp 7nc_out && + + echo -e "HTTP/1.1 200 OK\r" >&6 && + echo -e "Content-Type: text/plain\r" >&6 && + echo -e "Content-Length: 0\r" >&6 && + echo -e "\r" >&6 && + exec 6<&- && + + # Wait for IPFS and netcat + wait $IPFSPID $NCPID ' test_expect_success "request was received by local nc server" '