diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ce9c799f..18df60519 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `--verbose` flag displays all the output to the console
+### Changed
+- finalized port of Kubo's sharness tests. [PR](https://github.com/ipfs/gateway-conformance/pull/92)
+
## [0.2.0] - 2023-06-26
### Added
- `carFixture.MustGetChildren`
diff --git a/fixtures/README.md b/fixtures/README.md
index f9df5d6b7..beff1066d 100644
--- a/fixtures/README.md
+++ b/fixtures/README.md
@@ -1,33 +1,22 @@
-# ipfs add --recursive --raw-leaves --cid-version=1 --wrap-with-directory fixtures/dir
+# Fixtures
-added bafkreibyniihaqnhs536mbvc3wx66vbfttisc6zrvea6kzeku3w4as6lum dir/ascii.txt
-added bafybeiaxmpwa4nz2mekiiosayvkfgfpbubm7pch7tspx5syhzzsvkoewc4 dir
-added bafybeie7u7bbgvdqbur6inl6fpl4yw3xcg34bjjmnnzkmpwb5v6x3xz3hy
+This folder contains all the fixtures using during the tests, with
+the recipes to re-create them.
-# ipfs dag export bafybeie7u7bbgvdqbur6inl6fpl4yw3xcg34bjjmnnzkmpwb5v6x3xz3hy > fixtures/dir.car
+## Recipes
-# go install github.com/ipld/go-car/cmd/car@latest
+### [gateway-raw-block.car](./gateway-raw-block.car)
-# car list fixtures/dir.car
+Generated with:
-bafybeie7u7bbgvdqbur6inl6fpl4yw3xcg34bjjmnnzkmpwb5v6x3xz3hy
-bafybeiaxmpwa4nz2mekiiosayvkfgfpbubm7pch7tspx5syhzzsvkoewc4
-bafkreibyniihaqnhs536mbvc3wx66vbfttisc6zrvea6kzeku3w4as6lum
+```sh
+# using Kubo CLI version 0.18.1 (https://dist.ipfs.tech/kubo/v0.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 > gateway-raw-block.car
-# car extract --file fixtures/dir.car --verbose
-
-.../gateway-conformance/dir
-.../gateway-conformance/dir/ascii.txt
-
-# go run extract.go fixtures/dir.car
-
-path: /
- cid: bafybeie7u7bbgvdqbur6inl6fpl4yw3xcg34bjjmnnzkmpwb5v6x3xz3hy
- raw: [18 45 10 36 1 112 18 32 23 99 236 14 55 58 97 20 132 58 64 197 84 83 21 225 160 89 247 136 255 156 159 126 203 7 206 101 85 56 150 23 18 3 100 105 114 24 90 10 2 8 1]
-path: /dir
- cid: bafybeiaxmpwa4nz2mekiiosayvkfgfpbubm7pch7tspx5syhzzsvkoewc4
- raw: [18 51 10 36 1 85 18 32 56 106 16 112 65 167 151 119 230 6 162 221 175 239 84 37 156 209 33 123 49 169 1 229 100 138 166 237 192 75 203 163 18 9 97 115 99 105 105 46 116 120 116 24 33 10 2 8 1]
-path: /dir/ascii.txt
- cid: bafkreibyniihaqnhs536mbvc3wx66vbfttisc6zrvea6kzeku3w4as6lum
- raw: [103 111 111 100 98 121 101 32 97 112 112 108 105 99 97 116 105 111 110 47 118 110 100 46 105 112 108 100 46 114 97 119 10]
- str: goodbye application/vnd.ipld.raw
+echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./
+echo FILE_CID=${FILE_CID} # ./dir/ascii.txt
+```
\ No newline at end of file
diff --git a/fixtures/t0115/README.md b/fixtures/dir_listing/README.md
similarity index 85%
rename from fixtures/t0115/README.md
rename to fixtures/dir_listing/README.md
index 937438bcd..8b74a7327 100644
--- a/fixtures/t0115/README.md
+++ b/fixtures/dir_listing/README.md
@@ -1,12 +1,13 @@
-# Dataset description/sources
+# Directory Listing Fixtures
-- fixtures.car
- - raw CARv1
+## Recipes
-generated with:
+### [fixtures.car](./fixtures.car)
+
+Raw CARv1, generated with:
```sh
-# using ipfs version 0.18.1
+# using Kubo CLI version 0.18.1 (https://dist.ipfs.tech/kubo/v0.18.1/)
mkdir -p rootDir/ipfs &&
mkdir -p rootDir/ipns &&
mkdir -p rootDir/api &&
diff --git a/fixtures/t0115/dnslink.yml b/fixtures/dir_listing/dnslink.yml
similarity index 100%
rename from fixtures/t0115/dnslink.yml
rename to fixtures/dir_listing/dnslink.yml
diff --git a/fixtures/t0115/fixtures.car b/fixtures/dir_listing/fixtures.car
similarity index 100%
rename from fixtures/t0115/fixtures.car
rename to fixtures/dir_listing/fixtures.car
diff --git a/fixtures/gateway-cache/README.md b/fixtures/gateway-cache/README.md
index 56f244caa..41ad5f4e4 100644
--- a/fixtures/gateway-cache/README.md
+++ b/fixtures/gateway-cache/README.md
@@ -10,7 +10,7 @@
generated with:
```sh
-# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
+# using Kubo CLI version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
mkdir -p root2/root3/root4 &&
echo "hello" > root2/root3/root4/index.html &&
diff --git a/fixtures/t0117-gateway-block.car b/fixtures/gateway-raw-block.car
similarity index 100%
rename from fixtures/t0117-gateway-block.car
rename to fixtures/gateway-raw-block.car
diff --git a/fixtures/ipns_records/README.md b/fixtures/ipns_records/README.md
new file mode 100644
index 000000000..772712820
--- /dev/null
+++ b/fixtures/ipns_records/README.md
@@ -0,0 +1,23 @@
+# IPNS Records Fixtures
+
+## Recipes
+
+### Fixtures and ipns-record
+
+```sh
+# using Kubo CLI version 0.21.0-rc3 (https://dist.ipfs.tech/kubo/v0.21.0-rc3/)
+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/fixtures/t0124/fixtures.car b/fixtures/ipns_records/fixtures.car
similarity index 100%
rename from fixtures/t0124/fixtures.car
rename to fixtures/ipns_records/fixtures.car
diff --git a/fixtures/t0124/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record b/fixtures/ipns_records/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record
similarity index 100%
rename from fixtures/t0124/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record
rename to fixtures/ipns_records/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record
diff --git a/fixtures/path_gateway_dag/README.md b/fixtures/path_gateway_dag/README.md
new file mode 100644
index 000000000..3caeaa2b3
--- /dev/null
+++ b/fixtures/path_gateway_dag/README.md
@@ -0,0 +1,66 @@
+# Path Gateway Dag Fixtures
+
+## Recipes
+
+### Legacy fixtures from Kubo
+
+- dag-cbor-traversal.car
+- dag-json-traversal.car
+- dag-pb.car
+- dag-pb.json
+
+### [gateway-json-cbor.car](./gateway-json-cbor.car) and ipns-records
+
+Generated with:
+
+```sh
+# using Kubo CLI version 0.21.0-rc3 (https://dist.ipfs.tech/kubo/v0.21.0-rc3/)
+
+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} > gateway-json-cbor.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/fixtures/t0123/dag-cbor-traversal.car b/fixtures/path_gateway_dag/dag-cbor-traversal.car
similarity index 100%
rename from fixtures/t0123/dag-cbor-traversal.car
rename to fixtures/path_gateway_dag/dag-cbor-traversal.car
diff --git a/fixtures/t0123/dag-json-traversal.car b/fixtures/path_gateway_dag/dag-json-traversal.car
similarity index 100%
rename from fixtures/t0123/dag-json-traversal.car
rename to fixtures/path_gateway_dag/dag-json-traversal.car
diff --git a/fixtures/t0123/dag-pb.car b/fixtures/path_gateway_dag/dag-pb.car
similarity index 100%
rename from fixtures/t0123/dag-pb.car
rename to fixtures/path_gateway_dag/dag-pb.car
diff --git a/fixtures/t0123/dag-pb.json b/fixtures/path_gateway_dag/dag-pb.json
similarity index 100%
rename from fixtures/t0123/dag-pb.json
rename to fixtures/path_gateway_dag/dag-pb.json
diff --git a/fixtures/t0123-gateway-json-cbor.car b/fixtures/path_gateway_dag/gateway-json-cbor.car
similarity index 100%
rename from fixtures/t0123-gateway-json-cbor.car
rename to fixtures/path_gateway_dag/gateway-json-cbor.car
diff --git a/fixtures/t0123/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record b/fixtures/path_gateway_dag/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record
similarity index 100%
rename from fixtures/t0123/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record
rename to fixtures/path_gateway_dag/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record
diff --git a/fixtures/t0123/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record b/fixtures/path_gateway_dag/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record
similarity index 100%
rename from fixtures/t0123/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record
rename to fixtures/path_gateway_dag/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record
diff --git a/fixtures/t0123/plain-that-can-be-dag.cbor.car b/fixtures/path_gateway_dag/plain-cbor-that-can-be-dag-cbor.car
similarity index 100%
rename from fixtures/t0123/plain-that-can-be-dag.cbor.car
rename to fixtures/path_gateway_dag/plain-cbor-that-can-be-dag-cbor.car
diff --git a/fixtures/t0123/plain-that-can-be-dag.json.car b/fixtures/path_gateway_dag/plain-cbor-that-can-be-dag-json.car
similarity index 100%
rename from fixtures/t0123/plain-that-can-be-dag.json.car
rename to fixtures/path_gateway_dag/plain-cbor-that-can-be-dag-json.car
diff --git a/fixtures/t0123/plain.cbor.car b/fixtures/path_gateway_dag/plain-cbor.car
similarity index 100%
rename from fixtures/t0123/plain.cbor.car
rename to fixtures/path_gateway_dag/plain-cbor.car
diff --git a/fixtures/t0123/plain.json.car b/fixtures/path_gateway_dag/plain-json.car
similarity index 100%
rename from fixtures/t0123/plain.json.car
rename to fixtures/path_gateway_dag/plain-json.car
diff --git a/fixtures/path_gateway_tar/README.md b/fixtures/path_gateway_tar/README.md
new file mode 100644
index 000000000..ff8790088
--- /dev/null
+++ b/fixtures/path_gateway_tar/README.md
@@ -0,0 +1,40 @@
+# Path Gateway Tar Fixtures
+
+## Recipes
+
+### [inside-roots.car](./inside-root.car) and [outside-roots.car](./outside-root.car)
+
+Legacy fixtures from Kubo Sharness.
+
+See the [PR](https://github.com/ipfs/kubo/pull/9029) that introduced them for more details
+
+### [fixtures.car](./fixtures.car)
+
+Generated with:
+
+```sh
+# Kubo CLI version 0.18.1 (https://dist.ipfs.tech/kubo/v0.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/fixtures/t0122/fixtures.car b/fixtures/path_gateway_tar/fixtures.car
similarity index 100%
rename from fixtures/t0122/fixtures.car
rename to fixtures/path_gateway_tar/fixtures.car
diff --git a/fixtures/t0122/inside-root.car b/fixtures/path_gateway_tar/inside-root.car
similarity index 100%
rename from fixtures/t0122/inside-root.car
rename to fixtures/path_gateway_tar/inside-root.car
diff --git a/fixtures/t0122/outside-root.car b/fixtures/path_gateway_tar/outside-root.car
similarity index 100%
rename from fixtures/t0122/outside-root.car
rename to fixtures/path_gateway_tar/outside-root.car
diff --git a/fixtures/path_gateway_unixfs/README.md b/fixtures/path_gateway_unixfs/README.md
new file mode 100644
index 000000000..1c5186623
--- /dev/null
+++ b/fixtures/path_gateway_unixfs/README.md
@@ -0,0 +1,14 @@
+# Path Gateway Fixtures
+
+## Recipes
+
+### [symlink.car](./symlink.car)
+
+```sh
+# using Kubo CLI version 0.18.1 (https://dist.ipfs.tech/kubo/v0.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 > symlink.car
+```
diff --git a/fixtures/t0113-gateway-symlink.car b/fixtures/path_gateway_unixfs/symlink.car
similarity index 100%
rename from fixtures/t0113-gateway-symlink.car
rename to fixtures/path_gateway_unixfs/symlink.car
diff --git a/fixtures/redirects_file/README.md b/fixtures/redirects_file/README.md
new file mode 100644
index 000000000..9d56fb5cf
--- /dev/null
+++ b/fixtures/redirects_file/README.md
@@ -0,0 +1,12 @@
+# Fixture for Redirects File Testing
+
+## Recipes
+
+### [dnslink.yml](./dnslink.yml)
+
+See comments in the yml file.
+
+
+### [redirects.car](./redirects.car)
+
+Fixtures based on [specs.ipfs.tech/http-gateways/web-redirects-file/#test-fixtures](https://specs.ipfs.tech/http-gateways/web-redirects-file/#test-fixtures) and [IPIP-0002](https://specs.ipfs.tech/ipips/ipip-0002/)
\ No newline at end of file
diff --git a/fixtures/t0109-dnslink.yml b/fixtures/redirects_file/dnslink.yml
similarity index 85%
rename from fixtures/t0109-dnslink.yml
rename to fixtures/redirects_file/dnslink.yml
index d65b5f638..15be77219 100644
--- a/fixtures/t0109-dnslink.yml
+++ b/fixtures/redirects_file/dnslink.yml
@@ -3,5 +3,5 @@ dnslinks:
custom-dnslink:
subdomain: dnslink-enabled-on-fqdn
# this is the cid of the folder
- # t0109-redirects.car:/examples/
+ # ./redirects.car:/examples/
path: /ipfs/QmYBhLYDwVFvxos9h8CGU2ibaY66QNgv8hpfewxaQrPiZj
\ No newline at end of file
diff --git a/fixtures/t0109-redirects.car b/fixtures/redirects_file/redirects.car
similarity index 100%
rename from fixtures/t0109-redirects.car
rename to fixtures/redirects_file/redirects.car
diff --git a/fixtures/t0114/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record b/fixtures/subdomain_gateway/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record
similarity index 100%
rename from fixtures/t0114/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record
rename to fixtures/subdomain_gateway/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record
diff --git a/fixtures/t0114/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record b/fixtures/subdomain_gateway/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record
similarity index 100%
rename from fixtures/t0114/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record
rename to fixtures/subdomain_gateway/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record
diff --git a/fixtures/t0114/README.md b/fixtures/subdomain_gateway/README.md
similarity index 64%
rename from fixtures/t0114/README.md
rename to fixtures/subdomain_gateway/README.md
index 005a7f0c5..ea300eb34 100644
--- a/fixtures/t0114/README.md
+++ b/fixtures/subdomain_gateway/README.md
@@ -1,18 +1,15 @@
-# Dataset description/sources
+# Subdomain Gateway Fixtures
-- fixtures.car
- - raw CARv1
+## Recipes
-- QmUKd....ipns-record
- - ipns record, encoded with protocol buffer
+### [dnslink.yml](./dnslink.yml)
-- 12D3K....ipns-record
- - ipns record, encoded with protocol buffer
+See comments in the yml file.
-Generated with:
+### [fixtures.car](./fixtures.car)
```sh
-# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
+# using Kubo CLI version 0.21.0-rc3 (https://dist.ipfs.tech/kubo/v0.21.0-rc3/)
# CIDv0to1 is necessary because raw-leaves are enabled by default during
# "ipfs add" with CIDv1 and disabled with CIDv0
@@ -42,18 +39,22 @@ DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting)
echo DIR_CID=${DIR_CID} # ./testdirlisting
ipfs files mkdir /t0114/
-ipfs files cp /ipfs/${CIDv1} /t0114/
-ipfs files cp /ipfs/${CIDv0} /t0114/
-ipfs files cp /ipfs/${CIDv0to1} /t0114/
-ipfs files cp /ipfs/${DIR_CID} /t0114/
-ipfs files cp /ipfs/${CIDv1_TOO_LONG} /t0114/
+ipfs files cp /ipfs/${CIDv1} /t0114/hello-CIDv1
+ipfs files cp /ipfs/${CIDv0} /t0114/hello-CIDv0
+ipfs files cp /ipfs/${CIDv0to1} /t0114/hello-CIDv0to1
+ipfs files cp /ipfs/${DIR_CID} /t0114/testdirlisting
+ipfs files cp /ipfs/${CIDv1_TOO_LONG} /t0114/hello-CIDv1_TOO_LONG
ROOT=`ipfs files stat /t0114/ --hash`
ipfs dag export ${ROOT} > ./fixtures.car
+```
+
+### [ipns-records](./)
-# Then the keys
+We create ipns-records pointing to the CIDv1 generated above:
+```sh
KEY_NAME=test_key_rsa_$RANDOM
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 ${KEY_NAME} | head -n1 | tr -d "\n")
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
@@ -89,23 +90,4 @@ echo ED25519_IPNS_IDv1=${ED25519_IPNS_IDv1}
echo ED25519_IPNS_IDv1_DAGPB=${ED25519_IPNS_IDv1_DAGPB}
echo IPNS_ED25519_B58MH=${IPNS_ED25519_B58MH}
echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID}
-
-# CID_VAL=hello
-# CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
-# CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
-# CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
-# CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
-# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
-
-# RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
-# RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
-# RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w
-# RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo
-
-# ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
-# ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
-# ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
-# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq
-# IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
-# IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
```
diff --git a/fixtures/t0114/dnslink.yml b/fixtures/subdomain_gateway/dnslink.yml
similarity index 100%
rename from fixtures/t0114/dnslink.yml
rename to fixtures/subdomain_gateway/dnslink.yml
diff --git a/fixtures/t0114-gateway_subdomains.car b/fixtures/subdomain_gateway/fixtures.car
similarity index 100%
rename from fixtures/t0114-gateway_subdomains.car
rename to fixtures/subdomain_gateway/fixtures.car
diff --git a/fixtures/t0114/fixtures.car b/fixtures/t0114/fixtures.car
deleted file mode 100644
index bc7b913df..000000000
Binary files a/fixtures/t0114/fixtures.car and /dev/null differ
diff --git a/fixtures/t0123/README.md b/fixtures/t0123/README.md
index 5a63b192a..de670caa5 100644
--- a/fixtures/t0123/README.md
+++ b/fixtures/t0123/README.md
@@ -14,7 +14,7 @@
generated with:
```sh
-# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
+# using Kubo CLI version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
mkdir -p rootDir/ipfs &&
mkdir -p rootDir/ipns &&
diff --git a/tests/dnslink_gateway_test.go b/tests/dnslink_gateway_test.go
index 4cd0e26e7..0a18a23b2 100644
--- a/tests/dnslink_gateway_test.go
+++ b/tests/dnslink_gateway_test.go
@@ -13,134 +13,11 @@ import (
"github.com/ipfs/gateway-conformance/tooling/tmpl"
)
-// TODO(laurent): this were in t0114_gateway_subdomains_test.go
-
-func TestDNSLinkGateway(t *testing.T) {
- tests := SugarTests{
- // ## ============================================================================
- // ## Test DNSLink requests with a custom PublicGateway (hostname config)
- // ## (DNSLink site at http://dnslink-test.example.com)
- // ## ============================================================================
- // # disable wildcard DNSLink gateway
- // # and enable it on specific NSLink hostname
- // ipfs config --json Gateway.NoDNSLink true && \
- // ipfs config --json Gateway.PublicGateways '{
- // "dnslink-enabled-on-fqdn.example.org": {
- // "NoDNSLink": false,
- // "UseSubdomains": false,
- // "Paths": ["/ipfs"]
- // },
- // "only-dnslink-enabled-on-fqdn.example.org": {
- // "NoDNSLink": false,
- // "UseSubdomains": false,
- // "Paths": []
- // },
- // "dnslink-disabled-on-fqdn.example.com": {
- // "NoDNSLink": true,
- // "UseSubdomains": false,
- // "Paths": []
- // }
- // }' || exit 1
-
- // # DNSLink test requires a daemon in online mode with precached /ipns/ mapping
- // DNSLINK_FQDN="dnslink-enabled-on-fqdn.example.org"
- // ONLY_DNSLINK_FQDN="only-dnslink-enabled-on-fqdn.example.org"
- // NO_DNSLINK_FQDN="dnslink-disabled-on-fqdn.example.com"
- // export IPFS_NS_MAP="$DNSLINK_FQDN:/ipfs/$CIDv1,$ONLY_DNSLINK_FQDN:/ipfs/$DIR_CID"
-
- // # DNSLink enabled
-
- // test_hostname_gateway_response_should_contain \
- // "request for http://{dnslink-fqdn}/ PublicGateway returns expected payload" \
- // "$DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/" \
- // "$CID_VAL"
-
- // test_hostname_gateway_response_should_contain \
- // "request for {dnslink-fqdn}/ipfs/{cid} returns expected payload when /ipfs is on Paths whitelist" \
- // "$DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/ipfs/$CIDv1" \
- // "$CID_VAL"
-
- // # Test for a fun edge case: DNSLink-only gateway without /ipfs/ namespace
- // # mounted, and with subdirectory named "ipfs" ¯\_(ツ)_/¯
- // test_hostname_gateway_response_should_contain \
- // "request for {dnslink-fqdn}/ipfs/file.txt returns data from content root when /ipfs in not on Paths whitelist" \
- // "$ONLY_DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/ipfs/file.txt" \
- // "I am a txt file"
-
- // test_hostname_gateway_response_should_contain \
- // "request for {dnslink-fqdn}/ipns/{peerid} returns 404 when path is not whitelisted" \
- // "$DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/ipns/$RSA_IPNS_IDv0" \
- // "404 Not Found"
-
- // test_hostname_gateway_response_should_contain \
- // "request for {dnslink-fqdn}/ipns/{peerid} returns 404 when path is not whitelisted" \
- // "$DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/ipns/$ED25519_IPNS_IDv0" \
- // "404 Not Found"
-
- // # DNSLink disabled
-
- // test_hostname_gateway_response_should_contain \
- // "request for http://{dnslink-fqdn}/ returns 404 when NoDNSLink=true" \
- // "$NO_DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/" \
- // "404 Not Found"
-
- // test_hostname_gateway_response_should_contain \
- // "request for {dnslink-fqdn}/ipfs/{cid} returns 404 when path is not whitelisted" \
- // "$NO_DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/ipfs/$CIDv0" \
- // "404 Not Found"
-
- // ## ============================================================================
- // ## Test wildcard DNSLink (any hostname, with default config)
- // ## ============================================================================
-
- // test_kill_ipfs_daemon
-
- // # enable wildcard DNSLink gateway (any value in Host header)
- // # and remove custom PublicGateways
- // ipfs config --json Gateway.NoDNSLink false && \
- // ipfs config --json Gateway.PublicGateways '{}' || exit 1
-
- // # DNSLink test requires a daemon in online mode with precached /ipns/ mapping
- // DNSLINK_FQDN="wildcard-dnslink-not-in-config.example.com"
- // export IPFS_NS_MAP="$DNSLINK_FQDN:/ipfs/$CIDv1"
-
- // # restart daemon to apply config changes
- // test_launch_ipfs_daemon
-
- // # make sure test setup is valid (fail if CoreAPI is unable to resolve)
- // test_expect_success "spoofed DNSLink record resolves in cli" "
- // ipfs resolve /ipns/$DNSLINK_FQDN > result &&
- // test_should_contain \"$CIDv1\" result &&
- // ipfs cat /ipns/$DNSLINK_FQDN > result &&
- // test_should_contain \"$CID_VAL\" result
- // "
-
- // # gateway test
- //
- // test_hostname_gateway_response_should_contain \
- // "request for http://{dnslink-fqdn}/ (wildcard) returns expected payload" \
- // "$DNSLINK_FQDN" \
- // "http://127.0.0.1:$GWAY_PORT/" \
- // "$CID_VAL"
- }
-
- RunWithSpecs(t, helpers.UnwrapSubdomainTests(t, tests), specs.DNSLinkGateway)
-}
-
-// TODO(laurent): this was in t0115_gateway_dir_listing_test.go
-
func TestDNSLinkGatewayUnixFSDirectoryListing(t *testing.T) {
- fixture := car.MustOpenUnixfsCar("t0115/fixtures.car")
+ fixture := car.MustOpenUnixfsCar("dir_listing/fixtures.car")
file := fixture.MustGetNode("ą", "ę", "file-źł.txt")
- dnsLinks := dnslink.MustOpenDNSLink("t0115/dnslink.yml")
+ dnsLinks := dnslink.MustOpenDNSLink("dir_listing/dnslink.yml")
dnsLink := dnsLinks.MustGet("website")
gatewayURL := SubdomainGatewayURL
@@ -154,26 +31,7 @@ func TestDNSLinkGatewayUnixFSDirectoryListing(t *testing.T) {
dnsLinkHostname := tmpl.Fmt("{{dnslink}}.{{host}}", dnsLink, u.Host)
- // ## ============================================================================
- // ## Test dir listing on DNSLink gateway (eg. example.com)
- // ## ============================================================================
tests = append(tests, SugarTests{
- // # DNSLink test requires a daemon in online mode with precached /ipns/ mapping
- // test_kill_ipfs_daemon
- // DNSLINK_HOSTNAME="website.example.com"
- // export IPFS_NS_MAP="$DNSLINK_HOSTNAME:/ipfs/$DIR_CID"
- // test_launch_ipfs_daemon
-
- // # Note that:
- // # - this type of gateway is also tested in gateway_test.go#TestIPNSHostnameBacklinks
- // # (go tests and sharness tests should be kept in sync)
- // # - we skip DNS lookup by running curl with --resolve $DNSLINK_HOSTNAME:127.0.0.1
-
- // test_expect_success "dnslink gw: backlink on root CID should be hidden" '
- // curl -v -sD - --resolve $DNSLINK_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DNSLINK_HOSTNAME:$GWAY_PORT/ > list_response &&
- // test_should_contain "Index of" list_response &&
- // test_should_not_contain ".." list_response
- // '
{
Name: "Backlink on root CID should be hidden (TODO: cleanup Kubo-specifics)",
Request: Request().
@@ -186,11 +44,6 @@ func TestDNSLinkGatewayUnixFSDirectoryListing(t *testing.T) {
),
),
},
- // test_expect_success "dnslink gw: redirect dir listing to URL with trailing slash" '
- // curl -sD - --resolve $DNSLINK_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DNSLINK_HOSTNAME:$GWAY_PORT/ą/ę > list_response &&
- // test_should_contain "HTTP/1.1 301 Moved Permanently" list_response &&
- // test_should_contain "Location: /%c4%85/%c4%99/" list_response
- // '
{
Name: "Redirect dir listing to URL with trailing slash",
Request: Request().
@@ -201,25 +54,6 @@ func TestDNSLinkGatewayUnixFSDirectoryListing(t *testing.T) {
Header("Location").Equals(`/%c4%85/%c4%99/`),
),
},
- // test_expect_success "dnslink gw: Etag should be present" '
- // curl -sD - --resolve $DNSLINK_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DNSLINK_HOSTNAME:$GWAY_PORT/ą/ę/ > list_response &&
- // test_should_contain "Index of" list_response &&
- // test_should_contain "Etag: \"DirIndex-" list_response
- // '
- // test_expect_success "dnslink gw: backlink on subdirectory should point at parent directory" '
- // test_should_contain ".." list_response
- // '
- // test_expect_success "dnslink gw: breadcrumbs should point at content root mounted at dnslink origin" '
- // test_should_contain "/ipns/website.example.com/ą/ę" list_response
- // '
- // test_expect_success "dnslink gw: name column should be a link to content root mounted at dnslink origin" '
- // test_should_contain "file-źł.txt" list_response
- // '
- // # DNSLink websites don't have public gateway mounted by default
- // # See: https://github.com/ipfs/dir-index-html/issues/42
- // test_expect_success "dnslink gw: hash column should be a CID link to cid.ipfs.tech" '
- // test_should_contain "" list_response
- // '
{
Name: "Regular dir listing (TODO: cleanup Kubo-specifics)",
Request: Request().
@@ -234,7 +68,7 @@ func TestDNSLinkGatewayUnixFSDirectoryListing(t *testing.T) {
- name column should be a link to content root mounted at dnslink origin
- hash column should be a CID link to cid.ipfs.tech
DNSLink websites don't have public gateway mounted by default
- See: https://github.com/ipfs/dir-index-html/issues/42 (TODO: class and other attrs are kubo-specific)
+ See: https://github.com/ipfs/dir-index-html/issues/42 (TODO: class and other attrs are kubo-specific)
`,
And(
Contains("Index of"),
diff --git a/tests/path_gateway_cors_test.go b/tests/path_gateway_cors_test.go
new file mode 100644
index 000000000..563a2a71a
--- /dev/null
+++ b/tests/path_gateway_cors_test.go
@@ -0,0 +1,56 @@
+package tests
+
+import (
+ "testing"
+
+ "github.com/ipfs/gateway-conformance/tooling/specs"
+ . "github.com/ipfs/gateway-conformance/tooling/test"
+)
+
+func TestCors(t *testing.T) {
+ cidHello := "bafkqabtimvwgy3yk" // hello
+
+ tests := SugarTests{
+ {
+ Name: "GET Responses from Gateway should include CORS headers allowing JS from other origins to read the data cross-origin.",
+ Request: Request().
+ Path("/ipfs/{{CID}}/", cidHello),
+ Response: Expect().
+ Headers(
+ Header("Access-Control-Allow-Origin").Equals("*"),
+ Header("Access-Control-Allow-Methods").Has("GET", "HEAD", "OPTIONS"),
+ Header("Access-Control-Allow-Headers").Has("Content-Type", "Range", "User-Agent", "X-Requested-With"),
+ Header("Access-Control-Expose-Headers").Has(
+ "Content-Range",
+ "Content-Length",
+ "X-Ipfs-Path",
+ "X-Ipfs-Roots",
+ "X-Chunked-Output",
+ "X-Stream-Output",
+ ),
+ ),
+ },
+ {
+ Name: "OPTIONS to Gateway succeeds",
+ Request: Request().
+ Method("OPTIONS").
+ Path("/ipfs/{{CID}}/", cidHello),
+ Response: Expect().
+ Headers(
+ Header("Access-Control-Allow-Origin").Equals("*"),
+ Header("Access-Control-Allow-Methods").Has("GET", "HEAD", "OPTIONS"),
+ Header("Access-Control-Allow-Headers").Has("Content-Type", "Range", "User-Agent", "X-Requested-With"),
+ Header("Access-Control-Expose-Headers").Has(
+ "Content-Range",
+ "Content-Length",
+ "X-Ipfs-Path",
+ "X-Ipfs-Roots",
+ "X-Chunked-Output",
+ "X-Stream-Output",
+ ),
+ ),
+ },
+ }
+
+ RunWithSpecs(t, tests, specs.PathGatewayUnixFS)
+}
diff --git a/tests/path_gateway_dag_test.go b/tests/path_gateway_dag_test.go
index 8bccaf180..d0b0aec1b 100644
--- a/tests/path_gateway_dag_test.go
+++ b/tests/path_gateway_dag_test.go
@@ -14,7 +14,7 @@ import (
// TODO(laurent): this was t0123_gateway_json_cbor_test
func TestGatewayJsonCbor(t *testing.T) {
- fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car")
+ fixture := car.MustOpenUnixfsCar("path_gateway_dag/gateway-json-cbor.car")
fileJSON := fixture.MustGetNode("ą", "ę", "t.json")
fileJSONCID := fileJSON.Cid()
@@ -22,7 +22,7 @@ func TestGatewayJsonCbor(t *testing.T) {
tests := SugarTests{
{
- Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type (1)",
+ Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type - without headers",
Hint: `
## Quick regression check for JSON stored on UnixFS:
## it has nothing to do with DAG-JSON and JSON codecs,
@@ -30,10 +30,7 @@ func TestGatewayJsonCbor(t *testing.T) {
## and we want to avoid surprises like https://github.com/protocol/bifrost-infra/issues/2290
`,
Request: Request().
- Path("/ipfs/{{cid}}", fileJSONCID).
- Headers(
- Header("Accept", "application/json"),
- ),
+ Path("/ipfs/{{cid}}", fileJSONCID),
Response: Expect().
Status(200).
Headers(
@@ -43,7 +40,7 @@ func TestGatewayJsonCbor(t *testing.T) {
Body(fileJSONData),
},
{
- Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type (2)",
+ Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type - with headers",
Hint: `
## Quick regression check for JSON stored on UnixFS:
## it has nothing to do with DAG-JSON and JSON codecs,
@@ -71,7 +68,7 @@ func TestGatewayJsonCbor(t *testing.T) {
// ## 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)
func TestDAgPbConversion(t *testing.T) {
- fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car")
+ fixture := car.MustOpenUnixfsCar("path_gateway_dag/gateway-json-cbor.car")
dir := fixture.MustGetRoot()
file := fixture.MustGetNode("ą", "ę", "file-źł.txt")
@@ -95,16 +92,6 @@ func TestDAgPbConversion(t *testing.T) {
formatedDir := dir.Formatted("dag-" + row.Format)
tests := SugarTests{
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS file as {{name}} with format=dag-{{format}} converts to the expected Content-Type", row.Name, row.Format),
Request: Request().
@@ -123,16 +110,6 @@ func TestDAgPbConversion(t *testing.T) {
formatedFile,
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS directory as {{name}} with format=dag-{{format}} converts to the expected Content-Type", row.Name, row.Format),
Request: Request().
@@ -150,14 +127,6 @@ func TestDAgPbConversion(t *testing.T) {
formatedDir,
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS as {{name}} with 'Accept: application/vnd.ipld.dag-{{format}}' converts to the expected Content-Type", row.Name, row.Format),
Request: Request().
@@ -176,12 +145,6 @@ func TestDAgPbConversion(t *testing.T) {
Not().Contains("application/{{format}}", row.Format),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS as {{name}} with 'Accept: foo, application/vnd.ipld.dag-{{format}},bar' converts to the expected Content-Type", row.Name, row.Format),
Request: Request().
@@ -196,16 +159,6 @@ func TestDAgPbConversion(t *testing.T) {
Equals("application/vnd.ipld.dag-{{format}}", row.Format),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS with format={{format}} (not dag-{{format}}) is no-op (no conversion)", row.Format),
Request: Request().
@@ -224,16 +177,6 @@ func TestDAgPbConversion(t *testing.T) {
fileData,
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET UnixFS with 'Accept: application/{{format}}' (not dag-{{format}}) is no-op (no conversion)", row.Format),
Request: Request().
@@ -275,25 +218,14 @@ func TestPlainCodec(t *testing.T) {
}
for _, row := range table {
- plain := car.MustOpenUnixfsCar(Fmt("t0123/plain.{{format}}.car", row.Format)).MustGetRoot()
- plainOrDag := car.MustOpenUnixfsCar(Fmt("t0123/plain-that-can-be-dag.{{format}}.car", row.Format)).MustGetRoot()
+ plain := car.MustOpenUnixfsCar(Fmt("path_gateway_dag/plain-{{format}}.car", row.Format)).MustGetRoot()
+ plainOrDag := car.MustOpenUnixfsCar(Fmt("path_gateway_dag/plain-cbor-that-can-be-dag-{{format}}.car", row.Format)).MustGetRoot()
formatted := plainOrDag.Formatted("dag-" + row.Format)
plainCID := plain.Cid()
plainOrDagCID := plainOrDag.Cid()
tests := SugarTests{
- /**
- # 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
- '
- */
{
Name: Fmt(`GET {{name}} without Accept or format= has expected "{{format}}" Content-Type and body as-is`, row.Name, row.Format),
Hint: `
@@ -312,17 +244,6 @@ func TestPlainCodec(t *testing.T) {
plain.RawData(),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} with ?format= has expected {{format}} Content-Type and body as-is", row.Name, row.Format),
Hint: `
@@ -342,17 +263,6 @@ func TestPlainCodec(t *testing.T) {
plain.RawData(),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} with Accept has expected {{format}} Content-Type and body as-is", row.Name, row.Format),
Hint: `
@@ -372,20 +282,6 @@ func TestPlainCodec(t *testing.T) {
plain.RawData(),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} with format=dag-{{format}} interprets {{format}} as dag-* variant and produces expected Content-Type and body", row.Name, row.Format),
Hint: `
@@ -414,20 +310,13 @@ func TestPlainCodec(t *testing.T) {
// ## Pathing, traversal over DAG-JSON and DAG-CBOR
func TestPathing(t *testing.T) {
- dagJSONTraversal := car.MustOpenUnixfsCar("t0123/dag-json-traversal.car").MustGetRoot()
- dagCBORTraversal := car.MustOpenUnixfsCar("t0123/dag-cbor-traversal.car").MustGetRoot()
+ dagJSONTraversal := car.MustOpenUnixfsCar("path_gateway_dag/dag-json-traversal.car").MustGetRoot()
+ dagCBORTraversal := car.MustOpenUnixfsCar("path_gateway_dag/dag-cbor-traversal.car").MustGetRoot()
dagJSONTraversalCID := dagJSONTraversal.Cid()
dagCBORTraversalCID := dagCBORTraversal.Cid()
tests := SugarTests{
- /**
- 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
- '
- */
{
Name: "GET DAG-JSON traversal returns 501 if there is path remainder",
Request: Request().
@@ -437,14 +326,6 @@ func TestPathing(t *testing.T) {
Status(501).
Body(Contains("reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented")),
},
- /**
- 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
- '
- */
{
Name: "GET DAG-JSON traverses multiple links",
Request: Request().
@@ -458,13 +339,6 @@ func TestPathing(t *testing.T) {
IsJSONEqual([]byte(`{"hello": "this is not a link"}`)),
),
},
- /**
- 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
- '
- */
{
Name: "GET DAG-CBOR traversal returns 501 if there is path remainder",
Request: Request().
@@ -474,14 +348,6 @@ func TestPathing(t *testing.T) {
Status(501).
Body(Contains("reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented")),
},
- /**
- 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
- '
- */
{
Name: "GET DAG-CBOR traverses multiple links",
Request: Request().
@@ -516,20 +382,11 @@ func TestNativeDag(t *testing.T) {
}
for _, row := range table {
- dagTraversal := car.MustOpenUnixfsCar(Fmt("t0123/dag-{{format}}-traversal.car", row.Format)).MustGetRoot()
+ dagTraversal := car.MustOpenUnixfsCar(Fmt("path_gateway_dag/dag-{{format}}-traversal.car", row.Format)).MustGetRoot()
dagTraversalCID := dagTraversal.Cid()
formatted := dagTraversal.Formatted("dag-" + row.Format)
tests := SugarTests{
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} from /ipfs without explicit format returns the same payload as the raw block", row.Name),
Hint: `GET without explicit format and Accept: text/html returns raw block`,
@@ -541,15 +398,6 @@ func TestNativeDag(t *testing.T) {
row.Checker(formatted),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} from /ipfs with format=dag-{{format}} returns the same payload as the raw block", row.Name, row.Format),
Hint: `GET dag-cbor block via Accept and ?format and ensure both are the same as ipfs block get output`,
@@ -562,21 +410,6 @@ func TestNativeDag(t *testing.T) {
row.Checker(formatted),
),
},
- /**
- 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
- '
- Note: we skip this test since we compare responses bytes to bytes above.
- */
- /**
- 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
- '
- */
{
Name: Fmt("GET {{name}} from /ipfs with application/vnd.ipld.dag-{{format}} returns the same payload as the raw block", row.Name, row.Format),
Request: Request().
@@ -588,16 +421,6 @@ func TestNativeDag(t *testing.T) {
row.Checker(formatted),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET {{name}} with format={{format}} returns same payload as format=dag-{{format}} but with plain Content-Type", row.Name, row.Format),
Hint: `Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes`,
@@ -611,14 +434,6 @@ func TestNativeDag(t *testing.T) {
row.Checker(formatted),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET {{name}} with Accept: application/{{format}} returns same payload as application/vnd.ipld.dag-{{format}} but with plain Content-Type", row.Name, row.Format),
Request: Request().
@@ -631,24 +446,6 @@ func TestNativeDag(t *testing.T) {
row.Checker(formatted),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("GET response for application/vnd.ipld.dag-{{format}} has expected Content-Type", row.Format),
Hint: `Make sure expected HTTP headers are returned with the dag- block`,
@@ -663,12 +460,6 @@ func TestNativeDag(t *testing.T) {
Header("X-Content-Type-Options").Hint("includes nosniff hint").Contains("nosniff"),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET for application/vnd.ipld.dag-{{format}} with query filename includes Content-Disposition with custom filename", row.Format),
Request: Request().
@@ -682,12 +473,6 @@ func TestNativeDag(t *testing.T) {
Contains(`{{disposition}}; filename="foobar.{{format}}"`, row.Disposition, row.Format),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("GET for application/vnd.ipld.dag-{{format}} with ?download=true forces Content-Disposition: attachment", row.Format),
Request: Request().
@@ -702,21 +487,6 @@ func TestNativeDag(t *testing.T) {
Contains(`attachment; filename="foobar.{{format}}"`, row.Format),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("Cache control HTTP headers ({{format}})", row.Format),
Hint: `(basic checks, detailed behavior is tested in t0116-gateway-cache.sh)`,
@@ -731,15 +501,6 @@ func TestNativeDag(t *testing.T) {
Header("Cache-Control").Hint("includes Cache-Control").Contains("public, max-age=29030400, immutable"),
),
},
- /**
- # 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
- '
- */
{
Name: Fmt("HEAD {{name}} with no explicit format returns HTTP 200", row.Name),
Request: Request().
@@ -752,15 +513,6 @@ func TestNativeDag(t *testing.T) {
Header("Content-Length").Hint("includes Content-Length").Exists(),
),
},
- /**
- 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
- '
- */
{
Name: Fmt("HEAD {{name}} with an explicit DAG-JSON format returns HTTP 200", row.Name),
Request: Request().
@@ -775,14 +527,6 @@ func TestNativeDag(t *testing.T) {
Header("Content-Length").Hint("includes Content-Length").Exists(),
),
},
- /**
- test_expect_success "HEAD $name with only-if-cached for missing block returns HTTP 412 Precondition Failed" '
- MISSING_CID=$(echo "{\"t\": \"$(date +{{}})\"}" | 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
- '
- */
{
Name: Fmt("HEAD {{name}} with only-if-cached for missing block returns HTTP 412 Precondition Failed", row.Name),
Request: Request().
@@ -792,14 +536,6 @@ func TestNativeDag(t *testing.T) {
Response: Expect().
Status(412),
},
- // 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 "