master
sh 29 lines 995 Bytes
Raw
1 #!/usr/bin/env bash
2
3 test_description="Test pubsub command behavior over HTTP RPC API"
4
5 . lib/test-lib.sh
6
7 test_init_ipfs
8 test_launch_ipfs_daemon --enable-pubsub-experiment
9
10 # Require topic as multibase
11 # https://github.com/ipfs/go-ipfs/pull/8183
12 test_expect_success "/api/v0/pubsub/pub URL arg must be multibase encoded" '
13 echo test > data.txt &&
14 curl -s -X POST -F "data=@data.txt" "$API_ADDR/api/v0/pubsub/pub?arg=foobar" > result &&
15 test_should_contain "error" result &&
16 test_should_contain "URL arg must be multibase encoded" result
17 '
18
19 # Use URL-safe multibase
20 # base64 should produce error when used in URL args, base64url should be used
21 test_expect_success "/api/v0/pubsub/pub URL arg must be in URL-safe multibase" '
22 echo test > data.txt &&
23 curl -s -X POST -F "data=@data.txt" "$API_ADDR/api/v0/pubsub/pub?arg=mZm9vYmFyCg" > result &&
24 test_should_contain "error" result &&
25 test_should_contain "URL arg must be base64url encoded" result
26 '
27
28 test_kill_ipfs_daemon
29 test_done