Test HTTP Gateway _redirects support
- Init IPFS
- Launch IPFS Daemon
- Add the _redirects file test directory
- request for $REDIRECTS_DIR_HOSTNAME/redirect-one redirects with default of 301, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/301-redirect-one redirects with 301, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/302-redirect-two redirects with 302, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/200-index returns 200, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/posts/:year/:month/:day/:title redirects with 301 and placeholders, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/splat/one.html redirects with 301 and splat placeholder, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/not-found/has-no-redirects-entry returns custom 404, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/gone/has-no-redirects-entry returns custom 410, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/unavail/has-no-redirects-entry returns custom 451, per _redirects file
- request for $REDIRECTS_DIR_HOSTNAME/catch-all returns 200, per _redirects file
- request for http://127.0.0.1:$GWAY_PORT/ipfs/$REDIRECTS_DIR_CID/301-redirect-one returns generic 404 (no custom 404 from _redirects since no origin isolation)
- newline: _redirects has CRLF line terminators
- newline: request for $NEWLINE_REDIRECTS_DIR_HOSTNAME/redirect-one redirects with default of 301, per _redirects file
- good codes: request for $GOOD_REDIRECTS_DIR_HOSTNAME/redirect-one redirects with default of 301, per _redirects file
- bad codes: request for $BAD_REDIRECTS_DIR_HOSTNAME/not-found returns error about bad code
- bad codes: request for $BAD_REDIRECTS_DIR_HOSTNAME/found.html doesn't return error about bad code
- invalid file: request for $INVALID_REDIRECTS_DIR_HOSTNAME/not-found returns error about invalid redirects file
- invalid file: request for $INVALID_REDIRECTS_DIR_HOSTNAME/not-found returns error about invalid redirects file
- invalid file: request for $TOO_LARGE_REDIRECTS_DIR_HOSTNAME/not-found returns error about too large redirects file
- Restart IPFS Daemon
- spoofed DNSLink record resolves in cli
- request for $DNSLINK_FQDN/redirect-one redirects with default of 301, per _redirects file
- request for $DNSLINK_FQDN/en/has-no-redirects-entry returns custom 404, per _redirects file
- request for $NO_DNSLINK_FQDN/redirect-one does not redirect, since DNSLink is disabled
- Kill IPFS Daemon
- requires CAR file import
- checks if import didn't modify the newlines
- reconfigures the gateway DNSLink settings
Test HTTP Gateway (Writable)
- Init IPFS
- Launch IPFS Daemon --writable
- ipfs daemon --writable overrides config
- Kill IPFS Daemon
- prepare config -- gateway writable
- Launch IPFS Daemon --writable=false
- ipfs daemon --writable=false overrides Writable=true config
- Restart IPFS Daemon
- ipfs daemon up
- deprecation notice is printed when Gateway.Writable=true
- HTTP gateway gives access to sample file
- HTTP POST file gives Hash
- We can HTTP GET file just created
- We got the correct hash
- HTTP GET empty directory
- HTTP PUT file to construct a hierarchy
- We can HTTP GET file just created
- HTTP PUT file to append to existing hierarchy
- We can HTTP GET file just updated
- HTTP PUT to replace a directory
- We can HTTP GET file just put over a directory
- HTTP PUT to /ipns fails
- Kill IPFS Daemon
- reconfigures the gateway writable settings first
- is self-sufficient in a sense that it can create assets it verifies itself
Test CORS behavior on Gateway port
- Init IPFS
- Default Gateway.HTTPHeaders config match expected values
- Launch IPFS Daemon
- GET to Gateway succeeds
- GET response for Gateway resource looks good
- OPTIONS to Gateway succeeds
- OPTIONS response for Gateway resource looks good
- Kill IPFS Daemon
- Can configure gateway headers
- Launch IPFS Daemon
- OPTIONS to Gateway without custom headers succeeds
- Access-Control-Allow-Headers extends the implicit list
- OPTIONS to Gateway with a custom header succeeds
- Access-Control-Allow-Headers extends the implicit list
- Access-Control-Allow-Origin replaces the implicit list
- Assert the default API.HTTPHeaders config is empty
- Default CORS GET to {gw}/api/v0
- Default CORS GET response from {gw}/api/v0 is 403 Forbidden and has no CORS headers
- Default OPTIONS to {gw}/api/v0
- OPTIONS response from {gw}/api/v0 has no CORS header
- Kill IPFS Daemon
- Manually set API.HTTPHeaders config to be as relaxed as Gateway.HTTPHeaders
- Launch IPFS Daemon
- Manually relaxed CORS GET to {gw}/api/v0
- Manually relaxed CORS GET response from {gw}/api/v0 is the same as Gateway
- Manually relaxed OPTIONS to {gw}/api/v0
- Manually relaxed OPTIONS response from {gw}/api/v0 is the same as Gateway
- Kill IPFS Daemon
- queries preexisting
hello
file - reconfigures the gateway headers settings
- sets Origin header
Test symlink support on the HTTP gateway
- Init IPFS
- Launch IPFS Daemon
- Create a test directory with symlinks
- Add the test directory
- Test the directory listing
- Test the symlink
- Kill IPFS Daemon
- requires adding a directory with symlinks first
Test subdomain support on the HTTP gateway
- Init IPFS
- Launch IPFS Daemon without network
- Add test text file
- Add the test directory
- Publish test text file to IPNS using RSA keys
- Publish test text file to IPNS using ED25519 keys
- start daemon with empty config for Gateway.PublicGateways
- request for 127.0.0.1/ipfs/{CID} stays on path
- request for localhost/ipfs/{CIDv1} returns HTTP 301 Moved Permanently
- request for localhost/ipfs/{CIDv1} returns Location HTTP header for subdomain redirect in browsers
- request for localhost/ipfs/{DIR_CID} returns HTTP 301 Moved Permanently
- request for localhost/ipfs/{DIR_CID} returns Location HTTP header for subdomain redirect in browsers
- request for localhost/ipfs/{CIDv1} includes valid payload in body for CLI tools like curl
- request for localhost/ipfs/{CIDv0} redirects to CIDv1 representation in subdomain
- request for localhost/ipns/{CIDv0} redirects to CIDv1 with libp2p-key multicodec in subdomain
- request for localhost/ipns/{CIDv0} redirects to CIDv1 with libp2p-key multicodec in subdomain
- request for localhost/ipns/{fqdn} redirects to DNSLink in subdomain
- request for localhost/api
- request for {cid}.ipfs.localhost/api returns data if present on the content root
- request for {cid}.ipfs.localhost/api/v0/refs returns 404
- request for {CID}.ipfs.localhost should return expected payload
- request for {CID}.ipfs.localhost/ipfs/{CID} should return HTTP 404
- request for {CID}.ipfs.localhost/ipfs/file.txt should return data from a file in CID content root
- valid file and subdirectory paths in directory listing at {cid}.ipfs.localhost
- valid parent directory path in directory listing at {cid}.ipfs.localhost/sub/dir
- request for deep path resource at {cid}.ipfs.localhost/sub/dir/file
- request for {CIDv1-libp2p-key}.ipns.localhost returns expected payload
- request for {CIDv1-libp2p-key}.ipns.localhost returns expected payload
- localhost request for {CIDv1-dag-pb}.ipns.localhost redirects to CID with libp2p-key multicodec
- localhost request for {CIDv1-dag-pb}.ipns.localhost redirects to CID with libp2p-key multicodec
- Restart IPFS Daemon
- request for {dnslink}.ipns.localhost returns expected payload
- request for api.localhost returns API response
- Restart IPFS Daemon without network
- request for localhost/ipns/{fqdn} redirects to DNSLink in subdomain with DNS inlining
- request for example.com/ipns/{fqdn} redirects to DNSLink in subdomain with DNS inlining
- Restart IPFS Daemon without network
- request for example.com/ipfs/{CIDv1} produces redirect to {CIDv1}.ipfs.example.com
- request for example.com/ipfs/{InvalidCID} produces useful error before redirect
- request for example.com/ipfs/{CIDv0} produces redirect to {CIDv1}.ipfs.example.com
- request for http://example.com/ipfs/{CID} with X-Forwarded-Proto: https produces redirect to HTTPS URL
- request for example.com/ipfs/?uri=ipfs%3A%2F%2F.. produces redirect to /ipfs/.. content path
- request for example.com/ipns/{CIDv0} redirects to CIDv1 with libp2p-key multicodec in subdomain
- request for example.com/ipns/{CIDv0} redirects to CIDv1 with libp2p-key multicodec in subdomain
- request for example.com/ipns/{fqdn} redirects to DNSLink in subdomain
- request for example.com/ipns/{fqdn} with X-Forwarded-Proto redirects to TLS-safe label in subdomain
- request for example.com/ipns/?uri=ipns%3A%2F%2F.. produces redirect to /ipns/.. content path
- request for {CID}.ipfs.example.com should return expected payload
- request for {CID}.ipfs.example.com/ipfs/{CID} should return HTTP 404
- valid file and directory paths in directory listing at {cid}.ipfs.example.com
- valid parent directory path in directory listing at {cid}.ipfs.example.com/sub/dir
- valid breadcrumb links in the header of directory listing at {cid}.ipfs.example.com/sub/dir
- request for deep path resource {cid}.ipfs.example.com/sub/dir/file
- request for {CIDv1-libp2p-key}.ipns.example.com returns expected payload
- request for {CIDv1-libp2p-key}.ipns.example.com returns expected payload
- hostname request for {CIDv1-dag-pb}.ipns.localhost redirects to CID with libp2p-key multicodec
- hostname request for {CIDv1-dag-pb}.ipns.localhost redirects to CID with libp2p-key multicodec
- request for example.com/api/v0/refs returns expected payload when /api is on Paths whitelist
- request for {cid}.ipfs.example.com/api returns data if present on the content root
- request for {cid}.ipfs.example.com/api/v0/refs returns 404
- Restart IPFS Daemon without network
- request for example.com/api/v0/refs returns 404 if /api not on Paths whitelist
- request for {cid}.ipfs.example.com/api returns data if present on the content root
- Restart IPFS Daemon
- request for {dnslink}.ipns.example.com returns expected payload
- request for {single-label-dnslink}.ipns.example.com with X-Forwarded-Proto returns expected payload
- request for a ED25519 libp2p-key at localhost/ipns/{b58mh} returns Location HTTP header for DNS-safe subdomain redirect in browsers
- request for a too long CID at localhost/ipfs/{CIDv1} returns human readable error
- request for a too long CID at localhost/ipfs/{CIDv1} returns HTTP Error 400 Bad Request
- request for a too long CID at {CIDv1}.ipfs.localhost returns expected payload
- request for a ED25519 libp2p-key at example.com/ipns/{b58mh} returns Location HTTP header for DNS-safe subdomain redirect in browsers
- request for a too long CID at example.com/ipfs/{CIDv1} returns human readable error
- request for a too long CID at example.com/ipfs/{CIDv1} returns HTTP Error 400 Bad Request
- request for a too long CID at {CIDv1}.ipfs.example.com returns HTTP Error 400 Bad Request
- Restart IPFS Daemon without network
- request for *.ipns.example.com returns HTTP 404 Not Found when /ipns is not on Paths whitelist
- request for *.ipns.example.com returns HTTP 404 Not Found when /ipns is not on Paths whitelist
- Restart IPFS Daemon without network
- request for example.com/ipfs/{CIDv1} returns expected payload
- request for {CID}.ipfs.example.com/ipfs/{CID} should return HTTP 404 Not Found
- request for example.com/ipns/ returns HTTP 404 Not Found when /ipns is not on Paths whitelist
- request for example.com/ipns/ returns HTTP 404 Not Found when /ipns is not on Paths whitelist
- Restart IPFS Daemon
- spoofed DNSLink record resolves in cli
- request for http://{dnslink-fqdn}/ PublicGateway returns expected payload
- request for {dnslink-fqdn}/ipfs/{cid} returns expected payload when /ipfs is on Paths whitelist
- request for {dnslink-fqdn}/ipfs/file.txt returns data from content root when /ipfs in not on Paths whitelist
- request for {dnslink-fqdn}/ipns/{peerid} returns 404 when path is not whitelisted
- request for {dnslink-fqdn}/ipns/{peerid} returns 404 when path is not whitelisted
- request for http://{dnslink-fqdn}/ returns 404 when NoDNSLink=true
- request for {dnslink-fqdn}/ipfs/{cid} returns 404 when path is not whitelisted
- Restart IPFS Daemon
- spoofed DNSLink record resolves in cli
- request for http://{dnslink-fqdn}/ (wildcard) returns expected payload
- Restart IPFS Daemon without network
- request for http://fake.domain.com/ipfs/{CID} doesn't match the example.com gateway
- request for http://fake.domain.com/ipfs/{CID} with X-Forwarded-Host: example.com match the example.com gateway
- request for http://fake.domain.com/ipfs/{CID} with X-Forwarded-Host: example.com and X-Forwarded-Proto: https match the example.com gateway, redirect with https
- Restart IPFS Daemon without network
- request for foo.example1.com/ipfs/{CIDv1} produces redirect to {CIDv1}.ipfs.foo.example1.com
- request for {CID}.ipfs.foo.example1.com should return expected payload
- request for foo.bar.example2.com/ipfs/{CIDv1} produces redirect to {CIDv1}.ipfs.foo.bar.example2.com
- request for {CID}.ipfs.foo.bar.example2.com should return expected payload
- request for foo.bar.example3.com/ipfs/{CIDv1} produces redirect to {CIDv1}.ipfs.foo.bar.example3.com
- request for {CID}.ipfs.foo.bar.example3.com should return expected payload
- request for foo.bar-dev-boo.example4.com/ipfs/{CIDv1} produces redirect to {CIDv1}.ipfs.foo.bar-dev-boo.example4.com
- request for {CID}.ipfs.foo.bar-dev-boo.example4.com should return expected payload
- Restart IPFS Daemon without network
- request for localhost/ipfs/{CID} stays on path when subdomain gw is explicitly disabled
- Kill IPFS Daemon
- requires adding files with different CID versions
- requires adding directory first
- requires IPNS publishing
- reconfigures IPFS with different gateway configs
Test directory listing (dir-index-html) on the HTTP gateway
- Init IPFS
- Launch IPFS Daemon without network
- Add the test directory
- path gw: backlink on root CID should be hidden
- path gw: redirect dir listing to URL with trailing slash
- path gw: Etag should be present
- path gw: breadcrumbs should point at /ipfs namespace mounted at Origin root
- path gw: backlink on subdirectory should point at parent directory
- path gw: name column should be a link to its content path
- path gw: hash column should be a CID link with filename param
- subdomain gw: backlink on root CID should be hidden
- subdomain gw: redirect dir listing to URL with trailing slash
- subdomain gw: Etag should be present
- subdomain gw: backlink on subdirectory should point at parent directory
- subdomain gw: breadcrumbs should leverage path-based router mounted on the parent domain
- subdomain gw: name column should be a link to content root mounted at subdomain origin
- subdomain gw: hash column should be a CID link to path router with filename param
- Restart IPFS Daemon
- dnslink gw: backlink on root CID should be hidden
- dnslink gw: redirect dir listing to URL with trailing slash
- dnslink gw: Etag should be present
- dnslink gw: backlink on subdirectory should point at parent directory
- dnslink gw: breadcrumbs should point at content root mounted at dnslink origin
- dnslink gw: name column should be a link to content root mounted at dnslink origin
- dnslink gw: hash column should be a CID link to cid.ipfs.tech
- Kill IPFS Daemon
- requires adding multiple directories first
- tests offline and online modes
Test HTTP Gateway Cache Control Support
- Init IPFS
- Launch IPFS Daemon without network
- Add the test directory
- Prepare IPNS unixfs content path for testing
- GET for /ipfs/ unixfs dir listing succeeds
- GET for /ipfs/ unixfs dir with index.html succeeds
- GET for /ipfs/ unixfs file succeeds
- GET for /ipfs/ unixfs dir as DAG-JSON succeeds
- GET for /ipns/ unixfs dir listing succeeds
- GET for /ipns/ unixfs dir with index.html succeeds
- GET for /ipns/ unixfs file succeeds
- GET for /ipns/ unixfs dir as DAG-JSON succeeds
- GET /ipfs/ unixfs file has expected Cache-Control
- GET /ipfs/ unixfs dir listing has no Cache-Control
- GET /ipfs/ unixfs dir with index.html has expected Cache-Control
- GET /ipfs/ dag-json has expected Cache-Control
- GET /ipfs/ unixfs dir as json has expected Cache-Control
- GET /ipns/ unixfs file has no Cache-Control
- GET /ipns/ unixfs dir listing has no Cache-Control
- GET /ipns/ unixfs dir with index.html has no Cache-Control
- GET /ipns/ unixfs dir as dag-json has no Cache-Control
- GET /ipns/ unixfs dir as json has no Cache-Control
- HEAD for /ipfs/ with only-if-cached succeeds when in local datastore
- HEAD for /ipfs/ with only-if-cached fails when not in local datastore
- GET for /ipfs/ with only-if-cached succeeds when in local datastore
- GET for /ipfs/ with only-if-cached fails when not in local datastore
- GET /ipfs/ dir listing response has original content path in X-Ipfs-Path
- GET /ipns/ dir listing response has original content path in X-Ipfs-Path
- GET /ipfs/ dir index.html response has original content path in X-Ipfs-Path
- GET /ipns/ dir index.html response has original content path in X-Ipfs-Path
- GET /ipfs/ file response has original content path in X-Ipfs-Path
- GET /ipns/ file response has original content path in X-Ipfs-Path
- GET /ipfs/ dir listing response has logical CID roots in X-Ipfs-Roots
- GET /ipns/ dir listing response has logical CID roots in X-Ipfs-Roots
- GET /ipfs/ dir index.html response has logical CID roots in X-Ipfs-Roots
- GET /ipns/ dir index.html response has logical CID roots in X-Ipfs-Roots
- GET /ipfs/ file response has logical CID roots in X-Ipfs-Roots
- GET /ipns/ file response has logical CID roots in X-Ipfs-Roots
- GET /ipfs/ dir response has special Etag for generated dir listing
- GET /ipns/ dir response has special Etag for generated dir listing
- GET /ipfs/ dir index.html response has dir CID as Etag
- GET /ipns/ dir index.html response has dir CID as Etag
- GET /ipfs/ response has CID as Etag for a file
- GET /ipns/ response has CID as Etag for a file
- GET for /ipfs/ file with matching Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ dir with index.html file with matching Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ file with matching third Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ file with matching weak Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ file with wildcard Etag in If-None-Match returns 304 Not Modified
- GET for /ipns/ file with matching Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ dir listing with matching strong Etag in If-None-Match returns 304 Not Modified
- GET for /ipfs/ dir listing with matching weak Etag in If-None-Match returns 304 Not Modified
- Kill IPFS Daemon
- requires adding a directory first
Test HTTP Gateway Raw Block (application/vnd.ipld.raw) Support
- Init IPFS
- Launch IPFS Daemon without network
- Create text fixtures
- GET with format=raw param returns a raw block
- GET for application/vnd.ipld.raw returns a raw block
- GET response for application/vnd.ipld.raw has expected Content-Type
- GET response for application/vnd.ipld.raw includes Content-Length
- GET response for application/vnd.ipld.raw includes Content-Disposition
- GET response for application/vnd.ipld.raw includes nosniff hint
- GET for application/vnd.ipld.raw with query filename includes Content-Disposition with custom filename
- GET response for application/vnd.ipld.raw includes Etag
- GET response for application/vnd.ipld.raw includes X-Ipfs-Path and X-Ipfs-Roots
- GET response for application/vnd.ipld.raw includes Cache-Control
- Kill IPFS Daemon
- requires adding a directory first
Test HTTP Gateway CAR (application/vnd.ipld.car) Support
- Init IPFS
- Launch IPFS Daemon without network
- Create a deterministic CAR for testing
- GET for application/vnd.ipld.car with dag-cbor root returns a CARv1 stream with full DAG
- GET with format=car param returns a CARv1 stream
- GET for application/vnd.ipld.car returns a CARv1 stream
- GET for application/vnd.ipld.raw version=1 returns a CARv1 stream
- GET for application/vnd.ipld.raw version=1 returns a CARv1 stream (with whitespace)
- GET for application/vnd.ipld.raw version=2 returns HTTP 400 Bad Request error
- GET for application/vnd.ipld.car with unixfs dir returns a CARv1 stream with full DAG
- GET response for application/vnd.ipld.car has expected Content-Type
- GET response for application/vnd.ipld.car includes no Content-Length
- GET response for application/vnd.ipld.car includes Content-Disposition
- GET response for application/vnd.ipld.car includes nosniff hint
- GET response for application/vnd.ipld.car includes Accept-Ranges header
- GET for application/vnd.ipld.car with query filename includes Content-Disposition with custom filename
- GET response for application/vnd.ipld.car includes a weak Etag
- GET response for application/vnd.ipld.car includes X-Ipfs-Path and X-Ipfs-Roots
- GET response for application/vnd.ipld.car includes same Cache-Control as a block or a file
- Kill IPFS Daemon
- requires car import
- uses car import/stat to verify gateway response
Test HTTP Gateway TAR (application/x-tar) Support
- Init IPFS
- Launch IPFS Daemon without network
- Add the test directory
- GET TAR with format=tar and extract
- GET TAR with 'Accept: application/x-tar' and extract
- GET TAR with format=tar has expected Content-Type
- GET TAR with 'Accept: application/x-tar' has expected Content-Type
- GET TAR has expected root file
- GET TAR has expected root directory
- GET TAR with explicit ?filename= succeeds with modified Content-Disposition header
- Add CARs with relative paths to test with
- GET TAR with relative paths outside root fails
- GET TAR with relative paths inside root works
- Kill IPFS Daemon
- requires adding a directory first
- requires car import
Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and DAG-CBOR (application/vnd.ipld.dag-cbor) Support
- Init IPFS
- Launch IPFS Daemon without network
- Add the test directory
- GET UnixFS file with JSON bytes is returned with application/json Content-Type
- test_dag_pb_conversion "DAG-JSON" "json" "inline"
- test_dag_pb_conversion "DAG-CBOR" "cbor" "attachment"
- test_plain_codec "plain JSON codec" "json" "inline"
- test_plain_codec "plain CBOR codec" "cbor" "attachment"
- Add CARs for path traversal and DAG-PB representation tests
- GET DAG-JSON traversal returns 501 if there is path remainder
- GET DAG-JSON traverses multiple links
- GET DAG-CBOR traversal returns 501 if there is path remainder
- GET DAG-CBOR traverses multiple links
- test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID"
- test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID"
- Kill IPFS Daemon
- requires adding a directory first
- compares
ipfs
commands output with gateway responses, likeipfs dag get
- requires car import
Test HTTP Gateway IPNS Record (application/vnd.ipfs.ipns-record) Support
- Init IPFS
- Launch IPFS Daemon
- Create and Publish IPNS Key
- GET KEY with format=ipns-record and validate key
- GET KEY with 'Accept: application/vnd.ipfs.ipns-record' and validate key
- GET KEY with format=ipns-record has expected HTTP headers
- GET KEY with 'Accept: application/vnd.ipfs.ipns-record' has expected HTTP headers
- GET KEY with expliciy ?filename= succeeds with modified Content-Disposition header
- Kill IPFS Daemon
- requires publishing IPNS key first
- uses
ipfs name inspect --verify
to validate gateway response