From 4637ab8fa81c1679f8e92e2521ee0e0014345b20 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 17 Mar 2020 19:27:18 +0100 Subject: [PATCH] test(subdomain-gw): content validation before redirect 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. https://github.com/ipfs/go-ipfs/pull/6096#discussion_r392537182 License: MIT Signed-off-by: Marcin Rataj --- test/sharness/t0114-gateway-subdomains.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index ff57140b397f..5eac47e5603c 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -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" \ @@ -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/ test_hostname_gateway_response_should_contain \