From 4d7cec5368666565eb1010696b4e63e14b97b577 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 29 May 2023 15:12:45 +0200 Subject: [PATCH 1/8] t0115: add dir listing path gw --- fixtures/t0115/README.md | 32 ++++++++ fixtures/t0115/fixtures.car | Bin 0 -> 1053 bytes tests/t0115_gateway_dir_listing_test.go | 99 ++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 fixtures/t0115/README.md create mode 100644 fixtures/t0115/fixtures.car create mode 100644 tests/t0115_gateway_dir_listing_test.go diff --git a/fixtures/t0115/README.md b/fixtures/t0115/README.md new file mode 100644 index 000000000..937438bcd --- /dev/null +++ b/fixtures/t0115/README.md @@ -0,0 +1,32 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +# using ipfs version 0.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} +echo FILE_CID=${FILE_CID} +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/t0115/fixtures.car b/fixtures/t0115/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..71a5603822741f25320438bd70823589120e313c GIT binary patch literal 1053 zcmcColvR$Z!{1TqeSN@tUjjg{Tlgc7mrAdS5w!gPn*17KH6I(#F3Vnld4xzQ6ixRGTe(8O`Zyg zxeAF2KuroD-3pm`3d#9-X{E)PdFcxJz;IJY$t>amyOUtJLEZWM>i;({85gv-W(d_V zKa@*2eN@-d)vWbj%$Z-NzS6vINbXbzxziiuPC}aSyAu>)2!|4kFsMU?&s>>u#q@K) zg=4JD+Ddu%u4<)wm#M_8IM$cG*3(nQFic@T$&fnuIuO3{I&*k2EHJEuD( zXEu8GPP(?~NTtQ!*2R(r|4!eUF1UKJ@frzWikc}A4+_gfkg)`nn?n*5x8rrT>037M zkdg1bF*9{rSzCT(#hs2>E#m S1&JjY3gwwVqO>H list_response && + // test_should_contain "Index of" list_response && + // test_should_not_contain ".." list_response, + // + // ' + { + Name: "path gw: backlink on root CID should be hidden", + Request: Request(). + Path("ipfs/{{cid}}", root.Cid()), + Response: Expect(). + Body( + And( + Contains("Index of"), + Not(Contains(`..`, root.Cid())), + )), + }, + // test_expect_success "path gw: redirect dir listing to URL with trailing slash" ' + // curl -sD - http://127.0.0.1:$GWAY_PORT/ipfs/${DIR_CID}/ą/ę > list_response && + // test_should_contain "HTTP/1.1 301 Moved Permanently" list_response && + // test_should_contain "Location: /ipfs/${DIR_CID}/%c4%85/%c4%99/" list_response + // ' + { + Name: "path gw: redirect dir listing to URL with trailing slash WHAT", + Request: Request(). + DoNotFollowRedirects(). + Path("ipfs/{{cid}}/ą/ę", root.Cid()), + Response: Expect(). + Status(301). + Headers( + Header("Location", `/ipfs/{{cid}}/%c4%85/%c4%99/`, root.Cid()), + ), + }, + // test_expect_success "path gw: Etag should be present" ' + // curl -sD - http://127.0.0.1:$GWAY_PORT/ipfs/${DIR_CID}/ą/ę/ > list_response && + // test_should_contain "Index of" list_response && + // test_should_contain "Etag: \"DirIndex-" list_response + // ' + // test_expect_success "path gw: breadcrumbs should point at /ipfs namespace mounted at Origin root" ' + // test_should_contain "/ipfs/$DIR_CID/ą/ę" list_response + // ' + // test_expect_success "path gw: backlink on subdirectory should point at parent directory" ' + // test_should_contain ".." list_response + // ' + // test_expect_success "path gw: name column should be a link to its content path" ' + // test_should_contain "file-źł.txt" list_response + // ' + // test_expect_success "path gw: hash column should be a CID link with filename param" ' + // test_should_contain "" list_response + // ' + { + Name: "path gw: dir listing", + Request: Request(). + DoNotFollowRedirects(). + Path("ipfs/{{cid}}/ą/ę/", root.Cid()), + Response: Expect(). + Headers( + Header("Etag").Contains(`"DirIndex-`), + ). + BodyWithHint(` + - Breadcrumbs should point at /ipfs namespace mounted at Origin root + - backlink on subdirectory should point at parent directory + - name column should be a link to its content path + - hash column should be a CID link with filename param + `, + And(Contains(`/ipfs/{{cid}}/ą/ę`, + root.Cid()), + Contains(`..`, root.Cid()), + Contains(`file-źł.txt`, root.Cid()), + Contains(``, file.Cid())), + ), + }, + } + + RunIfSpecsAreEnabled( + t, + tests, + ) +} From ced9c694b2a32a29fc3ade5ab5c738cd6d53d1a3 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 29 May 2023 16:31:49 +0200 Subject: [PATCH 2/8] t0115: complete test --- fixtures/t0115/dnslink.yml | 5 + tests/t0115_gateway_dir_listing_test.go | 269 +++++++++++++++++++++++- 2 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 fixtures/t0115/dnslink.yml diff --git a/fixtures/t0115/dnslink.yml b/fixtures/t0115/dnslink.yml new file mode 100644 index 000000000..8e282274e --- /dev/null +++ b/fixtures/t0115/dnslink.yml @@ -0,0 +1,5 @@ +# yaml-language-server: $schema=../fixture.schema.json +dnslinks: + website: + subdomain: website + path: /ipfs/bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ \ No newline at end of file diff --git a/tests/t0115_gateway_dir_listing_test.go b/tests/t0115_gateway_dir_listing_test.go index 42dd1801c..4dee3c123 100644 --- a/tests/t0115_gateway_dir_listing_test.go +++ b/tests/t0115_gateway_dir_listing_test.go @@ -1,11 +1,16 @@ package tests import ( + "net/url" "testing" "github.com/ipfs/gateway-conformance/tooling/car" . "github.com/ipfs/gateway-conformance/tooling/check" + "github.com/ipfs/gateway-conformance/tooling/dnslink" + "github.com/ipfs/gateway-conformance/tooling/helpers" + "github.com/ipfs/gateway-conformance/tooling/specs" . "github.com/ipfs/gateway-conformance/tooling/test" + "github.com/ipfs/gateway-conformance/tooling/tmpl" ) func TestDirectorListingOnGateway(t *testing.T) { @@ -83,8 +88,9 @@ func TestDirectorListingOnGateway(t *testing.T) { - name column should be a link to its content path - hash column should be a CID link with filename param `, - And(Contains(`/ipfs/{{cid}}/ą/ę`, - root.Cid()), + And( + Contains(`/ipfs/{{cid}}/ą/ę`, + root.Cid()), Contains(`..`, root.Cid()), Contains(`file-źł.txt`, root.Cid()), Contains(``, file.Cid())), @@ -97,3 +103,262 @@ func TestDirectorListingOnGateway(t *testing.T) { tests, ) } + +func TestDirListingOnSubdomainGateway(t *testing.T) { + fixture := car.MustOpenUnixfsCar("t0115/fixtures.car") + root := fixture.MustGetNode() + file := fixture.MustGetNode("ą", "ę", "file-źł.txt") + + // We're going to run the same test against multiple gateways (localhost, and a subdomain gateway) + gatewayURLs := []string{ + SubdomainGatewayURL, + SubdomainLocalhostGatewayURL, + } + + tests := SugarTests{} + + for _, gatewayURL := range gatewayURLs { + u, err := url.Parse(gatewayURL) + if err != nil { + t.Fatal(err) + } + + // ## ============================================================================ + // ## Test dir listing on subdomain gateway (eg. .ipfs.localhost:8080) + // ## ============================================================================ + tests = append(tests, SugarTests{ + // DIR_HOSTNAME="${DIR_CID}.ipfs.localhost" + // # note: we skip DNS lookup by running curl with --resolve $DIR_HOSTNAME:127.0.0.1 + + // test_expect_success "subdomain gw: backlink on root CID should be hidden" ' + // curl -sD - --resolve $DIR_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DIR_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", + Request: Request(). + DoNotFollowRedirects(). + URL( + "{{scheme}}://{{cid}}.ipfs.{{host}}/", + u.Scheme, + root.Cid(), + u.Host, + ), + Response: Expect(). + BodyWithHint("backlink on root CID should be hidden", + And( + Contains("Index of"), + Not(Contains(`..`)), + )), + }, + // test_expect_success "subdomain gw: redirect dir listing to URL with trailing slash" ' + // curl -sD - --resolve $DIR_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DIR_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().DoNotFollowRedirects().URL( + "{{scheme}}://{{cid}}.ipfs.{{host}}/ą/ę", + u.Scheme, + root.Cid(), + u.Host, + ), + Response: Expect(). + Status(301). + Headers( + Header("Location").Equals(`/%c4%85/%c4%99/`), + ), + }, + // test_expect_success "subdomain gw: Etag should be present" ' + // curl -sD - --resolve $DIR_HOSTNAME:$GWAY_PORT:127.0.0.1 http://$DIR_HOSTNAME:$GWAY_PORT/ą/ę/ > list_response && + // test_should_contain "Index of" list_response && + // test_should_contain "Etag: \"DirIndex-" list_response + // ' + // test_expect_success "subdomain gw: backlink on subdirectory should point at parent directory" ' + // test_should_contain ".." list_response + // ' + // test_expect_success "subdomain gw: breadcrumbs should leverage path-based router mounted on the parent domain" ' + // test_should_contain "/ipfs/$DIR_CID/ą/ę" list_response + // ' + // test_expect_success "subdomain gw: name column should be a link to content root mounted at subdomain origin" ' + // test_should_contain "file-źł.txt" list_response + // ' + // test_expect_success "subdomain gw: hash column should be a CID link to path router with filename param" ' + // test_should_contain "" list_response + // ' + { + Name: "Regular dir listing", + Request: Request().DoNotFollowRedirects().URL( + "{{scheme}}://{{cid}}.ipfs.{{host}}/ą/ę/", + u.Scheme, + root.Cid(), + u.Host, + ), + Response: Expect(). + Headers( + Header("Etag").Contains(`"DirIndex-`), + ).BodyWithHint(` + - backlink on subdirectory should point at parent directory + - breadcrumbs should leverage path-based router mounted on the parent domain + - name column should be a link to content root mounted at subdomain origin + `, + And( + Contains("Index of"), + Contains( + `..`, + ), + Contains( + `/ipfs/{{cid}}/ą/ę`, + u.Host, // TODO: That looks wrong, we link without considering the subdomain + root.Cid(), + ), + Contains( + `file-źł.txt`, + ), + Contains( + ``, + u.Host, // TODO: That looks wrong, we link without considering the subdomain? + file.Cid(), + ), + )), + }, + }...) + } + + // Body expect to find substring '', + + RunIfSpecsAreEnabled( + t, + helpers.UnwrapSubdomainTests( + t, + tests, + ), + specs.SubdomainGateway, + ) +} + +func TestDirListingOnDNSLinkGateway(t *testing.T) { + fixture := car.MustOpenUnixfsCar("t0115/fixtures.car") + file := fixture.MustGetNode("ą", "ę", "file-źł.txt") + + dnsLinks := dnslink.MustOpenDNSLink("t0115/dnslink.yml") + dnsLink := dnsLinks.MustGet("website") + + gatewayURL := SubdomainGatewayURL + + tests := SugarTests{} + + u, err := url.Parse(gatewayURL) + if err != nil { + t.Fatal(err) + } + + 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", + Request: Request(). + DoNotFollowRedirects(). + URL(`{{scheme}}://{{hostname}}/`, u.Scheme, dnsLinkHostname), + Response: Expect(). + Body( + And( + Contains("Index of"), + Not(Contains(`..`)), + ), + ), + }, + // 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(). + DoNotFollowRedirects(). + URL(`{{scheme}}://{{hostname}}/ą/ę`, u.Scheme, dnsLinkHostname), + Response: Expect(). + Status(301). + Headers( + 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", + Request: Request(). + URL(`{{scheme}}://{{hostname}}/ą/ę/`, u.Scheme, dnsLinkHostname), + Response: Expect(). + Headers( + Header("Etag").Contains(`"DirIndex-`), + ). + BodyWithHint(` + - backlink on subdirectory should point at parent directory + - breadcrumbs should point at content root mounted at dnslink origin + - 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 + `, + And( + Contains("Index of"), + Contains(`..`), + Contains(`/ipns/{{hostname}}/ą/ę`, dnsLinkHostname), + Contains(`file-źł.txt`), + Contains(``, file.Cid()), + ), + ), + }, + }...) + + RunIfSpecsAreEnabled( + t, + helpers.UnwrapSubdomainTests( + t, + tests, + ), + specs.SubdomainGateway, + specs.DNSLinkResolver, + ) +} From 3838e8a7261fca90d2847121922bbc72d63693a9 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 30 May 2023 11:45:23 +0200 Subject: [PATCH 3/8] Update fixtures/t0115/dnslink.yml Co-authored-by: Piotr Galar --- fixtures/t0115/dnslink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixtures/t0115/dnslink.yml b/fixtures/t0115/dnslink.yml index 8e282274e..7e8be2607 100644 --- a/fixtures/t0115/dnslink.yml +++ b/fixtures/t0115/dnslink.yml @@ -2,4 +2,4 @@ dnslinks: website: subdomain: website - path: /ipfs/bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ \ No newline at end of file + path: /ipfs/bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ From 47a9b552a4cfe145895d3faed0a670af9d689b20 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 2 Jun 2023 10:31:24 +0200 Subject: [PATCH 4/8] fix tests --- tests/t0115_gateway_dir_listing_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/t0115_gateway_dir_listing_test.go b/tests/t0115_gateway_dir_listing_test.go index 4dee3c123..9b6838cef 100644 --- a/tests/t0115_gateway_dir_listing_test.go +++ b/tests/t0115_gateway_dir_listing_test.go @@ -83,12 +83,14 @@ func TestDirectorListingOnGateway(t *testing.T) { Header("Etag").Contains(`"DirIndex-`), ). BodyWithHint(` + - should contain "Index of" - Breadcrumbs should point at /ipfs namespace mounted at Origin root - backlink on subdirectory should point at parent directory - name column should be a link to its content path - hash column should be a CID link with filename param `, And( + Contains("Index of"), Contains(`/ipfs/{{cid}}/ą/ę`, root.Cid()), Contains(`..`, root.Cid()), From cc3685a88f58509a0a7306572be620eb72700f6e Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 6 Jun 2023 14:23:43 +0200 Subject: [PATCH 5/8] doc: clarify todos --- tests/t0115_gateway_dir_listing_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/t0115_gateway_dir_listing_test.go b/tests/t0115_gateway_dir_listing_test.go index 9b6838cef..4e20f36ba 100644 --- a/tests/t0115_gateway_dir_listing_test.go +++ b/tests/t0115_gateway_dir_listing_test.go @@ -213,7 +213,7 @@ func TestDirListingOnSubdomainGateway(t *testing.T) { ), Contains( `/ipfs/{{cid}}/ą/ę`, - u.Host, // TODO: That looks wrong, we link without considering the subdomain + u.Host, // We don't have a subdomain here which prevents issues with normalization and cidv0 root.Cid(), ), Contains( @@ -221,7 +221,7 @@ func TestDirListingOnSubdomainGateway(t *testing.T) { ), Contains( ``, - u.Host, // TODO: That looks wrong, we link without considering the subdomain? + u.Host, // We don't have a subdomain here which prevents issues with normalization and cidv0 file.Cid(), ), )), From 8254054b51e63a1017021449c11cd6ed1574337c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 7 Jun 2023 09:38:42 +0200 Subject: [PATCH 6/8] fix: redirects --- tests/t0115_gateway_dir_listing_test.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/t0115_gateway_dir_listing_test.go b/tests/t0115_gateway_dir_listing_test.go index 4e20f36ba..dfb4ca335 100644 --- a/tests/t0115_gateway_dir_listing_test.go +++ b/tests/t0115_gateway_dir_listing_test.go @@ -48,7 +48,6 @@ func TestDirectorListingOnGateway(t *testing.T) { { Name: "path gw: redirect dir listing to URL with trailing slash WHAT", Request: Request(). - DoNotFollowRedirects(). Path("ipfs/{{cid}}/ą/ę", root.Cid()), Response: Expect(). Status(301). @@ -76,7 +75,6 @@ func TestDirectorListingOnGateway(t *testing.T) { { Name: "path gw: dir listing", Request: Request(). - DoNotFollowRedirects(). Path("ipfs/{{cid}}/ą/ę/", root.Cid()), Response: Expect(). Headers( @@ -140,7 +138,6 @@ func TestDirListingOnSubdomainGateway(t *testing.T) { { Name: "backlink on root CID should be hidden", Request: Request(). - DoNotFollowRedirects(). URL( "{{scheme}}://{{cid}}.ipfs.{{host}}/", u.Scheme, @@ -161,12 +158,13 @@ func TestDirListingOnSubdomainGateway(t *testing.T) { // ' { Name: "redirect dir listing to URL with trailing slash", - Request: Request().DoNotFollowRedirects().URL( - "{{scheme}}://{{cid}}.ipfs.{{host}}/ą/ę", - u.Scheme, - root.Cid(), - u.Host, - ), + Request: Request(). + URL( + "{{scheme}}://{{cid}}.ipfs.{{host}}/ą/ę", + u.Scheme, + root.Cid(), + u.Host, + ), Response: Expect(). Status(301). Headers( @@ -192,7 +190,7 @@ func TestDirListingOnSubdomainGateway(t *testing.T) { // ' { Name: "Regular dir listing", - Request: Request().DoNotFollowRedirects().URL( + Request: Request().URL( "{{scheme}}://{{cid}}.ipfs.{{host}}/ą/ę/", u.Scheme, root.Cid(), @@ -282,7 +280,6 @@ func TestDirListingOnDNSLinkGateway(t *testing.T) { { Name: "Backlink on root CID should be hidden", Request: Request(). - DoNotFollowRedirects(). URL(`{{scheme}}://{{hostname}}/`, u.Scheme, dnsLinkHostname), Response: Expect(). Body( @@ -300,7 +297,6 @@ func TestDirListingOnDNSLinkGateway(t *testing.T) { { Name: "Redirect dir listing to URL with trailing slash", Request: Request(). - DoNotFollowRedirects(). URL(`{{scheme}}://{{hostname}}/ą/ę`, u.Scheme, dnsLinkHostname), Response: Expect(). Status(301). From 03c036169a00dd5c947dfbd9724e6fc402d393cd Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 7 Jun 2023 10:22:56 +0200 Subject: [PATCH 7/8] fix: missing nil check --- tooling/test/report.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tooling/test/report.go b/tooling/test/report.go index 3371042e2..dc78cd21a 100644 --- a/tooling/test/report.go +++ b/tooling/test/report.go @@ -57,6 +57,10 @@ func report(t *testing.T, test SugarTest, req *http.Request, res *http.Response, var err error switch v := v.(type) { case *http.Request: + if v == nil { + return "nil" + } + b, err = httputil.DumpRequestOut(v, true) case *http.Response: if v == nil { From 197935cdde0ef76f8a5ec078336788c4d118abf5 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 7 Jun 2023 10:31:40 +0200 Subject: [PATCH 8/8] fixes --- tests/t0115_gateway_dir_listing_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/t0115_gateway_dir_listing_test.go b/tests/t0115_gateway_dir_listing_test.go index dfb4ca335..76825878d 100644 --- a/tests/t0115_gateway_dir_listing_test.go +++ b/tests/t0115_gateway_dir_listing_test.go @@ -32,7 +32,7 @@ func TestDirectorListingOnGateway(t *testing.T) { { Name: "path gw: backlink on root CID should be hidden", Request: Request(). - Path("ipfs/{{cid}}", root.Cid()), + Path("/ipfs/{{cid}}/", root.Cid()), Response: Expect(). Body( And( @@ -48,7 +48,7 @@ func TestDirectorListingOnGateway(t *testing.T) { { Name: "path gw: redirect dir listing to URL with trailing slash WHAT", Request: Request(). - Path("ipfs/{{cid}}/ą/ę", root.Cid()), + Path("/ipfs/{{cid}}/ą/ę", root.Cid()), Response: Expect(). Status(301). Headers( @@ -75,7 +75,7 @@ func TestDirectorListingOnGateway(t *testing.T) { { Name: "path gw: dir listing", Request: Request(). - Path("ipfs/{{cid}}/ą/ę/", root.Cid()), + Path("/ipfs/{{cid}}/ą/ę/", root.Cid()), Response: Expect(). Headers( Header("Etag").Contains(`"DirIndex-`),