Skip to content

Commit

Permalink
chore: remove sharness tests ported to conformance testing (#9999)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
laurentsenta authored Aug 2, 2023
1 parent 5bec4d6 commit 7977f26
Show file tree
Hide file tree
Showing 30 changed files with 29 additions and 1,090 deletions.
2 changes: 2 additions & 0 deletions test/sharness/t0026-id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ test_expect_success "checking AgentVersion with suffix (fetched via libp2p ident
ipfsi 1 id "$(ipfsi 0 config Identity.PeerID)" -f "<aver>\n" > actual-libp2p-identify-agent-version &&
test_cmp expected-identify-agent-version actual-libp2p-identify-agent-version
'
iptb stop

test_kill_ipfs_daemon


Expand Down
33 changes: 0 additions & 33 deletions test/sharness/t0113-gateway-symlink.sh

This file was deleted.

17 changes: 0 additions & 17 deletions test/sharness/t0113-gateway-symlink/README.md

This file was deleted.

Binary file removed test/sharness/t0113-gateway-symlink/testfiles.car
Binary file not shown.
28 changes: 27 additions & 1 deletion test/sharness/t0114-gateway-subdomains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,18 @@ 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 \
"request for localhost/ipfs/{CIDv1} includes human-readable link and redirect info in HTTP 301 body" \
"http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
">Moved Permanently</a>"

# 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" \
Expand All @@ -188,11 +193,16 @@ test_localhost_gateway_response_should_contain \

# /ipns/<dnslink-fqdn>

# 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
Expand Down Expand Up @@ -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"

Expand All @@ -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

Expand Down Expand Up @@ -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"

Expand All @@ -464,6 +482,8 @@ test_expect_success "valid breadcrumb links in the header of directory listing a
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
'

# 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
Expand Down Expand Up @@ -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
## ============================================================================
Expand Down Expand Up @@ -966,3 +990,5 @@ test_expect_success "clean up ipfs dir" '
'

test_done

# end Kubo specific end-to-end test
214 changes: 0 additions & 214 deletions test/sharness/t0116-gateway-cache.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: \"$(<dir_index_etag)\"" "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
'
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/\"$(<dir_index_etag)\"" "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
'

test_kill_ipfs_daemon

Expand Down
Loading

0 comments on commit 7977f26

Please sign in to comment.