t0235-cli-request.sh 701 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="test http requests made by cli"

. lib/test-lib.sh

test_init_ipfs

test_expect_success "can make http request against nc server" '
Łukasz Magiera's avatar
Łukasz Magiera committed
14 15 16 17
  nc -ld 5005 > nc_out &
  NCPID=$!
  go-sleep 0.5s && kill "$NCPID" &
  ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true
18 19 20
'

test_expect_success "output does not contain multipart info" '
Łukasz Magiera's avatar
Łukasz Magiera committed
21
  test_expect_code 1 grep multipart nc_out
22 23 24
'

test_expect_success "request looks good" '
Łukasz Magiera's avatar
Łukasz Magiera committed
25
  grep "POST /api/v0/cat" nc_out
26 27 28
'

test_expect_success "api flag does not appear in request" '
Łukasz Magiera's avatar
Łukasz Magiera committed
29
  test_expect_code 1 grep "api=/ip4" nc_out
30 31 32
'

test_done