@cryptotaxi247 / kubo / commits / 2028d3707

test/sharness: Added basic gateway tests

Matt Bell committed Jan 27, 2015 at 01:26 UTC 2028d37076e4c61655ab31d5da4ee6810c8fe2f2
1 file changed +60
test/sharness/t0100-gateway.sh new
+60
@@ -0,0 +1,60 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2015 Matt Bell
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test HTTP gateway"
8 +
9 +. lib/test-lib.sh
10 +
11 +test_init_ipfs
12 +test_launch_ipfs_daemon
13 +
14 +test_expect_success "GET IPFS path succeeds" '
15 + echo "Hello Worlds!" > expected &&
16 + HASH=`ipfs add -q expected` &&
17 + wget http://127.0.0.1:5001/ipfs/"$HASH" -O actual
18 +'
19 +
20 +test_expect_success "GET IPFS path output looks good" '
21 + test_cmp expected actual &&
22 + rm actual
23 +'
24 +
25 +test_expect_success "GET IPFS directory path succeeds" '
26 + mkdir dir &&
27 + echo "12345" > dir/test &&
28 + HASH2=`ipfs add -r -q dir | tail -n 1` &&
29 + wget http://127.0.0.1:5001/ipfs/"$HASH2"
30 +'
31 +
32 +test_expect_success "GET IPFS directory file succeeds" '
33 + wget http://127.0.0.1:5001/ipfs/"$HASH2"/test -O actual
34 +'
35 +
36 +test_expect_success "GET IPFS directory file output looks good" '
37 + test_cmp dir/test actual
38 +'
39 +
40 +test_expect_failure "GET IPNS path succeeds" '
41 + ipfs name publish "$HASH" &&
42 + NAME=`ipfs config Identity.PeerID` &&
43 + wget http://127.0.0.1:5001/ipns/"$NAME" -O actual
44 +'
45 +
46 +test_expect_failure "GET IPNS path output looks good" '
47 + test_cmp expected actual
48 +'
49 +
50 +test_expect_success "GET invalid IPFS path errors" '
51 + test_must_fail wget http://127.0.0.1:5001/ipfs/12345
52 +'
53 +
54 +test_expect_success "GET invalid path errors" '
55 + test_must_fail wget http://127.0.0.1:5001/12345
56 +'
57 +
58 +test_kill_ipfs_daemon
59 +
60 +test_done