Repository navigation
Expand file tree
/
Copy patht0124-gateway-ipns-record.sh
More file actions
executable file
·52 lines (41 loc) · 2.62 KB
/
Copy patht0124-gateway-ipns-record.sh
File metadata and controls
executable file
·52 lines (41 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
test_description="Test HTTP Gateway IPNS Record (application/vnd.ipfs.ipns-record) Support"
. lib/test-lib.sh
test_init_ipfs
test_launch_ipfs_daemon
test_expect_success "Create and Publish IPNS Key" '
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q) &&
IPNS_KEY=$(ipfs key gen ipns-record) &&
ipfs name publish /ipfs/$FILE_CID --key=ipns-record --ttl=30m &&
curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
test_should_contain "Hello IPFS" curl_output_filename
'
test_expect_success "GET KEY with format=ipns-record and validate key" '
curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename &&
ipfs name inspect --verify $IPNS_KEY < curl_output_filename > verify_output &&
test_should_contain "$FILE_CID" verify_output
'
test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' and validate key" '
curl -H "Accept: application/vnd.ipfs.ipns-record" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
ipfs name inspect --verify $IPNS_KEY < curl_output_filename > verify_output &&
test_should_contain "$FILE_CID" verify_output
'
test_expect_success "GET KEY with format=ipns-record has expected HTTP headers" '
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename 2>&1 &&
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
'
test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' has expected HTTP headers" '
curl -H "Accept: application/vnd.ipfs.ipns-record" -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename 2>&1 &&
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
'
test_expect_success "GET KEY with expliciy ?filename= succeeds with modified Content-Disposition header" '
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record&filename=testтест.ipns-record" > curl_output_filename 2>&1 &&
grep -F "Content-Disposition: attachment; filename=\"test____.ipns-record\"; filename*=UTF-8'\'\''test%D1%82%D0%B5%D1%81%D1%82.ipns-record" curl_output_filename &&
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename
'
test_kill_ipfs_daemon
test_done