@cryptotaxi247 / kubo / commits / 7977f26e8

chore: remove sharness tests ported to conformance testing (#9999)

* test(t0112): drop test ported to conformance * test(t0113): drop test ported to conformance * test(t0114): drop test ported to conformance * test(t0114): drop test ported to conformance * test(t0115): drop test ported to conformance * test(t0122): drop test ported to conformance * test(t0123): drop test ported to conformance * test(t0117): drop test ported to conformance * test(t0124): drop test ported to conformance * test(t0114): simplify tests * test(t0112): drop test ported to conformance * test(t0116): drop test ported to conformance * t0114: restore tests flagged by lidel * t0112: restore * t0116: restore dirindex check * t0109: restore file * t0115: restore full file * t0114: restored rest of file * fix: kill the iptb cluster

Laurent Senta committed Aug 2, 2023 at 19:15 UTC 7977f26e862449f47d313c2cb1d2977f227638d7
30 files changed +29 -1090
test/sharness/t0026-id.sh
+2
@@ -61,6 +61,8 @@ test_expect_success "checking AgentVersion with suffix (fetched via libp2p ident
61 ipfsi 1 id "$(ipfsi 0 config Identity.PeerID)" -f "<aver>\n" > actual-libp2p-identify-agent-version &&
62 test_cmp expected-identify-agent-version actual-libp2p-identify-agent-version
63 '
64 +iptb stop
65 +
66 test_kill_ipfs_daemon
67
68
test/sharness/t0113-gateway-symlink.sh deleted
-33
@@ -1,33 +0,0 @@
1 -#!/usr/bin/env bash
2 -#
3 -# Copyright (c) Protocol Labs
4 -
5 -test_description="Test symlink support on the HTTP gateway"
6 -
7 -. lib/test-lib.sh
8 -
9 -test_init_ipfs
10 -test_launch_ipfs_daemon
11 -
12 -# Import test case
13 -# See the static fixtures in ./t0113-gateway-symlink/
14 -test_expect_success "Add the test directory with symlinks" '
15 - ipfs dag import --pin-roots ../t0113-gateway-symlink/testfiles.car
16 -'
17 -ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt # ./testfiles/
18 -
19 -test_expect_success "Test the directory listing" '
20 - curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/" > list_response &&
21 - test_should_contain ">foo<" list_response &&
22 - test_should_contain ">bar<" list_response
23 -'
24 -
25 -test_expect_success "Test the symlink" '
26 - curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/bar" > bar_actual &&
27 - echo -n "foo" > bar_expected &&
28 - test_cmp bar_expected bar_actual
29 -'
30 -
31 -test_kill_ipfs_daemon
32 -
33 -test_done
test/sharness/t0113-gateway-symlink/README.md deleted
-17
@@ -1,17 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- testfiles.car
4 - - raw CARv1
5 -
6 -generated with:
7 -
8 -```sh
9 -# using ipfs version 0.18.1
10 -mkdir testfiles &&
11 -echo "content" > testfiles/foo &&
12 -ln -s foo testfiles/bar &&
13 -ROOT_DIR_CID=$(ipfs add -Qr testfiles) &&
14 -ipfs dag export $ROOT_DIR_CID > testfiles.car
15 -
16 -# ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt
17 -```
test/sharness/t0113-gateway-symlink/testfiles.car
Binary files a/test/sharness/t0113-gateway-symlink/testfiles.car and /dev/null differ
test/sharness/t0114-gateway-subdomains.sh
+27 -1
@@ -162,6 +162,9 @@ test_localhost_gateway_response_should_contain \
162 "http://localhost:$GWAY_PORT/ipfs/$DIR_CID/" \
163 "Location: http://$DIR_CID.ipfs.localhost:$GWAY_PORT/"
164
165 +# Kubo specific end-to-end test
166 +# (independend of gateway-conformance)
167 +
168 # We return human-readable body with HTTP 301 so existing cli scripts that use path-based
169 # gateway are informed to enable following HTTP redirects
170 test_localhost_gateway_response_should_contain \
@@ -169,6 +172,8 @@ test_localhost_gateway_response_should_contain \
172 "http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
173 ">Moved Permanently</a>"
174
175 +# end Kubo specific end-to-end test
176 +
177 test_localhost_gateway_response_should_contain \
178 "request for localhost/ipfs/{CIDv0} redirects to CIDv1 representation in subdomain" \
179 "http://localhost:$GWAY_PORT/ipfs/$CIDv0" \
@@ -188,11 +193,16 @@ test_localhost_gateway_response_should_contain \
193
194 # /ipns/<dnslink-fqdn>
195
196 +# Kubo specific end-to-end test
197 +# (independend of gateway-conformance)
198 +
199 test_localhost_gateway_response_should_contain \
200 "request for localhost/ipns/{fqdn} redirects to DNSLink in subdomain" \
201 "http://localhost:$GWAY_PORT/ipns/en.wikipedia-on-ipfs.org/wiki" \
202 "Location: http://en.wikipedia-on-ipfs.org.ipns.localhost:$GWAY_PORT/wiki"
203
204 +# end Kubo specific end-to-end test
205 +
206 # API on localhost subdomain gateway
207
208 # /api/v0 present on the root hostname
@@ -236,6 +246,10 @@ test_localhost_gateway_response_should_contain \
246 "http://${DIR_CID}.ipfs.localhost:$GWAY_PORT/ipfs/file.txt" \
247 "I am a txt file"
248
249 +# Kubo specific end-to-end test
250 +# (independend of gateway-conformance)
251 +# This tests link to parent specific to boxo + relative pathing end-to-end tests specific to Kubo.
252 +
253 # {CID}.ipfs.localhost/sub/dir (Directory Listing)
254 DIR_HOSTNAME="${DIR_CID}.ipfs.localhost:$GWAY_PORT"
255
@@ -255,7 +269,7 @@ test_expect_success "request for deep path resource at {cid}.ipfs.localhost/sub/
269 curl -s --resolve $DIR_HOSTNAME:127.0.0.1 "http://$DIR_HOSTNAME/ipfs/ipns/bar" > list_response &&
270 test_should_contain "text-file-content" list_response
271 '
258 -
272 +# end Kubo specific end-to-end test
273
274 # *.ipns.localhost
275
@@ -441,6 +455,10 @@ test_hostname_gateway_response_should_contain \
455 "http://127.0.0.1:$GWAY_PORT/ipfs/$CIDv1" \
456 "404 Not Found"
457
458 +# Kubo specific end-to-end test
459 +# (independend of gateway-conformance)
460 +# HTML specific to Boxo/Kubo, and relative pathing specific to code in Kubo
461 +
462 # {CID}.ipfs.example.com/sub/dir (Directory Listing)
463 DIR_FQDN="${DIR_CID}.ipfs.example.com"
464
@@ -464,6 +482,8 @@ test_expect_success "valid breadcrumb links in the header of directory listing a
482 test_should_contain "/ipfs/<a href=\"//example.com/ipfs/${DIR_CID}\">${DIR_CID}</a>/<a href=\"//example.com/ipfs/${DIR_CID}/ipfs\">ipfs</a>/<a href=\"//example.com/ipfs/${DIR_CID}/ipfs/ipns\">ipns</a>" list_response
483 '
484
485 +# end Kubo specific end-to-end test
486 +
487 test_expect_success "request for deep path resource {cid}.ipfs.example.com/sub/dir/file" '
488 curl -s -H "Host: $DIR_FQDN" http://127.0.0.1:$GWAY_PORT/ipfs/ipns/bar > list_response &&
489 test_should_contain "text-file-content" list_response
@@ -855,6 +875,10 @@ test_expect_success "request for http://fake.domain.com/ipfs/{CID} with X-Forwar
875 test_should_contain \"Location: https://$CIDv1.ipfs.example.com/\" response
876 "
877
878 +# Kubo specific end-to-end test
879 +# (independend of gateway-conformance)
880 +# test cofiguration beign wired up correctly end-to-end
881 +
882 ## ============================================================================
883 ## Test support for wildcards in gateway config
884 ## ============================================================================
@@ -966,3 +990,5 @@ test_expect_success "clean up ipfs dir" '
990 '
991
992 test_done
993 +
994 +# end Kubo specific end-to-end test
\ No newline at end of file
test/sharness/t0116-gateway-cache.sh
-214
@@ -39,156 +39,6 @@ test_expect_success "Add the test directory" '
39 ipfs routing put --allow-offline /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record
40 '
41
42 -# GET /ipfs/
43 - # unixfs
44 - test_expect_success "GET for /ipfs/ unixfs dir listing succeeds" '
45 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/" >/dev/null 2>curl_ipfs_dir_listing_output
46 - '
47 - test_expect_success "GET for /ipfs/ unixfs dir with index.html succeeds" '
48 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/" >/dev/null 2>curl_ipfs_dir_index.html_output
49 - '
50 - test_expect_success "GET for /ipfs/ unixfs file succeeds" '
51 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_ipfs_file_output
52 - '
53 - # unixfs dir as dag-json
54 - test_expect_success "GET for /ipfs/ unixfs dir as DAG-JSON succeeds" '
55 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/?format=dag-json" >/dev/null 2>curl_ipfs_dir_dag-json_output &&
56 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/?format=json" >/dev/null 2>curl_ipfs_dir_json_output
57 - '
58 -# GET /ipns/
59 - # unixfs
60 - test_expect_success "GET for /ipns/ unixfs dir listing succeeds" '
61 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/" >/dev/null 2>curl_ipns_dir_listing_output
62 - '
63 - test_expect_success "GET for /ipns/ unixfs dir with index.html succeeds" '
64 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/root4/" >/dev/null 2>curl_ipns_dir_index.html_output
65 - '
66 - test_expect_success "GET for /ipns/ unixfs file succeeds" '
67 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/root4/index.html" >/dev/null 2>curl_ipns_file_output
68 - '
69 - # unixfs dir as dag-json
70 - test_expect_success "GET for /ipns/ unixfs dir as DAG-JSON succeeds" '
71 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/root4/?format=dag-json" >/dev/null 2>curl_ipns_dir_dag-json_output &&
72 - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/root4/?format=json" >/dev/null 2>curl_ipns_dir_json_output
73 - '
74 -
75 -# Cache-Control
76 -
77 -# Cache-Control: immutable /ipfs/ file
78 - test_expect_success "GET /ipfs/ unixfs file has expected Cache-Control" '
79 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_file_output
80 - '
81 -# Cache-Control: generated /ipfs/dir/ (listing)
82 - # TODO: test_should_contain "< Cache-Control: public, max-age=TBD" curl_ipfs_dir_listing_output
83 - test_expect_success "GET /ipfs/ unixfs dir listing has no Cache-Control" '
84 - test_should_not_contain "< Cache-Control" curl_ipns_dir_listing_output
85 - '
86 -# Cache-Control: immutable /ipfs/dir/ (index.html)
87 - test_expect_success "GET /ipfs/ unixfs dir with index.html has expected Cache-Control" '
88 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_index.html_output
89 - '
90 -# Cache-Control: immutable /ipfs/ unixfs dir as dag-json
91 - test_expect_success "GET /ipfs/ dag-json has expected Cache-Control" '
92 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_dag-json_output
93 - '
94 -# Cache-Control: immutable /ipfs/ unixfs dir as json
95 - test_expect_success "GET /ipfs/ unixfs dir as json has expected Cache-Control" '
96 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_json_output
97 - '
98 -# Cache-Control: mutable /ipns/ file
99 - test_expect_success "GET /ipns/ unixfs file has no Cache-Control" '
100 - test_should_not_contain "< Cache-Control" curl_ipns_file_output
101 - '
102 -# Cache-Control: mutable /ipns/dir/ (generated listing)
103 - test_expect_success "GET /ipns/ unixfs dir listing has no Cache-Control" '
104 - test_should_not_contain "< Cache-Control" curl_ipns_dir_listing_output
105 - '
106 -# Cache-Control: mutable /ipns/dir/ (index.html)
107 - test_expect_success "GET /ipns/ unixfs dir with index.html has no Cache-Control" '
108 - test_should_not_contain "< Cache-Control" curl_ipns_dir_index.html_output
109 - '
110 -# Cache-Control: mutable /ipns/dir/ as dag-json
111 - test_expect_success "GET /ipns/ unixfs dir as dag-json has no Cache-Control" '
112 - test_should_not_contain "< Cache-Control" curl_ipns_dir_dag-json_output
113 - '
114 -# Cache-Control: mutable /ipns/dir/ as json
115 - test_expect_success "GET /ipns/ unixfs dir as json has no Cache-Control" '
116 - test_should_not_contain "< Cache-Control" curl_ipns_dir_json_output
117 - '
118 -
119 -# Cache-Control: only-if-cached
120 - test_expect_success "HEAD for /ipfs/ with only-if-cached succeeds when in local datastore" '
121 - curl -sv -I -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" > curl_onlyifcached_postitive_head 2>&1 &&
122 - cat curl_onlyifcached_postitive_head &&
123 - grep "< HTTP/1.1 200 OK" curl_onlyifcached_postitive_head
124 - '
125 - test_expect_success "HEAD for /ipfs/ with only-if-cached fails when not in local datastore" '
126 - curl -sv -I -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$(date | ipfs add --only-hash -Q)" > curl_onlyifcached_negative_head 2>&1 &&
127 - cat curl_onlyifcached_negative_head &&
128 - grep "< HTTP/1.1 412 Precondition Failed" curl_onlyifcached_negative_head
129 - '
130 - test_expect_success "GET for /ipfs/ with only-if-cached succeeds when in local datastore" '
131 - curl -svX GET -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_onlyifcached_postitive_out &&
132 - cat curl_onlyifcached_postitive_out &&
133 - grep "< HTTP/1.1 200 OK" curl_onlyifcached_postitive_out
134 - '
135 - test_expect_success "GET for /ipfs/ with only-if-cached fails when not in local datastore" '
136 - curl -svX GET -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$(date | ipfs add --only-hash -Q)" >/dev/null 2>curl_onlyifcached_negative_out &&
137 - cat curl_onlyifcached_negative_out &&
138 - grep "< HTTP/1.1 412 Precondition Failed" curl_onlyifcached_negative_out
139 - '
140 -
141 -# X-Ipfs-Path
142 -
143 - ## dir generated listing
144 - test_expect_success "GET /ipfs/ dir listing response has original content path in X-Ipfs-Path" '
145 - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3" curl_ipfs_dir_listing_output
146 - '
147 - test_expect_success "GET /ipns/ dir listing response has original content path in X-Ipfs-Path" '
148 - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3" curl_ipns_dir_listing_output
149 - '
150 -
151 - ## dir static index.html
152 - test_expect_success "GET /ipfs/ dir index.html response has original content path in X-Ipfs-Path" '
153 - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3/root4/" curl_ipfs_dir_index.html_output
154 - '
155 - test_expect_success "GET /ipns/ dir index.html response has original content path in X-Ipfs-Path" '
156 - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3/root4/" curl_ipns_dir_index.html_output
157 - '
158 -
159 - # file
160 - test_expect_success "GET /ipfs/ file response has original content path in X-Ipfs-Path" '
161 - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3/root4/index.html" curl_ipfs_file_output
162 - '
163 - test_expect_success "GET /ipns/ file response has original content path in X-Ipfs-Path" '
164 - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3/root4/index.html" curl_ipns_file_output
165 - '
166 -
167 -# X-Ipfs-Roots
168 -
169 - ## dir generated listing
170 - test_expect_success "GET /ipfs/ dir listing response has logical CID roots in X-Ipfs-Roots" '
171 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID}" curl_ipfs_dir_listing_output
172 - '
173 - test_expect_success "GET /ipns/ dir listing response has logical CID roots in X-Ipfs-Roots" '
174 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID}" curl_ipns_dir_listing_output
175 - '
176 -
177 - ## dir static index.html
178 - test_expect_success "GET /ipfs/ dir index.html response has logical CID roots in X-Ipfs-Roots" '
179 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID}" curl_ipfs_dir_index.html_output
180 - '
181 - test_expect_success "GET /ipns/ dir index.html response has logical CID roots in X-Ipfs-Roots" '
182 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID}" curl_ipns_dir_index.html_output
183 - '
184 -
185 - ## file
186 - test_expect_success "GET /ipfs/ file response has logical CID roots in X-Ipfs-Roots" '
187 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID},${FILE_CID}" curl_ipfs_file_output
188 - '
189 - test_expect_success "GET /ipns/ file response has logical CID roots in X-Ipfs-Roots" '
190 - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID},${FILE_CID}" curl_ipns_file_output
191 - '
42
43 # Etag
44
@@ -202,70 +52,6 @@ test_expect_success "Add the test directory" '
52 grep -E "< Etag: \"DirIndex-.+_CID-${ROOT3_CID}\"" curl_ipns_dir_listing_output
53 '
54
205 - ## dir static index.html should use CID of the index.html file for improved HTTP caching
206 - test_expect_success "GET /ipfs/ dir index.html response has dir CID as Etag" '
207 - test_should_contain "< Etag: \"${ROOT4_CID}\"" curl_ipfs_dir_index.html_output
208 - '
209 - test_expect_success "GET /ipns/ dir index.html response has dir CID as Etag" '
210 - test_should_contain "< Etag: \"${ROOT4_CID}\"" curl_ipns_dir_index.html_output
211 - '
212 -
213 - ## file
214 - test_expect_success "GET /ipfs/ response has CID as Etag for a file" '
215 - test_should_contain "< Etag: \"${FILE_CID}\"" curl_ipfs_file_output
216 - '
217 - test_expect_success "GET /ipns/ response has CID as Etag for a file" '
218 - test_should_contain "< Etag: \"${FILE_CID}\"" curl_ipns_file_output
219 - '
220 -
221 -# If-None-Match (return 304 Not Modified when client sends matching Etag they already have)
222 -
223 - test_expect_success "GET for /ipfs/ file with matching Etag in If-None-Match returns 304 Not Modified" '
224 - curl -svX GET -H "If-None-Match: \"$FILE_CID\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_output &&
225 - test_should_contain "304 Not Modified" curl_output
226 - '
227 -
228 - test_expect_success "GET for /ipfs/ dir with index.html file with matching Etag in If-None-Match returns 304 Not Modified" '
229 - curl -svX GET -H "If-None-Match: \"$ROOT4_CID\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/" >/dev/null 2>curl_output &&
230 - test_should_contain "304 Not Modified" curl_output
231 - '
232 -
233 - test_expect_success "GET for /ipfs/ file with matching third Etag in If-None-Match returns 304 Not Modified" '
234 - curl -svX GET -H "If-None-Match: \"fakeEtag1\", \"fakeEtag2\", \"$FILE_CID\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_output &&
235 - test_should_contain "304 Not Modified" curl_output
236 - '
237 -
238 - test_expect_success "GET for /ipfs/ file with matching weak Etag in If-None-Match returns 304 Not Modified" '
239 - curl -svX GET -H "If-None-Match: W/\"$FILE_CID\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_output &&
240 - test_should_contain "304 Not Modified" curl_output
241 - '
242 -
243 - test_expect_success "GET for /ipfs/ file with wildcard Etag in If-None-Match returns 304 Not Modified" '
244 - curl -svX GET -H "If-None-Match: *" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/root4/index.html" >/dev/null 2>curl_output &&
245 - test_should_contain "304 Not Modified" curl_output
246 - '
247 -
248 - test_expect_success "GET for /ipns/ file with matching Etag in If-None-Match returns 304 Not Modified" '
249 - curl -svX GET -H "If-None-Match: \"$FILE_CID\"" "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/root4/index.html" >/dev/null 2>curl_output &&
250 - test_should_contain "304 Not Modified" curl_output
251 - '
252 -
253 - test_expect_success "GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified" '
254 - curl -svX GET -H "If-None-Match: W/\"$ROOT3_CID\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/" >/dev/null 2>curl_output &&
255 - test_should_contain "304 Not Modified" curl_output
256 - '
257 -
258 - # DirIndex etag is based on xxhash(./assets/dir-index-html), so we need to fetch it dynamically
259 - test_expect_success "GET for /ipfs/ dir listing with matching strong Etag in If-None-Match returns 304 Not Modified" '
260 - curl -Is "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/"| grep -i Etag | cut -f2- -d: | tr -d "[:space:]\"" > dir_index_etag &&
261 - curl -svX GET -H "If-None-Match: \"$(<dir_index_etag)\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/" >/dev/null 2>curl_output &&
262 - test_should_contain "304 Not Modified" curl_output
263 - '
264 - test_expect_success "GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified" '
265 - curl -Is "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/"| grep -i Etag | cut -f2- -d: | tr -d "[:space:]\"" > dir_index_etag &&
266 - curl -svX GET -H "If-None-Match: W/\"$(<dir_index_etag)\"" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/" >/dev/null 2>curl_output &&
267 - test_should_contain "304 Not Modified" curl_output
268 - '
55
56 test_kill_ipfs_daemon
57
test/sharness/t0116-gateway-cache/README.md deleted
-39
@@ -1,39 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- fixtures.car
4 - - raw CARv1
5 -
6 -generated with:
7 -
8 -```sh
9 -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
10 -
11 -mkdir -p root2/root3/root4 &&
12 -echo "hello" > root2/root3/root4/index.html &&
13 -ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2)
14 -ROOT2_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2 | cut -d "/" -f3)
15 -ROOT3_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3 | cut -d "/" -f3)
16 -ROOT4_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4 | cut -d "/" -f3)
17 -FILE_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4/index.html | cut -d "/" -f3)
18 -
19 -TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n")
20 -# publish a record valid for a 100 years
21 -ipfs name publish --key cache_test_key --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$ROOT1_CID"
22 -ipfs routing get /ipns/${TEST_IPNS_ID} > ${TEST_IPNS_ID}.ipns-record
23 -
24 -echo ROOT1_CID=${ROOT1_CID} # ./
25 -echo ROOT2_CID=${ROOT2_CID} # ./root2
26 -echo ROOT3_CID=${ROOT3_CID} # ./root2/root3
27 -echo ROOT4_CID=${ROOT4_CID} # ./root2/root3/root4
28 -echo FILE_CID=${FILE_CID} # ./root2/root3/root4/index.html
29 -echo TEST_IPNS_ID=${TEST_IPNS_ID}
30 -
31 -ipfs dag export ${ROOT1_CID} > ./fixtures.car
32 -
33 -# ROOT1_CID=bafybeib3ffl2teiqdncv3mkz4r23b5ctrwkzrrhctdbne6iboayxuxk5ui # ./
34 -# ROOT2_CID=bafybeih2w7hjocxjg6g2ku25hvmd53zj7og4txpby3vsusfefw5rrg5sii # ./root2
35 -# ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3
36 -# ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4
37 -# FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html
38 -# TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe
39 -```
test/sharness/t0116-gateway-cache/fixtures.car
Binary files a/test/sharness/t0116-gateway-cache/fixtures.car and /dev/null differ
test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record
Binary files a/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record and /dev/null differ
test/sharness/t0117-gateway-block.sh deleted
-90
@@ -1,90 +0,0 @@
1 -#!/usr/bin/env bash
2 -
3 -test_description="Test HTTP Gateway Raw Block (application/vnd.ipld.raw) Support"
4 -
5 -. lib/test-lib.sh
6 -
7 -test_init_ipfs
8 -test_launch_ipfs_daemon_without_network
9 -
10 -# Import test case
11 -# See the static fixtures in ./t0117-gateway-block/
12 -test_expect_success "Add the dir test directory" '
13 - ipfs dag import --pin-roots ../t0117-gateway-block/fixtures.car
14 -'
15 -ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./
16 -FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt
17 -
18 -# GET unixfs dir root block and compare it with `ipfs block get` output
19 -
20 - test_expect_success "GET with format=raw param returns a raw block" '
21 - ipfs block get "/ipfs/$ROOT_DIR_CID/dir" > expected &&
22 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/dir?format=raw" -o curl_ipfs_dir_block_param_output &&
23 - test_cmp expected curl_ipfs_dir_block_param_output
24 - '
25 -
26 - test_expect_success "GET for application/vnd.ipld.raw returns a raw block" '
27 - ipfs block get "/ipfs/$ROOT_DIR_CID/dir" > expected_block &&
28 - curl -sX GET -H "Accept: application/vnd.ipld.raw" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/dir" -o curl_ipfs_dir_block_accept_output &&
29 - test_cmp expected_block curl_ipfs_dir_block_accept_output
30 - '
31 -
32 - test_expect_success "GET for application/vnd.ipld.raw with single range request includes correct bytes" '
33 - echo -n "application" > expected_file_block_single_range &&
34 - curl -sX GET -H "Accept: application/vnd.ipld.raw" -H "Range: bytes=6-16" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" -o curl_ipfs_file_block_single_range &&
35 - test_cmp expected_file_block_single_range curl_ipfs_file_block_single_range
36 - '
37 -
38 - test_expect_success "GET for application/vnd.ipld.raw with multiple range request includes correct bytes" '
39 - curl -sX GET -H "Accept: application/vnd.ipld.raw" -H "Range: bytes=6-16,0-4" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" -o curl_ipfs_file_block_multiple_range &&
40 - test_should_contain "Content-Range: bytes 6-16/31" curl_ipfs_file_block_multiple_range &&
41 - test_should_contain "Content-Type: application/vnd.ipld.raw" curl_ipfs_file_block_multiple_range &&
42 - test_should_contain "application" curl_ipfs_file_block_multiple_range &&
43 - test_should_contain "Content-Range: bytes 0-4/31" curl_ipfs_file_block_multiple_range &&
44 - test_should_contain "hello" curl_ipfs_file_block_multiple_range
45 - '
46 -
47 -# Make sure expected HTTP headers are returned with the block bytes
48 -
49 - test_expect_success "GET response for application/vnd.ipld.raw has expected Content-Type" '
50 - curl -svX GET -H "Accept: application/vnd.ipld.raw" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/dir/ascii.txt" >/dev/null 2>curl_output &&
51 - test_should_contain "< Content-Type: application/vnd.ipld.raw" curl_output
52 - '
53 -
54 - test_expect_success "GET response for application/vnd.ipld.raw includes Content-Length" '
55 - BYTES=$(ipfs block get $FILE_CID | wc --bytes)
56 - test_should_contain "< Content-Length: $BYTES" curl_output
57 - '
58 -
59 - test_expect_success "GET response for application/vnd.ipld.raw includes Content-Disposition" '
60 - test_should_contain "< Content-Disposition: attachment\; filename=\"${FILE_CID}.bin\"" curl_output
61 - '
62 -
63 - test_expect_success "GET response for application/vnd.ipld.raw includes nosniff hint" '
64 - test_should_contain "< X-Content-Type-Options: nosniff" curl_output
65 - '
66 -
67 - test_expect_success "GET for application/vnd.ipld.raw with query filename includes Content-Disposition with custom filename" '
68 - curl -svX GET -H "Accept: application/vnd.ipld.raw" "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/dir/ascii.txt?filename=foobar.bin" >/dev/null 2>curl_output_filename &&
69 - test_should_contain "< Content-Disposition: attachment\; filename=\"foobar.bin\"" curl_output_filename
70 - '
71 -
72 -# Cache control HTTP headers
73 -# (basic checks, detailed behavior is tested in t0116-gateway-cache.sh)
74 -
75 - test_expect_success "GET response for application/vnd.ipld.raw includes Etag" '
76 - test_should_contain "< Etag: \"${FILE_CID}.raw\"" curl_output
77 - '
78 -
79 - test_expect_success "GET response for application/vnd.ipld.raw includes X-Ipfs-Path and X-Ipfs-Roots" '
80 - test_should_contain "< X-Ipfs-Path" curl_output &&
81 - test_should_contain "< X-Ipfs-Roots" curl_output
82 - '
83 -
84 - test_expect_success "GET response for application/vnd.ipld.raw includes Cache-Control" '
85 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_output
86 - '
87 -
88 -test_kill_ipfs_daemon
89 -
90 -test_done
test/sharness/t0117-gateway-block/README.md deleted
-21
@@ -1,21 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- fixtures.car
4 - - raw CARv1
5 -
6 -generated with:
7 -
8 -```sh
9 -# using ipfs version 0.18.1
10 -mkdir -p dir &&
11 -echo "hello application/vnd.ipld.raw" > dir/ascii.txt &&
12 -ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 dir) &&
13 -FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/dir/ascii.txt | cut -d "/" -f3) &&
14 -ipfs dag export $ROOT_DIR_CID > fixtures.car
15 -
16 -echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./
17 -echo FILE_CID=${FILE_CID} # ./dir/ascii.txt
18 -
19 -# ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./
20 -# FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt
21 -```
test/sharness/t0117-gateway-block/fixtures.car
Binary files a/test/sharness/t0117-gateway-block/fixtures.car and /dev/null differ
test/sharness/t0122-gateway-tar.sh deleted
-85
@@ -1,85 +0,0 @@
1 -#!/usr/bin/env bash
2 -
3 -test_description="Test HTTP Gateway TAR (application/x-tar) Support"
4 -
5 -. lib/test-lib.sh
6 -
7 -test_init_ipfs
8 -test_launch_ipfs_daemon_without_network
9 -
10 -OUTSIDE_ROOT_CID="bafybeicaj7kvxpcv4neaqzwhrqqmdstu4dhrwfpknrgebq6nzcecfucvyu"
11 -INSIDE_ROOT_CID="bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y"
12 -
13 -# Import test case
14 -# See the static fixtures in ./t0122-gateway-tar/
15 -test_expect_success "Add the test directory" '
16 - ipfs dag import --pin-roots ../t0122-gateway-tar/fixtures.car
17 -'
18 -DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir
19 -FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
20 -FILE_SIZE=34
21 -
22 -test_expect_success "GET TAR with format=tar and extract" '
23 - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x
24 -'
25 -
26 -test_expect_success "GET TAR with 'Accept: application/x-tar' and extract" '
27 - curl -H "Accept: application/x-tar" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" | tar -x
28 -'
29 -
30 -test_expect_success "GET TAR with format=tar has expected Content-Type" '
31 - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" > curl_output_filename 2>&1 &&
32 - test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
33 - test_should_contain "Etag: W/\"$FILE_CID.x-tar" curl_output_filename &&
34 - test_should_contain "Content-Type: application/x-tar" curl_output_filename
35 -'
36 -
37 -test_expect_success "GET TAR with 'Accept: application/x-tar' has expected Content-Type" '
38 - curl -sD - -H "Accept: application/x-tar" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output_filename 2>&1 &&
39 - test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
40 - test_should_contain "Etag: W/\"$FILE_CID.x-tar" curl_output_filename &&
41 - test_should_contain "Content-Type: application/x-tar" curl_output_filename
42 -'
43 -
44 -test_expect_success "GET TAR has expected root file" '
45 - rm -rf outputDir && mkdir outputDir &&
46 - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x -C outputDir &&
47 - test -f "outputDir/$FILE_CID" &&
48 - echo "I am a txt file on path with utf8" > expected &&
49 - test_cmp expected outputDir/$FILE_CID
50 -'
51 -
52 -test_expect_success "GET TAR has expected root directory" '
53 - rm -rf outputDir && mkdir outputDir &&
54 - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=tar" | tar -x -C outputDir &&
55 - test -d "outputDir/$DIR_CID" &&
56 - echo "I am a txt file on path with utf8" > expected &&
57 - test_cmp expected outputDir/$DIR_CID/ą/ę/file-źł.txt
58 -'
59 -
60 -test_expect_success "GET TAR with explicit ?filename= succeeds with modified Content-Disposition header" "
61 - curl -fo actual -D actual_headers 'http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?filename=testтест.tar&format=tar' &&
62 - grep -F 'Content-Disposition: attachment; filename=\"test____.tar\"; filename*=UTF-8'\'\''test%D1%82%D0%B5%D1%81%D1%82.tar' actual_headers
63 -"
64 -
65 -test_expect_success "Add CARs with relative paths to test with" '
66 - ipfs dag import --pin-roots ../t0122-gateway-tar/outside-root.car > import_output &&
67 - test_should_contain $OUTSIDE_ROOT_CID import_output &&
68 - ipfs dag import --pin-roots ../t0122-gateway-tar/inside-root.car > import_output &&
69 - test_should_contain $INSIDE_ROOT_CID import_output
70 -'
71 -
72 -test_expect_success "GET TAR with relative paths outside root fails" '
73 - curl -o - "http://127.0.0.1:$GWAY_PORT/ipfs/$OUTSIDE_ROOT_CID?format=tar" > curl_output_filename &&
74 - test_should_contain "relative UnixFS paths outside the root are now allowed" curl_output_filename
75 -'
76 -
77 -test_expect_success "GET TAR with relative paths inside root works" '
78 - rm -rf outputDir && mkdir outputDir &&
79 - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$INSIDE_ROOT_CID?format=tar" | tar -x -C outputDir &&
80 - test -f outputDir/$INSIDE_ROOT_CID/foobar/file
81 -'
82 -
83 -test_kill_ipfs_daemon
84 -
85 -test_done
test/sharness/t0122-gateway-tar/README.md deleted
-37
@@ -1,37 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- inside-root.car
4 -
5 -- outside-root.car
6 -
7 -- fixtures.car
8 - - raw CARv1
9 -
10 -generated with:
11 -
12 -```sh
13 -# ipfs version 0.18.1
14 -
15 -mkdir -p rootDir/ipfs &&
16 -mkdir -p rootDir/ipns &&
17 -mkdir -p rootDir/api &&
18 -mkdir -p rootDir/ą/ę &&
19 -echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
20 -echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
21 -echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
22 -echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
23 -DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
24 -FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
25 -FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
26 -echo "$FILE_CID / $FILE_SIZE"
27 -
28 -echo DIR_CID=${DIR_CID} # ./rootDir
29 -echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt
30 -echo FILE_SIZE=${FILE_SIZE}
31 -
32 -ipfs dag export ${DIR_CID} > ./fixtures.car
33 -
34 -# DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir
35 -# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
36 -# FILE_SIZE=34
37 -```
test/sharness/t0122-gateway-tar/fixtures.car
Binary files a/test/sharness/t0122-gateway-tar/fixtures.car and /dev/null differ
test/sharness/t0122-gateway-tar/inside-root.car
Binary files a/test/sharness/t0122-gateway-tar/inside-root.car and /dev/null differ
test/sharness/t0122-gateway-tar/outside-root.car
Binary files a/test/sharness/t0122-gateway-tar/outside-root.car and /dev/null differ
test/sharness/t0123-gateway-json-cbor.sh deleted
-379
@@ -1,379 +0,0 @@
1 -#!/usr/bin/env bash
2 -
3 -test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and DAG-CBOR (application/vnd.ipld.dag-cbor) Support"
4 -
5 -. lib/test-lib.sh
6 -
7 -test_init_ipfs
8 -test_launch_ipfs_daemon_without_network
9 -
10 -# Import test case
11 -# See the static fixtures in ./t0123-gateway-json-cbor/
12 -test_expect_success "Add the test directory" '
13 - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/fixtures.car
14 -'
15 -DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir
16 -FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json
17 -FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
18 -FILE_SIZE=34
19 -
20 -## Quick regression check for JSON stored on UnixFS:
21 -## it has nothing to do with DAG-JSON and JSON codecs,
22 -## but a lot of JSON data is stored on UnixFS and is requested with or without various hints
23 -## and we want to avoid surprises like https://github.com/protocol/bifrost-infra/issues/2290
24 -test_expect_success "GET UnixFS file with JSON bytes is returned with application/json Content-Type" '
25 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_JSON_CID" > curl_output 2>&1 &&
26 - curl -sD headers_accept -H "Accept: application/json" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_JSON_CID" > curl_output_accept 2>&1 &&
27 - ipfs cat $FILE_JSON_CID > ipfs_cat_output 2>&1 &&
28 - test_should_contain "Content-Type: application/json" headers &&
29 - test_should_contain "Content-Type: application/json" headers_accept &&
30 - test_cmp ipfs_cat_output curl_output &&
31 - test_cmp curl_output curl_output_accept
32 -'
33 -
34 -
35 -## Reading UnixFS (data encoded with dag-pb codec) as DAG-CBOR and DAG-JSON
36 -## (returns representation defined in https://ipld.io/specs/codecs/dag-pb/spec/#logical-format)
37 -
38 -test_dag_pb_conversion () {
39 - name=$1
40 - format=$2
41 - disposition=$3
42 -
43 - test_expect_success "GET UnixFS file as $name with format=dag-$format converts to the expected Content-Type" '
44 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=dag-$format" > curl_output 2>&1 &&
45 - ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output 2>&1 &&
46 - test_cmp ipfs_dag_get_output curl_output &&
47 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers &&
48 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" headers &&
49 - test_should_not_contain "Content-Type: application/$format" headers
50 - '
51 -
52 - test_expect_success "GET UnixFS directory as $name with format=dag-$format converts to the expected Content-Type" '
53 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=dag-$format" > curl_output 2>&1 &&
54 - ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output 2>&1 &&
55 - test_cmp ipfs_dag_get_output curl_output &&
56 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers &&
57 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${DIR_CID}.${format}\"" headers &&
58 - test_should_not_contain "Content-Type: application/$format" headers
59 - '
60 -
61 - test_expect_success "GET UnixFS as $name with 'Accept: application/vnd.ipld.dag-$format' converts to the expected Content-Type" '
62 - curl -sD - -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 &&
63 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" curl_output &&
64 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output &&
65 - test_should_not_contain "Content-Type: application/$format" curl_output
66 - '
67 -
68 - test_expect_success "GET UnixFS as $name with 'Accept: foo, application/vnd.ipld.dag-$format,bar' converts to the expected Content-Type" '
69 - curl -sD - -H "Accept: foo, application/vnd.ipld.dag-$format,text/plain" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 &&
70 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output
71 - '
72 -
73 - test_expect_success "GET UnixFS with format=$format (not dag-$format) is no-op (no conversion)" '
74 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=$format" > curl_output 2>&1 &&
75 - ipfs cat $FILE_CID > cat_output &&
76 - test_cmp cat_output curl_output &&
77 - test_should_contain "Content-Type: text/plain" headers &&
78 - test_should_not_contain "Content-Type: application/$format" headers &&
79 - test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers
80 - '
81 -
82 - test_expect_success "GET UnixFS with 'Accept: application/$format' (not dag-$format) is no-op (no conversion)" '
83 - curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 &&
84 - ipfs cat $FILE_CID > cat_output &&
85 - test_cmp cat_output curl_output &&
86 - test_should_contain "Content-Type: text/plain" headers &&
87 - test_should_not_contain "Content-Type: application/$format" headers &&
88 - test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers
89 - '
90 -}
91 -
92 -test_dag_pb_conversion "DAG-JSON" "json" "inline"
93 -test_dag_pb_conversion "DAG-CBOR" "cbor" "attachment"
94 -
95 -
96 -# Requesting CID with plain json (0x0200) and cbor (0x51) codecs
97 -# (note these are not UnixFS, not DAG-* variants, just raw block identified by a CID with a special codec)
98 -test_plain_codec () {
99 - name=$1
100 - format=$2
101 - disposition=$3
102 -
103 - # no explicit format, just codec in CID
104 - test_expect_success "GET $name without Accept or format= has expected $format Content-Type and body as-is" '
105 - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) &&
106 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 &&
107 - ipfs block get $CID > ipfs_block_output 2>&1 &&
108 - test_cmp ipfs_block_output curl_output &&
109 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers &&
110 - test_should_contain "Content-Type: application/$format" headers
111 - '
112 -
113 - # explicit format still gives correct output, just codec in CID
114 - test_expect_success "GET $name with ?format= has expected $format Content-Type and body as-is" '
115 - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) &&
116 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" > curl_output 2>&1 &&
117 - ipfs block get $CID > ipfs_block_output 2>&1 &&
118 - test_cmp ipfs_block_output curl_output &&
119 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers &&
120 - test_should_contain "Content-Type: application/$format" headers
121 - '
122 -
123 - # explicit format still gives correct output, just codec in CID
124 - test_expect_success "GET $name with Accept has expected $format Content-Type and body as-is" '
125 - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) &&
126 - curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 &&
127 - ipfs block get $CID > ipfs_block_output 2>&1 &&
128 - test_cmp ipfs_block_output curl_output &&
129 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers &&
130 - test_should_contain "Content-Type: application/$format" headers
131 - '
132 -
133 - # explicit dag-* format passed, attempt to parse as dag* variant
134 - ## Note: this works only for simple JSON that can be upgraded to DAG-JSON.
135 - test_expect_success "GET $name with format=dag-$format interprets $format as dag-* variant and produces expected Content-Type and body" '
136 - CID=$(echo "{ \"test\": \"plain-json-that-can-also-be-dag-json\" }" | ipfs dag put --input-codec json --store-codec $format) &&
137 - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" > curl_output_param 2>&1 &&
138 - ipfs dag get --output-codec dag-$format $CID > ipfs_dag_get_output 2>&1 &&
139 - test_cmp ipfs_dag_get_output curl_output_param &&
140 - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers &&
141 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers &&
142 - curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output_accept 2>&1 &&
143 - test_cmp curl_output_param curl_output_accept
144 - '
145 -
146 -}
147 -
148 -test_plain_codec "plain JSON codec" "json" "inline"
149 -test_plain_codec "plain CBOR codec" "cbor" "attachment"
150 -
151 -## Pathing, traversal over DAG-JSON and DAG-CBOR
152 -
153 -DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim"
154 -DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq"
155 -DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke"
156 -
157 -test_expect_success "Add CARs for path traversal and DAG-PB representation tests" '
158 - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-cbor-traversal.car > import_output &&
159 - test_should_contain $DAG_CBOR_TRAVERSAL_CID import_output &&
160 - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-json-traversal.car > import_output &&
161 - test_should_contain $DAG_JSON_TRAVERSAL_CID import_output &&
162 - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-pb.car > import_output &&
163 - test_should_contain $DAG_PB_CID import_output
164 -'
165 -
166 -IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2
167 -IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l
168 -
169 -test_expect_success "Add ipns records for path traversal and DAG-PB representation tests" '
170 - ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record &&
171 - ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record
172 -'
173 -
174 -test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" '
175 - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo?format=dag-json" > curl_output 2>&1 &&
176 - test_should_contain "501 Not Implemented" curl_output &&
177 - test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output
178 -'
179 -
180 -test_expect_success "GET DAG-JSON traverses multiple links" '
181 - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 &&
182 - jq --sort-keys . curl_output > actual &&
183 - echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected &&
184 - test_cmp expected actual
185 -'
186 -
187 -test_expect_success "GET DAG-CBOR traversal returns 501 if there is path remainder" '
188 - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo?format=dag-cbor" > curl_output 2>&1 &&
189 - test_should_contain "501 Not Implemented" curl_output &&
190 - test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output
191 -'
192 -
193 -test_expect_success "GET DAG-CBOR traverses multiple links" '
194 - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 &&
195 - jq --sort-keys . curl_output > actual &&
196 - echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected &&
197 - test_cmp expected actual
198 -'
199 -
200 -## NATIVE TESTS for DAG-JSON (0x0129) and DAG-CBOR (0x71):
201 -## DAG- regression tests for core behaviors when native DAG-(CBOR|JSON) is requested
202 -
203 -test_native_dag () {
204 - name=$1
205 - format=$2
206 - disposition=$3
207 - CID=$4
208 - IPNS_ID=$5
209 -
210 - # GET without explicit format and Accept: text/html returns raw block
211 -
212 - test_expect_success "GET $name from /ipfs without explicit format returns the same payload as the raw block" '
213 - ipfs block get "/ipfs/$CID" > expected &&
214 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o curl_output &&
215 - test_cmp expected curl_output
216 - '
217 -
218 - # GET dag-cbor block via Accept and ?format and ensure both are the same as `ipfs block get` output
219 -
220 - test_expect_success "GET $name from /ipfs with format=dag-$format returns the same payload as the raw block" '
221 - ipfs block get "/ipfs/$CID" > expected &&
222 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o curl_ipfs_dag_param_output &&
223 - test_cmp expected curl_ipfs_dag_param_output
224 - '
225 -
226 - test_expect_success "GET $name from /ipfs for application/$format returns the same payload as format=dag-$format" '
227 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected &&
228 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output &&
229 - test_cmp expected plain_output
230 - '
231 -
232 - test_expect_success "GET $name from /ipfs with application/vnd.ipld.dag-$format returns the same payload as the raw block" '
233 - ipfs block get "/ipfs/$CID" > expected_block &&
234 - curl -sX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o curl_ipfs_dag_block_accept_output &&
235 - test_cmp expected_block curl_ipfs_dag_block_accept_output
236 - '
237 -
238 - # Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes
239 -
240 - test_expect_success "GET $name with format=$format returns same payload as format=dag-$format but with plain Content-Type" '
241 - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected &&
242 - curl -sD plain_headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output &&
243 - test_should_contain "Content-Type: application/$format" plain_headers &&
244 - test_cmp expected plain_output
245 - '
246 -
247 - test_expect_success "GET $name with Accept: application/$format returns same payload as application/vnd.ipld.dag-$format but with plain Content-Type" '
248 - curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > expected &&
249 - curl -sD plain_headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > plain_output &&
250 - test_should_contain "Content-Type: application/$format" plain_headers &&
251 - test_cmp expected plain_output
252 - '
253 -
254 -
255 - # Make sure expected HTTP headers are returned with the dag- block
256 -
257 - test_expect_success "GET response for application/vnd.ipld.dag-$format has expected Content-Type" '
258 - curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" >/dev/null 2>curl_output &&
259 - test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output
260 - '
261 -
262 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Length" '
263 - BYTES=$(ipfs block get $CID | wc --bytes)
264 - test_should_contain "< Content-Length: $BYTES" curl_output
265 - '
266 -
267 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Disposition" '
268 - test_should_contain "< Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" curl_output
269 - '
270 -
271 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes nosniff hint" '
272 - test_should_contain "< X-Content-Type-Options: nosniff" curl_output
273 - '
274 -
275 - test_expect_success "GET for application/vnd.ipld.dag-$format with query filename includes Content-Disposition with custom filename" '
276 - curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?filename=foobar.$format" >/dev/null 2>curl_output_filename &&
277 - test_should_contain "< Content-Disposition: ${disposition}\; filename=\"foobar.$format\"" curl_output_filename
278 - '
279 -
280 - test_expect_success "GET for application/vnd.ipld.dag-$format with ?download=true forces Content-Disposition: attachment" '
281 - curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?filename=foobar.$format&download=true" >/dev/null 2>curl_output_filename &&
282 - test_should_contain "< Content-Disposition: attachment" curl_output_filename
283 - '
284 -
285 - # Cache control HTTP headers
286 - # (basic checks, detailed behavior is tested in t0116-gateway-cache.sh)
287 -
288 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Etag" '
289 - test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output
290 - '
291 -
292 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes X-Ipfs-Path and X-Ipfs-Roots" '
293 - test_should_contain "< X-Ipfs-Path" curl_output &&
294 - test_should_contain "< X-Ipfs-Roots" curl_output
295 - '
296 -
297 - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Cache-Control" '
298 - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_output
299 - '
300 -
301 - # HTTP HEAD behavior
302 - test_expect_success "HEAD $name with no explicit format returns HTTP 200" '
303 - curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o output &&
304 - test_should_contain "HTTP/1.1 200 OK" output &&
305 - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" output &&
306 - test_should_contain "Content-Length: " output
307 - '
308 - test_expect_success "HEAD $name with an explicit DAG-JSON format returns HTTP 200" '
309 - curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-json" -o output &&
310 - test_should_contain "HTTP/1.1 200 OK" output &&
311 - test_should_contain "Etag: \"$CID.dag-json\"" output &&
312 - test_should_contain "Content-Type: application/vnd.ipld.dag-json" output &&
313 - test_should_contain "Content-Length: " output
314 - '
315 - test_expect_success "HEAD $name with only-if-cached for missing block returns HTTP 412 Precondition Failed" '
316 - MISSING_CID=$(echo "{\"t\": \"$(date +%s)\"}" | ipfs dag put --store-codec=dag-${format}) &&
317 - ipfs block rm -f -q $MISSING_CID &&
318 - curl -I -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$MISSING_CID" -o output &&
319 - test_should_contain "HTTP/1.1 412 Precondition Failed" output
320 - '
321 -
322 - # IPNS behavior (should be same as immutable /ipfs, but with different caching headers)
323 - # To keep tests small we only confirm payload is the same, and then only test delta around caching headers.
324 -
325 - test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" '
326 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o ipfs_output &&
327 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" -o ipns_output &&
328 - test_cmp ipfs_output ipns_output
329 - '
330 -
331 - test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" '
332 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o ipfs_output &&
333 - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID?format=dag-$format" -o ipns_output &&
334 - test_cmp ipfs_output ipns_output
335 - '
336 -
337 - test_expect_success "GET $name from /ipns with explicit application/vnd.ipld.dag-$format has expected headers" '
338 - curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" >/dev/null 2>curl_output &&
339 - test_should_not_contain "Cache-Control" curl_output &&
340 - test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output &&
341 - test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output &&
342 - test_should_contain "< X-Ipfs-Path" curl_output &&
343 - test_should_contain "< X-Ipfs-Roots" curl_output
344 - '
345 -
346 -
347 - # When Accept header includes text/html and no explicit format is requested for DAG-(CBOR|JSON)
348 - # The gateway returns generated HTML index (see dag-index-html) for web browsers (similar to dir-index-html returned for unixfs dirs)
349 - # As this is generated, we don't return immutable Cache-Control, even on /ipfs (same as for dir-index-html)
350 -
351 - test_expect_success "GET $name on /ipfs with Accept: text/html returns HTML (dag-index-html)" '
352 - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID/" > curl_output 2>&1 &&
353 - test_should_not_contain "Content-Disposition" curl_output &&
354 - test_should_not_contain "Cache-Control" curl_output &&
355 - test_should_contain "Etag: \"DagIndex-" curl_output &&
356 - test_should_contain "Content-Type: text/html" curl_output &&
357 - test_should_contain "</html>" curl_output
358 - '
359 -
360 - test_expect_success "GET $name on /ipns with Accept: text/html returns HTML (dag-index-html)" '
361 - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID/" > curl_output 2>&1 &&
362 - test_should_not_contain "Content-Disposition" curl_output &&
363 - test_should_not_contain "Cache-Control" curl_output &&
364 - test_should_contain "Etag: \"DagIndex-" curl_output &&
365 - test_should_contain "Content-Type: text/html" curl_output &&
366 - test_should_contain "</html>" curl_output
367 - '
368 -
369 -
370 -}
371 -
372 -test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID" ${IPNS_ID_DAG_JSON}
373 -test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID" ${IPNS_ID_DAG_CBOR}
374 -
375 -test_kill_ipfs_daemon
376 -
377 -test_done
378 -
379 -# vim: set ts=2 sw=2 et:
test/sharness/t0123-gateway-json-cbor/README.md deleted
-66
@@ -1,66 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- dag-cbor-traversal.car
4 -
5 -- dag-json-traversal.car
6 -
7 -- dag-pb.car
8 -
9 -- dag-pb.json
10 -
11 -- fixtures.car
12 - - raw CARv1
13 -
14 -generated with:
15 -
16 -```sh
17 -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
18 -
19 -mkdir -p rootDir/ipfs &&
20 -mkdir -p rootDir/ipns &&
21 -mkdir -p rootDir/api &&
22 -mkdir -p rootDir/ą/ę &&
23 -echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json &&
24 -echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
25 -echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
26 -echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
27 -echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
28 -DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
29 -FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) &&
30 -FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
31 -FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
32 -echo "$FILE_CID / $FILE_SIZE"
33 -
34 -echo DIR_CID=${DIR_CID} # ./rootDir
35 -echo FILE_JSON_CID=${FILE_JSON_CID} # ./rootDir/ą/ę/t.json
36 -echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt
37 -echo FILE_SIZE=${FILE_SIZE}
38 -
39 -ipfs dag export ${DIR_CID} > fixtures.car
40 -
41 -DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim"
42 -DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq"
43 -DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke"
44 -
45 -test_native_dag() {
46 - NAME=$1
47 - CID=$2
48 -
49 - IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${NAME}_test_key | head -n1 | tr -d "\n")
50 - ipfs name publish --key ${NAME}_test_key --allow-offline --ttl=876600h --lifetime=876600h -Q "/ipfs/${CID}" > name_publish_out
51 -
52 - ipfs routing get /ipns/${IPNS_ID} > ${IPNS_ID}.ipns-record
53 -
54 - echo "IPNS_ID_${NAME}=${IPNS_ID}"
55 -}
56 -
57 -test_native_dag "DAG_JSON" "$DAG_JSON_TRAVERSAL_CID"
58 -test_native_dag "DAG_CBOR" "$DAG_CBOR_TRAVERSAL_CID"
59 -
60 -# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir
61 -# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json
62 -# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
63 -# FILE_SIZE=34
64 -# IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2
65 -# IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l
66 -```
test/sharness/t0123-gateway-json-cbor/dag-cbor-traversal.car
Binary files a/test/sharness/t0123-gateway-json-cbor/dag-cbor-traversal.car and /dev/null differ
test/sharness/t0123-gateway-json-cbor/dag-json-traversal.car
Binary files a/test/sharness/t0123-gateway-json-cbor/dag-json-traversal.car and /dev/null differ
test/sharness/t0123-gateway-json-cbor/dag-pb.car
Binary files a/test/sharness/t0123-gateway-json-cbor/dag-pb.car and /dev/null differ
test/sharness/t0123-gateway-json-cbor/dag-pb.json deleted
-23
@@ -1,23 +0,0 @@
1 -{
2 - "Data": {
3 - "/": {
4 - "bytes": "CAE"
5 - }
6 - },
7 - "Links": [
8 - {
9 - "Hash": {
10 - "/": "bafybeidryarwh34ygbtyypbu7qjkl4euiwxby6cql6uvosonohkq2kwnkm"
11 - },
12 - "Name": "foo",
13 - "Tsize": 69
14 - },
15 - {
16 - "Hash": {
17 - "/": "bafkreic3ondyhizrzeoufvoodehinugpj3ecruwokaygl7elezhn2khqfa"
18 - },
19 - "Name": "foo.txt",
20 - "Tsize": 13
21 - }
22 - ]
23 -}
test/sharness/t0123-gateway-json-cbor/fixtures.car
Binary files a/test/sharness/t0123-gateway-json-cbor/fixtures.car and /dev/null differ
test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record
Binary files a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record and /dev/null differ
test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record
Binary files a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record and /dev/null differ
test/sharness/t0124-gateway-ipns-record.sh deleted
-58
@@ -1,58 +0,0 @@
1 -#!/usr/bin/env bash
2 -
3 -test_description="Test HTTP Gateway IPNS Record (application/vnd.ipfs.ipns-record) Support"
4 -
5 -. lib/test-lib.sh
6 -
7 -test_init_ipfs
8 -test_launch_ipfs_daemon
9 -
10 -# Import test case
11 -# See the static fixtures in ./t0124-gateway-ipns-record/
12 -IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab
13 -FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
14 -test_expect_success "Add the test directory & IPNS records" '
15 - ipfs dag import ../t0124-gateway-ipns-record/fixtures.car &&
16 - ipfs routing put /ipns/${IPNS_KEY} ../t0124-gateway-ipns-record/${IPNS_KEY}.ipns-record
17 -'
18 -
19 -test_expect_success "Create and Publish IPNS Key" '
20 - curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
21 - test_should_contain "Hello IPFS" curl_output_filename
22 -'
23 -
24 -test_expect_success "GET KEY with format=ipns-record and validate key" '
25 - curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename &&
26 - ipfs name inspect --verify $IPNS_KEY < curl_output_filename > verify_output &&
27 - test_should_contain "$FILE_CID" verify_output
28 -'
29 -
30 -test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' and validate key" '
31 - curl -H "Accept: application/vnd.ipfs.ipns-record" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
32 - ipfs name inspect --verify $IPNS_KEY < curl_output_filename > verify_output &&
33 - test_should_contain "$FILE_CID" verify_output
34 -'
35 -
36 -test_expect_success "GET KEY with format=ipns-record has expected HTTP headers" '
37 - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename 2>&1 &&
38 - test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
39 - test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
40 - test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
41 -'
42 -
43 -test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' has expected HTTP headers" '
44 - curl -H "Accept: application/vnd.ipfs.ipns-record" -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename 2>&1 &&
45 - test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
46 - test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
47 - test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
48 -'
49 -
50 -test_expect_success "GET KEY with expliciy ?filename= succeeds with modified Content-Disposition header" '
51 - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record&filename=testтест.ipns-record" > curl_output_filename 2>&1 &&
52 - 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 &&
53 - test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename
54 -'
55 -
56 -test_kill_ipfs_daemon
57 -
58 -test_done
test/sharness/t0124-gateway-ipns-record/README.md deleted
-27
@@ -1,27 +0,0 @@
1 -# Dataset description/sources
2 -
3 -- fixtures.car
4 - - raw CARv1
5 -
6 -- k51....ipns-record
7 - - ipns record, encoded with protocol buffer
8 -
9 -generated with:
10 -
11 -```sh
12 -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
13 -FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q)
14 -IPNS_KEY=$(ipfs key gen ipns-record)
15 -
16 -ipfs dag export ${FILE_CID} > fixtures.car
17 -
18 -# publish a record valid for a 100 years
19 -ipfs name publish --key=ipns-record --quieter --ttl=876600h --lifetime=876600h /ipfs/${FILE_CID}
20 -ipfs routing get /ipns/${IPNS_KEY} > ${IPNS_KEY}.ipns-record
21 -
22 -echo IPNS_KEY=${IPNS_KEY}
23 -echo FILE_CID=${FILE_CID} # A file containing "Hello IPFS"
24 -
25 -# IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab
26 -# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
27 -```
test/sharness/t0124-gateway-ipns-record/fixtures.car
Binary files a/test/sharness/t0124-gateway-ipns-record/fixtures.car and /dev/null differ
test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record
Binary files a/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record and /dev/null differ