Skip to content

Commit

Permalink
test(subdomain-gw): content validation before redirect
Browse files Browse the repository at this point in the history
This adds test for redirect scenario from subdomain root domain to
$cid.ipfs.example.com subdomain when provided content path is invalid.

Some http clients such as web browsers force-lowercase domain names,
and we want to ensure the error happens before redirect and includes
original (case-sensitive) content path.

#6096 (comment)

License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
  • Loading branch information
lidel committed Mar 17, 2020
1 parent f03d973 commit 4637ab8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/sharness/t0114-gateway-subdomains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ test_hostname_gateway_response_should_contain \
"http://127.0.0.1:$GWAY_PORT/ipfs/$CIDv1" \
"Location: http://$CIDv1.ipfs.example.com/"

# error message should include original CID
# (and it should be case-sensitive, as we can't assume everyone uses base32)
test_hostname_gateway_response_should_contain \
"request for example.com/ipfs/{InvalidCID} produces useful error before redirect" \
"example.com" \
"http://127.0.0.1:$GWAY_PORT/ipfs/QmInvalidCID" \
'invalid path \"/ipfs/QmInvalidCID\"'

test_hostname_gateway_response_should_contain \
"request for example.com/ipfs/{CIDv0} produces redirect to {CIDv1}.ipfs.example.com" \
Expand All @@ -313,6 +320,8 @@ test_expect_success "request for http://example.com/ipfs/{CID} with X-Forwarded-
test_should_contain \"Location: https://$CIDv1.ipfs.example.com/\" response
"



# example.com/ipns/<libp2p-key>

test_hostname_gateway_response_should_contain \
Expand Down

0 comments on commit 4637ab8

Please sign in to comment.