diff --git a/test/sharness/t0026-id.sh b/test/sharness/t0026-id.sh index 5ae5f500609..d4248c56295 100755 --- a/test/sharness/t0026-id.sh +++ b/test/sharness/t0026-id.sh @@ -61,6 +61,8 @@ test_expect_success "checking AgentVersion with suffix (fetched via libp2p ident ipfsi 1 id "$(ipfsi 0 config Identity.PeerID)" -f "\n" > actual-libp2p-identify-agent-version && test_cmp expected-identify-agent-version actual-libp2p-identify-agent-version ' +iptb stop + test_kill_ipfs_daemon diff --git a/test/sharness/t0113-gateway-symlink.sh b/test/sharness/t0113-gateway-symlink.sh deleted file mode 100755 index 2cb4f319537..00000000000 --- a/test/sharness/t0113-gateway-symlink.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) Protocol Labs - -test_description="Test symlink support on the HTTP gateway" - -. lib/test-lib.sh - -test_init_ipfs -test_launch_ipfs_daemon - -# Import test case -# See the static fixtures in ./t0113-gateway-symlink/ -test_expect_success "Add the test directory with symlinks" ' - ipfs dag import --pin-roots ../t0113-gateway-symlink/testfiles.car -' -ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt # ./testfiles/ - -test_expect_success "Test the directory listing" ' - curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/" > list_response && - test_should_contain ">foo<" list_response && - test_should_contain ">bar<" list_response -' - -test_expect_success "Test the symlink" ' - curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/bar" > bar_actual && - echo -n "foo" > bar_expected && - test_cmp bar_expected bar_actual -' - -test_kill_ipfs_daemon - -test_done diff --git a/test/sharness/t0113-gateway-symlink/README.md b/test/sharness/t0113-gateway-symlink/README.md deleted file mode 100644 index 31a257bdded..00000000000 --- a/test/sharness/t0113-gateway-symlink/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Dataset description/sources - -- testfiles.car - - raw CARv1 - -generated with: - -```sh -# using ipfs version 0.18.1 -mkdir testfiles && -echo "content" > testfiles/foo && -ln -s foo testfiles/bar && -ROOT_DIR_CID=$(ipfs add -Qr testfiles) && -ipfs dag export $ROOT_DIR_CID > testfiles.car - -# ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt -``` diff --git a/test/sharness/t0113-gateway-symlink/testfiles.car b/test/sharness/t0113-gateway-symlink/testfiles.car deleted file mode 100644 index 88e5825f302..00000000000 Binary files a/test/sharness/t0113-gateway-symlink/testfiles.car and /dev/null differ diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index 8be102c4f41..2596bb49254 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -162,6 +162,9 @@ test_localhost_gateway_response_should_contain \ "http://localhost:$GWAY_PORT/ipfs/$DIR_CID/" \ "Location: http://$DIR_CID.ipfs.localhost:$GWAY_PORT/" +# Kubo specific end-to-end test +# (independend of gateway-conformance) + # We return human-readable body with HTTP 301 so existing cli scripts that use path-based # gateway are informed to enable following HTTP redirects test_localhost_gateway_response_should_contain \ @@ -169,6 +172,8 @@ test_localhost_gateway_response_should_contain \ "http://localhost:$GWAY_PORT/ipfs/$CIDv1" \ ">Moved Permanently" +# end Kubo specific end-to-end test + test_localhost_gateway_response_should_contain \ "request for localhost/ipfs/{CIDv0} redirects to CIDv1 representation in subdomain" \ "http://localhost:$GWAY_PORT/ipfs/$CIDv0" \ @@ -188,11 +193,16 @@ test_localhost_gateway_response_should_contain \ # /ipns/ +# Kubo specific end-to-end test +# (independend of gateway-conformance) + test_localhost_gateway_response_should_contain \ "request for localhost/ipns/{fqdn} redirects to DNSLink in subdomain" \ "http://localhost:$GWAY_PORT/ipns/en.wikipedia-on-ipfs.org/wiki" \ "Location: http://en.wikipedia-on-ipfs.org.ipns.localhost:$GWAY_PORT/wiki" +# end Kubo specific end-to-end test + # API on localhost subdomain gateway # /api/v0 present on the root hostname @@ -236,6 +246,10 @@ test_localhost_gateway_response_should_contain \ "http://${DIR_CID}.ipfs.localhost:$GWAY_PORT/ipfs/file.txt" \ "I am a txt file" +# Kubo specific end-to-end test +# (independend of gateway-conformance) +# This tests link to parent specific to boxo + relative pathing end-to-end tests specific to Kubo. + # {CID}.ipfs.localhost/sub/dir (Directory Listing) DIR_HOSTNAME="${DIR_CID}.ipfs.localhost:$GWAY_PORT" @@ -255,7 +269,7 @@ test_expect_success "request for deep path resource at {cid}.ipfs.localhost/sub/ curl -s --resolve $DIR_HOSTNAME:127.0.0.1 "http://$DIR_HOSTNAME/ipfs/ipns/bar" > list_response && test_should_contain "text-file-content" list_response ' - +# end Kubo specific end-to-end test # *.ipns.localhost @@ -441,6 +455,10 @@ test_hostname_gateway_response_should_contain \ "http://127.0.0.1:$GWAY_PORT/ipfs/$CIDv1" \ "404 Not Found" +# Kubo specific end-to-end test +# (independend of gateway-conformance) +# HTML specific to Boxo/Kubo, and relative pathing specific to code in Kubo + # {CID}.ipfs.example.com/sub/dir (Directory Listing) DIR_FQDN="${DIR_CID}.ipfs.example.com" @@ -464,6 +482,8 @@ test_expect_success "valid breadcrumb links in the header of directory listing a test_should_contain "/ipfs/${DIR_CID}/ipfs/ipns" list_response ' +# end Kubo specific end-to-end test + test_expect_success "request for deep path resource {cid}.ipfs.example.com/sub/dir/file" ' curl -s -H "Host: $DIR_FQDN" http://127.0.0.1:$GWAY_PORT/ipfs/ipns/bar > list_response && 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 test_should_contain \"Location: https://$CIDv1.ipfs.example.com/\" response " +# Kubo specific end-to-end test +# (independend of gateway-conformance) +# test cofiguration beign wired up correctly end-to-end + ## ============================================================================ ## Test support for wildcards in gateway config ## ============================================================================ @@ -966,3 +990,5 @@ test_expect_success "clean up ipfs dir" ' ' test_done + +# end Kubo specific end-to-end test \ No newline at end of file diff --git a/test/sharness/t0116-gateway-cache.sh b/test/sharness/t0116-gateway-cache.sh old mode 100755 new mode 100644 index 2c0f2f83301..0986ffa419a --- a/test/sharness/t0116-gateway-cache.sh +++ b/test/sharness/t0116-gateway-cache.sh @@ -39,156 +39,6 @@ test_expect_success "Add the test directory" ' ipfs routing put --allow-offline /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record ' -# GET /ipfs/ - # unixfs - test_expect_success "GET for /ipfs/ unixfs dir listing succeeds" ' - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT1_CID/root2/root3/" >/dev/null 2>curl_ipfs_dir_listing_output - ' - test_expect_success "GET for /ipfs/ unixfs dir with index.html succeeds" ' - 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 - ' - test_expect_success "GET for /ipfs/ unixfs file succeeds" ' - 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 - ' - # unixfs dir as dag-json - test_expect_success "GET for /ipfs/ unixfs dir as DAG-JSON succeeds" ' - 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 && - 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 - ' -# GET /ipns/ - # unixfs - test_expect_success "GET for /ipns/ unixfs dir listing succeeds" ' - curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipns/$TEST_IPNS_ID/root2/root3/" >/dev/null 2>curl_ipns_dir_listing_output - ' - test_expect_success "GET for /ipns/ unixfs dir with index.html succeeds" ' - 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 - ' - test_expect_success "GET for /ipns/ unixfs file succeeds" ' - 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 - ' - # unixfs dir as dag-json - test_expect_success "GET for /ipns/ unixfs dir as DAG-JSON succeeds" ' - 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 && - 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 - ' - -# Cache-Control - -# Cache-Control: immutable /ipfs/ file - test_expect_success "GET /ipfs/ unixfs file has expected Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_file_output - ' -# Cache-Control: generated /ipfs/dir/ (listing) - # TODO: test_should_contain "< Cache-Control: public, max-age=TBD" curl_ipfs_dir_listing_output - test_expect_success "GET /ipfs/ unixfs dir listing has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_dir_listing_output - ' -# Cache-Control: immutable /ipfs/dir/ (index.html) - test_expect_success "GET /ipfs/ unixfs dir with index.html has expected Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_index.html_output - ' -# Cache-Control: immutable /ipfs/ unixfs dir as dag-json - test_expect_success "GET /ipfs/ dag-json has expected Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_dag-json_output - ' -# Cache-Control: immutable /ipfs/ unixfs dir as json - test_expect_success "GET /ipfs/ unixfs dir as json has expected Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_ipfs_dir_json_output - ' -# Cache-Control: mutable /ipns/ file - test_expect_success "GET /ipns/ unixfs file has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_file_output - ' -# Cache-Control: mutable /ipns/dir/ (generated listing) - test_expect_success "GET /ipns/ unixfs dir listing has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_dir_listing_output - ' -# Cache-Control: mutable /ipns/dir/ (index.html) - test_expect_success "GET /ipns/ unixfs dir with index.html has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_dir_index.html_output - ' -# Cache-Control: mutable /ipns/dir/ as dag-json - test_expect_success "GET /ipns/ unixfs dir as dag-json has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_dir_dag-json_output - ' -# Cache-Control: mutable /ipns/dir/ as json - test_expect_success "GET /ipns/ unixfs dir as json has no Cache-Control" ' - test_should_not_contain "< Cache-Control" curl_ipns_dir_json_output - ' - -# Cache-Control: only-if-cached - test_expect_success "HEAD for /ipfs/ with only-if-cached succeeds when in local datastore" ' - 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 && - cat curl_onlyifcached_postitive_head && - grep "< HTTP/1.1 200 OK" curl_onlyifcached_postitive_head - ' - test_expect_success "HEAD for /ipfs/ with only-if-cached fails when not in local datastore" ' - 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 && - cat curl_onlyifcached_negative_head && - grep "< HTTP/1.1 412 Precondition Failed" curl_onlyifcached_negative_head - ' - test_expect_success "GET for /ipfs/ with only-if-cached succeeds when in local datastore" ' - 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 && - cat curl_onlyifcached_postitive_out && - grep "< HTTP/1.1 200 OK" curl_onlyifcached_postitive_out - ' - test_expect_success "GET for /ipfs/ with only-if-cached fails when not in local datastore" ' - 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 && - cat curl_onlyifcached_negative_out && - grep "< HTTP/1.1 412 Precondition Failed" curl_onlyifcached_negative_out - ' - -# X-Ipfs-Path - - ## dir generated listing - test_expect_success "GET /ipfs/ dir listing response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3" curl_ipfs_dir_listing_output - ' - test_expect_success "GET /ipns/ dir listing response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3" curl_ipns_dir_listing_output - ' - - ## dir static index.html - test_expect_success "GET /ipfs/ dir index.html response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3/root4/" curl_ipfs_dir_index.html_output - ' - test_expect_success "GET /ipns/ dir index.html response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3/root4/" curl_ipns_dir_index.html_output - ' - - # file - test_expect_success "GET /ipfs/ file response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipfs/$ROOT1_CID/root2/root3/root4/index.html" curl_ipfs_file_output - ' - test_expect_success "GET /ipns/ file response has original content path in X-Ipfs-Path" ' - test_should_contain "< X-Ipfs-Path: /ipns/$TEST_IPNS_ID/root2/root3/root4/index.html" curl_ipns_file_output - ' - -# X-Ipfs-Roots - - ## dir generated listing - test_expect_success "GET /ipfs/ dir listing response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID}" curl_ipfs_dir_listing_output - ' - test_expect_success "GET /ipns/ dir listing response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID}" curl_ipns_dir_listing_output - ' - - ## dir static index.html - test_expect_success "GET /ipfs/ dir index.html response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID}" curl_ipfs_dir_index.html_output - ' - test_expect_success "GET /ipns/ dir index.html response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID}" curl_ipns_dir_index.html_output - ' - - ## file - test_expect_success "GET /ipfs/ file response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID},${FILE_CID}" curl_ipfs_file_output - ' - test_expect_success "GET /ipns/ file response has logical CID roots in X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Roots: ${ROOT1_CID},${ROOT2_CID},${ROOT3_CID},${ROOT4_CID},${FILE_CID}" curl_ipns_file_output - ' # Etag @@ -202,70 +52,6 @@ test_expect_success "Add the test directory" ' grep -E "< Etag: \"DirIndex-.+_CID-${ROOT3_CID}\"" curl_ipns_dir_listing_output ' - ## dir static index.html should use CID of the index.html file for improved HTTP caching - test_expect_success "GET /ipfs/ dir index.html response has dir CID as Etag" ' - test_should_contain "< Etag: \"${ROOT4_CID}\"" curl_ipfs_dir_index.html_output - ' - test_expect_success "GET /ipns/ dir index.html response has dir CID as Etag" ' - test_should_contain "< Etag: \"${ROOT4_CID}\"" curl_ipns_dir_index.html_output - ' - - ## file - test_expect_success "GET /ipfs/ response has CID as Etag for a file" ' - test_should_contain "< Etag: \"${FILE_CID}\"" curl_ipfs_file_output - ' - test_expect_success "GET /ipns/ response has CID as Etag for a file" ' - test_should_contain "< Etag: \"${FILE_CID}\"" curl_ipns_file_output - ' - -# If-None-Match (return 304 Not Modified when client sends matching Etag they already have) - - test_expect_success "GET for /ipfs/ file with matching Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipfs/ dir with index.html file with matching Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipfs/ file with matching third Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipfs/ file with matching weak Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipfs/ file with wildcard Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipns/ file with matching Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - test_expect_success "GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified" ' - 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 && - test_should_contain "304 Not Modified" curl_output - ' - - # DirIndex etag is based on xxhash(./assets/dir-index-html), so we need to fetch it dynamically - test_expect_success "GET for /ipfs/ dir listing with matching strong Etag in If-None-Match returns 304 Not Modified" ' - 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 && - curl -svX GET -H "If-None-Match: \"$(/dev/null 2>curl_output && - test_should_contain "304 Not Modified" curl_output - ' - test_expect_success "GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified" ' - 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 && - curl -svX GET -H "If-None-Match: W/\"$(/dev/null 2>curl_output && - test_should_contain "304 Not Modified" curl_output - ' test_kill_ipfs_daemon diff --git a/test/sharness/t0116-gateway-cache/README.md b/test/sharness/t0116-gateway-cache/README.md deleted file mode 100644 index 1be92f45456..00000000000 --- a/test/sharness/t0116-gateway-cache/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Dataset description/sources - -- fixtures.car - - raw CARv1 - -generated with: - -```sh -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) - -mkdir -p root2/root3/root4 && -echo "hello" > root2/root3/root4/index.html && -ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2) -ROOT2_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2 | cut -d "/" -f3) -ROOT3_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3 | cut -d "/" -f3) -ROOT4_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4 | cut -d "/" -f3) -FILE_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4/index.html | cut -d "/" -f3) - -TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n") -# publish a record valid for a 100 years -ipfs name publish --key cache_test_key --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$ROOT1_CID" -ipfs routing get /ipns/${TEST_IPNS_ID} > ${TEST_IPNS_ID}.ipns-record - -echo ROOT1_CID=${ROOT1_CID} # ./ -echo ROOT2_CID=${ROOT2_CID} # ./root2 -echo ROOT3_CID=${ROOT3_CID} # ./root2/root3 -echo ROOT4_CID=${ROOT4_CID} # ./root2/root3/root4 -echo FILE_CID=${FILE_CID} # ./root2/root3/root4/index.html -echo TEST_IPNS_ID=${TEST_IPNS_ID} - -ipfs dag export ${ROOT1_CID} > ./fixtures.car - -# ROOT1_CID=bafybeib3ffl2teiqdncv3mkz4r23b5ctrwkzrrhctdbne6iboayxuxk5ui # ./ -# ROOT2_CID=bafybeih2w7hjocxjg6g2ku25hvmd53zj7og4txpby3vsusfefw5rrg5sii # ./root2 -# ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3 -# ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4 -# FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html -# TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe -``` diff --git a/test/sharness/t0116-gateway-cache/fixtures.car b/test/sharness/t0116-gateway-cache/fixtures.car deleted file mode 100644 index 43e570e1d6a..00000000000 Binary files a/test/sharness/t0116-gateway-cache/fixtures.car and /dev/null differ diff --git a/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record b/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record deleted file mode 100644 index 9cd7491bf7e..00000000000 Binary files a/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record and /dev/null differ diff --git a/test/sharness/t0117-gateway-block.sh b/test/sharness/t0117-gateway-block.sh deleted file mode 100755 index a4a661bd194..00000000000 --- a/test/sharness/t0117-gateway-block.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test HTTP Gateway Raw Block (application/vnd.ipld.raw) Support" - -. lib/test-lib.sh - -test_init_ipfs -test_launch_ipfs_daemon_without_network - -# Import test case -# See the static fixtures in ./t0117-gateway-block/ -test_expect_success "Add the dir test directory" ' - ipfs dag import --pin-roots ../t0117-gateway-block/fixtures.car -' -ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./ -FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt - -# GET unixfs dir root block and compare it with `ipfs block get` output - - test_expect_success "GET with format=raw param returns a raw block" ' - ipfs block get "/ipfs/$ROOT_DIR_CID/dir" > expected && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$ROOT_DIR_CID/dir?format=raw" -o curl_ipfs_dir_block_param_output && - test_cmp expected curl_ipfs_dir_block_param_output - ' - - test_expect_success "GET for application/vnd.ipld.raw returns a raw block" ' - ipfs block get "/ipfs/$ROOT_DIR_CID/dir" > expected_block && - 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 && - test_cmp expected_block curl_ipfs_dir_block_accept_output - ' - - test_expect_success "GET for application/vnd.ipld.raw with single range request includes correct bytes" ' - echo -n "application" > expected_file_block_single_range && - 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 && - test_cmp expected_file_block_single_range curl_ipfs_file_block_single_range - ' - - test_expect_success "GET for application/vnd.ipld.raw with multiple range request includes correct bytes" ' - 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 && - test_should_contain "Content-Range: bytes 6-16/31" curl_ipfs_file_block_multiple_range && - test_should_contain "Content-Type: application/vnd.ipld.raw" curl_ipfs_file_block_multiple_range && - test_should_contain "application" curl_ipfs_file_block_multiple_range && - test_should_contain "Content-Range: bytes 0-4/31" curl_ipfs_file_block_multiple_range && - test_should_contain "hello" curl_ipfs_file_block_multiple_range - ' - -# Make sure expected HTTP headers are returned with the block bytes - - test_expect_success "GET response for application/vnd.ipld.raw has expected Content-Type" ' - 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 && - test_should_contain "< Content-Type: application/vnd.ipld.raw" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.raw includes Content-Length" ' - BYTES=$(ipfs block get $FILE_CID | wc --bytes) - test_should_contain "< Content-Length: $BYTES" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.raw includes Content-Disposition" ' - test_should_contain "< Content-Disposition: attachment\; filename=\"${FILE_CID}.bin\"" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.raw includes nosniff hint" ' - test_should_contain "< X-Content-Type-Options: nosniff" curl_output - ' - - test_expect_success "GET for application/vnd.ipld.raw with query filename includes Content-Disposition with custom filename" ' - 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 && - test_should_contain "< Content-Disposition: attachment\; filename=\"foobar.bin\"" curl_output_filename - ' - -# Cache control HTTP headers -# (basic checks, detailed behavior is tested in t0116-gateway-cache.sh) - - test_expect_success "GET response for application/vnd.ipld.raw includes Etag" ' - test_should_contain "< Etag: \"${FILE_CID}.raw\"" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.raw includes X-Ipfs-Path and X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Path" curl_output && - test_should_contain "< X-Ipfs-Roots" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.raw includes Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_output - ' - -test_kill_ipfs_daemon - -test_done diff --git a/test/sharness/t0117-gateway-block/README.md b/test/sharness/t0117-gateway-block/README.md deleted file mode 100644 index 4ce37ae086f..00000000000 --- a/test/sharness/t0117-gateway-block/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Dataset description/sources - -- fixtures.car - - raw CARv1 - -generated with: - -```sh -# using ipfs version 0.18.1 -mkdir -p dir && -echo "hello application/vnd.ipld.raw" > dir/ascii.txt && -ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 dir) && -FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/dir/ascii.txt | cut -d "/" -f3) && -ipfs dag export $ROOT_DIR_CID > fixtures.car - -echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./ -echo FILE_CID=${FILE_CID} # ./dir/ascii.txt - -# ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./ -# FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt -``` diff --git a/test/sharness/t0117-gateway-block/fixtures.car b/test/sharness/t0117-gateway-block/fixtures.car deleted file mode 100644 index 77da1b5542e..00000000000 Binary files a/test/sharness/t0117-gateway-block/fixtures.car and /dev/null differ diff --git a/test/sharness/t0122-gateway-tar.sh b/test/sharness/t0122-gateway-tar.sh deleted file mode 100755 index 435623547a3..00000000000 --- a/test/sharness/t0122-gateway-tar.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test HTTP Gateway TAR (application/x-tar) Support" - -. lib/test-lib.sh - -test_init_ipfs -test_launch_ipfs_daemon_without_network - -OUTSIDE_ROOT_CID="bafybeicaj7kvxpcv4neaqzwhrqqmdstu4dhrwfpknrgebq6nzcecfucvyu" -INSIDE_ROOT_CID="bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y" - -# Import test case -# See the static fixtures in ./t0122-gateway-tar/ -test_expect_success "Add the test directory" ' - ipfs dag import --pin-roots ../t0122-gateway-tar/fixtures.car -' -DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir -FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt -FILE_SIZE=34 - -test_expect_success "GET TAR with format=tar and extract" ' - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x -' - -test_expect_success "GET TAR with 'Accept: application/x-tar' and extract" ' - curl -H "Accept: application/x-tar" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" | tar -x -' - -test_expect_success "GET TAR with format=tar has expected Content-Type" ' - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" > curl_output_filename 2>&1 && - test_should_contain "Content-Disposition: attachment;" curl_output_filename && - test_should_contain "Etag: W/\"$FILE_CID.x-tar" curl_output_filename && - test_should_contain "Content-Type: application/x-tar" curl_output_filename -' - -test_expect_success "GET TAR with 'Accept: application/x-tar' has expected Content-Type" ' - curl -sD - -H "Accept: application/x-tar" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output_filename 2>&1 && - test_should_contain "Content-Disposition: attachment;" curl_output_filename && - test_should_contain "Etag: W/\"$FILE_CID.x-tar" curl_output_filename && - test_should_contain "Content-Type: application/x-tar" curl_output_filename -' - -test_expect_success "GET TAR has expected root file" ' - rm -rf outputDir && mkdir outputDir && - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x -C outputDir && - test -f "outputDir/$FILE_CID" && - echo "I am a txt file on path with utf8" > expected && - test_cmp expected outputDir/$FILE_CID -' - -test_expect_success "GET TAR has expected root directory" ' - rm -rf outputDir && mkdir outputDir && - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=tar" | tar -x -C outputDir && - test -d "outputDir/$DIR_CID" && - echo "I am a txt file on path with utf8" > expected && - test_cmp expected outputDir/$DIR_CID/ą/ę/file-źł.txt -' - -test_expect_success "GET TAR with explicit ?filename= succeeds with modified Content-Disposition header" " - curl -fo actual -D actual_headers 'http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?filename=testтест.tar&format=tar' && - grep -F 'Content-Disposition: attachment; filename=\"test____.tar\"; filename*=UTF-8'\'\''test%D1%82%D0%B5%D1%81%D1%82.tar' actual_headers -" - -test_expect_success "Add CARs with relative paths to test with" ' - ipfs dag import --pin-roots ../t0122-gateway-tar/outside-root.car > import_output && - test_should_contain $OUTSIDE_ROOT_CID import_output && - ipfs dag import --pin-roots ../t0122-gateway-tar/inside-root.car > import_output && - test_should_contain $INSIDE_ROOT_CID import_output -' - -test_expect_success "GET TAR with relative paths outside root fails" ' - curl -o - "http://127.0.0.1:$GWAY_PORT/ipfs/$OUTSIDE_ROOT_CID?format=tar" > curl_output_filename && - test_should_contain "relative UnixFS paths outside the root are now allowed" curl_output_filename -' - -test_expect_success "GET TAR with relative paths inside root works" ' - rm -rf outputDir && mkdir outputDir && - curl "http://127.0.0.1:$GWAY_PORT/ipfs/$INSIDE_ROOT_CID?format=tar" | tar -x -C outputDir && - test -f outputDir/$INSIDE_ROOT_CID/foobar/file -' - -test_kill_ipfs_daemon - -test_done diff --git a/test/sharness/t0122-gateway-tar/README.md b/test/sharness/t0122-gateway-tar/README.md deleted file mode 100644 index 8b9311277cc..00000000000 --- a/test/sharness/t0122-gateway-tar/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Dataset description/sources - -- inside-root.car - -- outside-root.car - -- fixtures.car - - raw CARv1 - -generated with: - -```sh -# ipfs version 0.18.1 - -mkdir -p rootDir/ipfs && -mkdir -p rootDir/ipns && -mkdir -p rootDir/api && -mkdir -p rootDir/ą/ę && -echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && -echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && -echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && -echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && -DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && -FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && -FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) -echo "$FILE_CID / $FILE_SIZE" - -echo DIR_CID=${DIR_CID} # ./rootDir -echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt -echo FILE_SIZE=${FILE_SIZE} - -ipfs dag export ${DIR_CID} > ./fixtures.car - -# DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir -# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt -# FILE_SIZE=34 -``` diff --git a/test/sharness/t0122-gateway-tar/fixtures.car b/test/sharness/t0122-gateway-tar/fixtures.car deleted file mode 100644 index 71a56038227..00000000000 Binary files a/test/sharness/t0122-gateway-tar/fixtures.car and /dev/null differ diff --git a/test/sharness/t0122-gateway-tar/inside-root.car b/test/sharness/t0122-gateway-tar/inside-root.car deleted file mode 100644 index c37b594f8d6..00000000000 Binary files a/test/sharness/t0122-gateway-tar/inside-root.car and /dev/null differ diff --git a/test/sharness/t0122-gateway-tar/outside-root.car b/test/sharness/t0122-gateway-tar/outside-root.car deleted file mode 100644 index 7587dcb7efa..00000000000 Binary files a/test/sharness/t0122-gateway-tar/outside-root.car and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh deleted file mode 100755 index 323d23d584f..00000000000 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ /dev/null @@ -1,379 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and DAG-CBOR (application/vnd.ipld.dag-cbor) Support" - -. lib/test-lib.sh - -test_init_ipfs -test_launch_ipfs_daemon_without_network - -# Import test case -# See the static fixtures in ./t0123-gateway-json-cbor/ -test_expect_success "Add the test directory" ' - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/fixtures.car -' -DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir -FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json -FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt -FILE_SIZE=34 - -## Quick regression check for JSON stored on UnixFS: -## it has nothing to do with DAG-JSON and JSON codecs, -## but a lot of JSON data is stored on UnixFS and is requested with or without various hints -## and we want to avoid surprises like https://github.com/protocol/bifrost-infra/issues/2290 -test_expect_success "GET UnixFS file with JSON bytes is returned with application/json Content-Type" ' - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_JSON_CID" > curl_output 2>&1 && - curl -sD headers_accept -H "Accept: application/json" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_JSON_CID" > curl_output_accept 2>&1 && - ipfs cat $FILE_JSON_CID > ipfs_cat_output 2>&1 && - test_should_contain "Content-Type: application/json" headers && - test_should_contain "Content-Type: application/json" headers_accept && - test_cmp ipfs_cat_output curl_output && - test_cmp curl_output curl_output_accept -' - - -## Reading UnixFS (data encoded with dag-pb codec) as DAG-CBOR and DAG-JSON -## (returns representation defined in https://ipld.io/specs/codecs/dag-pb/spec/#logical-format) - -test_dag_pb_conversion () { - name=$1 - format=$2 - disposition=$3 - - test_expect_success "GET UnixFS file as $name with format=dag-$format converts to the expected Content-Type" ' - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=dag-$format" > curl_output 2>&1 && - ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output 2>&1 && - test_cmp ipfs_dag_get_output curl_output && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" headers && - test_should_not_contain "Content-Type: application/$format" headers - ' - - test_expect_success "GET UnixFS directory as $name with format=dag-$format converts to the expected Content-Type" ' - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=dag-$format" > curl_output 2>&1 && - ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output 2>&1 && - test_cmp ipfs_dag_get_output curl_output && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${DIR_CID}.${format}\"" headers && - test_should_not_contain "Content-Type: application/$format" headers - ' - - test_expect_success "GET UnixFS as $name with 'Accept: application/vnd.ipld.dag-$format' converts to the expected Content-Type" ' - curl -sD - -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" curl_output && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output && - test_should_not_contain "Content-Type: application/$format" curl_output - ' - - test_expect_success "GET UnixFS as $name with 'Accept: foo, application/vnd.ipld.dag-$format,bar' converts to the expected Content-Type" ' - 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 && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output - ' - - test_expect_success "GET UnixFS with format=$format (not dag-$format) is no-op (no conversion)" ' - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=$format" > curl_output 2>&1 && - ipfs cat $FILE_CID > cat_output && - test_cmp cat_output curl_output && - test_should_contain "Content-Type: text/plain" headers && - test_should_not_contain "Content-Type: application/$format" headers && - test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers - ' - - test_expect_success "GET UnixFS with 'Accept: application/$format' (not dag-$format) is no-op (no conversion)" ' - curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 && - ipfs cat $FILE_CID > cat_output && - test_cmp cat_output curl_output && - test_should_contain "Content-Type: text/plain" headers && - test_should_not_contain "Content-Type: application/$format" headers && - test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers - ' -} - -test_dag_pb_conversion "DAG-JSON" "json" "inline" -test_dag_pb_conversion "DAG-CBOR" "cbor" "attachment" - - -# Requesting CID with plain json (0x0200) and cbor (0x51) codecs -# (note these are not UnixFS, not DAG-* variants, just raw block identified by a CID with a special codec) -test_plain_codec () { - name=$1 - format=$2 - disposition=$3 - - # no explicit format, just codec in CID - test_expect_success "GET $name without Accept or format= has expected $format Content-Type and body as-is" ' - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) && - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 && - ipfs block get $CID > ipfs_block_output 2>&1 && - test_cmp ipfs_block_output curl_output && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && - test_should_contain "Content-Type: application/$format" headers - ' - - # explicit format still gives correct output, just codec in CID - test_expect_success "GET $name with ?format= has expected $format Content-Type and body as-is" ' - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) && - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" > curl_output 2>&1 && - ipfs block get $CID > ipfs_block_output 2>&1 && - test_cmp ipfs_block_output curl_output && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && - test_should_contain "Content-Type: application/$format" headers - ' - - # explicit format still gives correct output, just codec in CID - test_expect_success "GET $name with Accept has expected $format Content-Type and body as-is" ' - CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) && - curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 && - ipfs block get $CID > ipfs_block_output 2>&1 && - test_cmp ipfs_block_output curl_output && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && - test_should_contain "Content-Type: application/$format" headers - ' - - # explicit dag-* format passed, attempt to parse as dag* variant - ## Note: this works only for simple JSON that can be upgraded to DAG-JSON. - test_expect_success "GET $name with format=dag-$format interprets $format as dag-* variant and produces expected Content-Type and body" ' - CID=$(echo "{ \"test\": \"plain-json-that-can-also-be-dag-json\" }" | ipfs dag put --input-codec json --store-codec $format) && - curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" > curl_output_param 2>&1 && - ipfs dag get --output-codec dag-$format $CID > ipfs_dag_get_output 2>&1 && - test_cmp ipfs_dag_get_output curl_output_param && - test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && - curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output_accept 2>&1 && - test_cmp curl_output_param curl_output_accept - ' - -} - -test_plain_codec "plain JSON codec" "json" "inline" -test_plain_codec "plain CBOR codec" "cbor" "attachment" - -## Pathing, traversal over DAG-JSON and DAG-CBOR - -DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim" -DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq" -DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke" - -test_expect_success "Add CARs for path traversal and DAG-PB representation tests" ' - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-cbor-traversal.car > import_output && - test_should_contain $DAG_CBOR_TRAVERSAL_CID import_output && - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-json-traversal.car > import_output && - test_should_contain $DAG_JSON_TRAVERSAL_CID import_output && - ipfs dag import --pin-roots ../t0123-gateway-json-cbor/dag-pb.car > import_output && - test_should_contain $DAG_PB_CID import_output -' - -IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2 -IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l - -test_expect_success "Add ipns records for path traversal and DAG-PB representation tests" ' - ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record && - ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record -' - -test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" ' - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo?format=dag-json" > curl_output 2>&1 && - test_should_contain "501 Not Implemented" curl_output && - test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output -' - -test_expect_success "GET DAG-JSON traverses multiple links" ' - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 && - jq --sort-keys . curl_output > actual && - echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected && - test_cmp expected actual -' - -test_expect_success "GET DAG-CBOR traversal returns 501 if there is path remainder" ' - curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo?format=dag-cbor" > curl_output 2>&1 && - test_should_contain "501 Not Implemented" curl_output && - test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output -' - -test_expect_success "GET DAG-CBOR traverses multiple links" ' - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 && - jq --sort-keys . curl_output > actual && - echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected && - test_cmp expected actual -' - -## NATIVE TESTS for DAG-JSON (0x0129) and DAG-CBOR (0x71): -## DAG- regression tests for core behaviors when native DAG-(CBOR|JSON) is requested - -test_native_dag () { - name=$1 - format=$2 - disposition=$3 - CID=$4 - IPNS_ID=$5 - - # GET without explicit format and Accept: text/html returns raw block - - test_expect_success "GET $name from /ipfs without explicit format returns the same payload as the raw block" ' - ipfs block get "/ipfs/$CID" > expected && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o curl_output && - test_cmp expected curl_output - ' - - # GET dag-cbor block via Accept and ?format and ensure both are the same as `ipfs block get` output - - test_expect_success "GET $name from /ipfs with format=dag-$format returns the same payload as the raw block" ' - ipfs block get "/ipfs/$CID" > expected && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o curl_ipfs_dag_param_output && - test_cmp expected curl_ipfs_dag_param_output - ' - - test_expect_success "GET $name from /ipfs for application/$format returns the same payload as format=dag-$format" ' - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output && - test_cmp expected plain_output - ' - - test_expect_success "GET $name from /ipfs with application/vnd.ipld.dag-$format returns the same payload as the raw block" ' - ipfs block get "/ipfs/$CID" > expected_block && - 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 && - test_cmp expected_block curl_ipfs_dag_block_accept_output - ' - - # Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes - - test_expect_success "GET $name with format=$format returns same payload as format=dag-$format but with plain Content-Type" ' - curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected && - curl -sD plain_headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output && - test_should_contain "Content-Type: application/$format" plain_headers && - test_cmp expected plain_output - ' - - test_expect_success "GET $name with Accept: application/$format returns same payload as application/vnd.ipld.dag-$format but with plain Content-Type" ' - curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > expected && - curl -sD plain_headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > plain_output && - test_should_contain "Content-Type: application/$format" plain_headers && - test_cmp expected plain_output - ' - - - # Make sure expected HTTP headers are returned with the dag- block - - test_expect_success "GET response for application/vnd.ipld.dag-$format has expected Content-Type" ' - curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" >/dev/null 2>curl_output && - test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Length" ' - BYTES=$(ipfs block get $CID | wc --bytes) - test_should_contain "< Content-Length: $BYTES" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Disposition" ' - test_should_contain "< Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes nosniff hint" ' - test_should_contain "< X-Content-Type-Options: nosniff" curl_output - ' - - test_expect_success "GET for application/vnd.ipld.dag-$format with query filename includes Content-Disposition with custom filename" ' - 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 && - test_should_contain "< Content-Disposition: ${disposition}\; filename=\"foobar.$format\"" curl_output_filename - ' - - test_expect_success "GET for application/vnd.ipld.dag-$format with ?download=true forces Content-Disposition: attachment" ' - 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 && - test_should_contain "< Content-Disposition: attachment" curl_output_filename - ' - - # Cache control HTTP headers - # (basic checks, detailed behavior is tested in t0116-gateway-cache.sh) - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Etag" ' - test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes X-Ipfs-Path and X-Ipfs-Roots" ' - test_should_contain "< X-Ipfs-Path" curl_output && - test_should_contain "< X-Ipfs-Roots" curl_output - ' - - test_expect_success "GET response for application/vnd.ipld.dag-$format includes Cache-Control" ' - test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_output - ' - - # HTTP HEAD behavior - test_expect_success "HEAD $name with no explicit format returns HTTP 200" ' - curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o output && - test_should_contain "HTTP/1.1 200 OK" output && - test_should_contain "Content-Type: application/vnd.ipld.dag-$format" output && - test_should_contain "Content-Length: " output - ' - test_expect_success "HEAD $name with an explicit DAG-JSON format returns HTTP 200" ' - curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-json" -o output && - test_should_contain "HTTP/1.1 200 OK" output && - test_should_contain "Etag: \"$CID.dag-json\"" output && - test_should_contain "Content-Type: application/vnd.ipld.dag-json" output && - test_should_contain "Content-Length: " output - ' - test_expect_success "HEAD $name with only-if-cached for missing block returns HTTP 412 Precondition Failed" ' - MISSING_CID=$(echo "{\"t\": \"$(date +%s)\"}" | ipfs dag put --store-codec=dag-${format}) && - ipfs block rm -f -q $MISSING_CID && - curl -I -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$MISSING_CID" -o output && - test_should_contain "HTTP/1.1 412 Precondition Failed" output - ' - - # IPNS behavior (should be same as immutable /ipfs, but with different caching headers) - # To keep tests small we only confirm payload is the same, and then only test delta around caching headers. - - test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" ' - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o ipfs_output && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" -o ipns_output && - test_cmp ipfs_output ipns_output - ' - - test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" ' - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o ipfs_output && - curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID?format=dag-$format" -o ipns_output && - test_cmp ipfs_output ipns_output - ' - - test_expect_success "GET $name from /ipns with explicit application/vnd.ipld.dag-$format has expected headers" ' - 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 && - test_should_not_contain "Cache-Control" curl_output && - test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output && - test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output && - test_should_contain "< X-Ipfs-Path" curl_output && - test_should_contain "< X-Ipfs-Roots" curl_output - ' - - - # When Accept header includes text/html and no explicit format is requested for DAG-(CBOR|JSON) - # The gateway returns generated HTML index (see dag-index-html) for web browsers (similar to dir-index-html returned for unixfs dirs) - # As this is generated, we don't return immutable Cache-Control, even on /ipfs (same as for dir-index-html) - - test_expect_success "GET $name on /ipfs with Accept: text/html returns HTML (dag-index-html)" ' - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID/" > curl_output 2>&1 && - test_should_not_contain "Content-Disposition" curl_output && - test_should_not_contain "Cache-Control" curl_output && - test_should_contain "Etag: \"DagIndex-" curl_output && - test_should_contain "Content-Type: text/html" curl_output && - test_should_contain "" curl_output - ' - - test_expect_success "GET $name on /ipns with Accept: text/html returns HTML (dag-index-html)" ' - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID/" > curl_output 2>&1 && - test_should_not_contain "Content-Disposition" curl_output && - test_should_not_contain "Cache-Control" curl_output && - test_should_contain "Etag: \"DagIndex-" curl_output && - test_should_contain "Content-Type: text/html" curl_output && - test_should_contain "" curl_output - ' - - -} - -test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID" ${IPNS_ID_DAG_JSON} -test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID" ${IPNS_ID_DAG_CBOR} - -test_kill_ipfs_daemon - -test_done - -# vim: set ts=2 sw=2 et: diff --git a/test/sharness/t0123-gateway-json-cbor/README.md b/test/sharness/t0123-gateway-json-cbor/README.md deleted file mode 100644 index 5a63b192af8..00000000000 --- a/test/sharness/t0123-gateway-json-cbor/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Dataset description/sources - -- dag-cbor-traversal.car - -- dag-json-traversal.car - -- dag-pb.car - -- dag-pb.json - -- fixtures.car - - raw CARv1 - -generated with: - -```sh -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) - -mkdir -p rootDir/ipfs && -mkdir -p rootDir/ipns && -mkdir -p rootDir/api && -mkdir -p rootDir/ą/ę && -echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json && -echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && -echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && -echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && -echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && -DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && -FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) && -FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && -FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) -echo "$FILE_CID / $FILE_SIZE" - -echo DIR_CID=${DIR_CID} # ./rootDir -echo FILE_JSON_CID=${FILE_JSON_CID} # ./rootDir/ą/ę/t.json -echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt -echo FILE_SIZE=${FILE_SIZE} - -ipfs dag export ${DIR_CID} > fixtures.car - -DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim" -DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq" -DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke" - -test_native_dag() { - NAME=$1 - CID=$2 - - IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${NAME}_test_key | head -n1 | tr -d "\n") - ipfs name publish --key ${NAME}_test_key --allow-offline --ttl=876600h --lifetime=876600h -Q "/ipfs/${CID}" > name_publish_out - - ipfs routing get /ipns/${IPNS_ID} > ${IPNS_ID}.ipns-record - - echo "IPNS_ID_${NAME}=${IPNS_ID}" -} - -test_native_dag "DAG_JSON" "$DAG_JSON_TRAVERSAL_CID" -test_native_dag "DAG_CBOR" "$DAG_CBOR_TRAVERSAL_CID" - -# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir -# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json -# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt -# FILE_SIZE=34 -# IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2 -# IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l -``` diff --git a/test/sharness/t0123-gateway-json-cbor/dag-cbor-traversal.car b/test/sharness/t0123-gateway-json-cbor/dag-cbor-traversal.car deleted file mode 100644 index 92c3d4f3e21..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/dag-cbor-traversal.car and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor/dag-json-traversal.car b/test/sharness/t0123-gateway-json-cbor/dag-json-traversal.car deleted file mode 100644 index 0431ef24aea..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/dag-json-traversal.car and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor/dag-pb.car b/test/sharness/t0123-gateway-json-cbor/dag-pb.car deleted file mode 100644 index a6bb076c7e3..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/dag-pb.car and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor/dag-pb.json b/test/sharness/t0123-gateway-json-cbor/dag-pb.json deleted file mode 100644 index ab4f9f011a6..00000000000 --- a/test/sharness/t0123-gateway-json-cbor/dag-pb.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "Data": { - "/": { - "bytes": "CAE" - } - }, - "Links": [ - { - "Hash": { - "/": "bafybeidryarwh34ygbtyypbu7qjkl4euiwxby6cql6uvosonohkq2kwnkm" - }, - "Name": "foo", - "Tsize": 69 - }, - { - "Hash": { - "/": "bafkreic3ondyhizrzeoufvoodehinugpj3ecruwokaygl7elezhn2khqfa" - }, - "Name": "foo.txt", - "Tsize": 13 - } - ] -} diff --git a/test/sharness/t0123-gateway-json-cbor/fixtures.car b/test/sharness/t0123-gateway-json-cbor/fixtures.car deleted file mode 100644 index 8663730f2fe..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/fixtures.car and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record b/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record deleted file mode 100644 index 7186c709e3c..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record and /dev/null differ diff --git a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record b/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record deleted file mode 100644 index 28676f4d9a8..00000000000 Binary files a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record and /dev/null differ diff --git a/test/sharness/t0124-gateway-ipns-record.sh b/test/sharness/t0124-gateway-ipns-record.sh deleted file mode 100755 index 1d05b56985a..00000000000 --- a/test/sharness/t0124-gateway-ipns-record.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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 - -# Import test case -# See the static fixtures in ./t0124-gateway-ipns-record/ -IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab -FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS -test_expect_success "Add the test directory & IPNS records" ' - ipfs dag import ../t0124-gateway-ipns-record/fixtures.car && - ipfs routing put /ipns/${IPNS_KEY} ../t0124-gateway-ipns-record/${IPNS_KEY}.ipns-record -' - -test_expect_success "Create and Publish IPNS Key" ' - 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=3155760000" 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=3155760000" 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 diff --git a/test/sharness/t0124-gateway-ipns-record/README.md b/test/sharness/t0124-gateway-ipns-record/README.md deleted file mode 100644 index 8ada577d4d7..00000000000 --- a/test/sharness/t0124-gateway-ipns-record/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Dataset description/sources - -- fixtures.car - - raw CARv1 - -- k51....ipns-record - - ipns record, encoded with protocol buffer - -generated with: - -```sh -# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) -FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q) -IPNS_KEY=$(ipfs key gen ipns-record) - -ipfs dag export ${FILE_CID} > fixtures.car - -# publish a record valid for a 100 years -ipfs name publish --key=ipns-record --quieter --ttl=876600h --lifetime=876600h /ipfs/${FILE_CID} -ipfs routing get /ipns/${IPNS_KEY} > ${IPNS_KEY}.ipns-record - -echo IPNS_KEY=${IPNS_KEY} -echo FILE_CID=${FILE_CID} # A file containing "Hello IPFS" - -# IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab -# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS -``` diff --git a/test/sharness/t0124-gateway-ipns-record/fixtures.car b/test/sharness/t0124-gateway-ipns-record/fixtures.car deleted file mode 100644 index 5c541e430ea..00000000000 Binary files a/test/sharness/t0124-gateway-ipns-record/fixtures.car and /dev/null differ diff --git a/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record b/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record deleted file mode 100644 index ec13ec55016..00000000000 Binary files a/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record and /dev/null differ