From 3d8feacec135bd6b43f1dac1dcb5241bdc268ba7 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 28 Oct 2023 04:04:43 +0200 Subject: [PATCH] fix(gw): blocked content produces http error 410 requires https://github.com/ipfs/boxo/pull/497 which is based on top of the boxo already used in kubo master to avoid issues caused by ilater commits in boxo main --- docs/examples/kubo-as-a-library/go.mod | 2 +- docs/examples/kubo-as-a-library/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- test/cli/content_blocking_test.go | 16 ++++++++-------- test/dependencies/go.mod | 2 +- test/dependencies/go.sum | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 674f5b4f0dc..dfb7848b036 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -7,7 +7,7 @@ go 1.20 replace github.com/ipfs/kubo => ./../../.. require ( - github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 + github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b github.com/ipfs/kubo v0.0.0-00010101000000-000000000000 github.com/libp2p/go-libp2p v0.31.0 github.com/multiformats/go-multiaddr v0.11.0 diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index c582628193a..49dbacfee11 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -305,8 +305,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b h1:0Qi1EhB82x3SZJOBieG51BtPvjU3kSy4H8OpMnxKvtk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b/go.mod h1:pu8HsZvuyYeYJsqtLDCoYSvy8rHj6vI3dlh8P0f83Zs= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= diff --git a/go.mod b/go.mod index d2584cec03e..c94a251cba4 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/ipfs-shipyard/nopfs v0.0.12-0.20231027223058-cde3b5ba964c github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c - github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 + github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 diff --git a/go.sum b/go.sum index 245c74e457b..928433eaaa2 100644 --- a/go.sum +++ b/go.sum @@ -339,8 +339,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b h1:0Qi1EhB82x3SZJOBieG51BtPvjU3kSy4H8OpMnxKvtk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b/go.mod h1:pu8HsZvuyYeYJsqtLDCoYSvy8rHj6vI3dlh8P0f83Zs= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= diff --git a/test/cli/content_blocking_test.go b/test/cli/content_blocking_test.go index 575c7530540..98e65397f15 100644 --- a/test/cli/content_blocking_test.go +++ b/test/cli/content_blocking_test.go @@ -25,7 +25,7 @@ func TestContentBlocking(t *testing.T) { // and running in parallel could impact other tests const blockedMsg = "blocked and cannot be provided" - const statusExpl = "HTTP error code is expected" + const statusExpl = "specific HTTP error code is expected" const bodyExpl = "Error message informing about content block is expected" h := harness.NewT(t) @@ -88,7 +88,7 @@ func TestContentBlocking(t *testing.T) { t.Run("Gateway Denies directly blocked CID", func(t *testing.T) { t.Parallel() resp := client.Get("/ipfs/" + blockedCID) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) assert.NotEqual(t, "directly blocked file content", resp.Body) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -175,7 +175,7 @@ func TestContentBlocking(t *testing.T) { t.Run(gwTestName, func(t *testing.T) { resp := client.Get(testCase.path) // TODO we should require HTTP 410, not 5XX: assert.Equal(t, http.StatusGone, resp.StatusCode) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -191,7 +191,7 @@ func TestContentBlocking(t *testing.T) { r.Host = "localhost:" + gwURL.Port() }) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) // TODO assert.Equal(t, http.StatusGone, resp.StatusCode) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -204,7 +204,7 @@ func TestContentBlocking(t *testing.T) { r.Host = "blocked-dnslink.example.com.ipns.localhost:" + gwURL.Port() }) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) // TODO assert.Equal(t, http.StatusGone, resp.StatusCode) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -219,7 +219,7 @@ func TestContentBlocking(t *testing.T) { r.Host = "blocked--dnslink-example-com.ipns.localhost:" + gwURL.Port() }) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) // TODO assert.Equal(t, http.StatusGone, resp.StatusCode) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -248,7 +248,7 @@ func TestContentBlocking(t *testing.T) { // Then, does the most basic blocking case work? t.Run("Denies directly blocked CID", func(t *testing.T) { resp := client.Get("/ipfs/" + blockedCID) - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) assert.NotEqual(t, "directly blocked file content", resp.Body) assert.Contains(t, resp.Body, blockedMsg, bodyExpl) }) @@ -299,7 +299,7 @@ func TestContentBlocking(t *testing.T) { resp, err := libp2pClient.Get(fmt.Sprintf("/ipfs/%s?format=raw", blockedCID)) require.NoError(t, err) defer resp.Body.Close() - assert.NotEqual(t, http.StatusOK, resp.StatusCode, statusExpl) + assert.Equal(t, http.StatusGone, resp.StatusCode, statusExpl) body, err := io.ReadAll(resp.Body) require.NoError(t, err) assert.NotEqual(t, string(body), "directly blocked file content") diff --git a/test/dependencies/go.mod b/test/dependencies/go.mod index e79c7ff5ebd..cbc577f9b40 100644 --- a/test/dependencies/go.mod +++ b/test/dependencies/go.mod @@ -7,7 +7,7 @@ replace github.com/ipfs/kubo => ../../ require ( github.com/Kubuxu/gocovmerge v0.0.0-20161216165753-7ecaa51963cd github.com/golangci/golangci-lint v1.54.1 - github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 + github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 github.com/ipfs/go-datastore v0.6.0 diff --git a/test/dependencies/go.sum b/test/dependencies/go.sum index cbb547d2bc9..90a00aebcca 100644 --- a/test/dependencies/go.sum +++ b/test/dependencies/go.sum @@ -398,8 +398,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ= -github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b h1:0Qi1EhB82x3SZJOBieG51BtPvjU3kSy4H8OpMnxKvtk= +github.com/ipfs/boxo v0.13.2-0.20231028021353-182e86f5bb9b/go.mod h1:pu8HsZvuyYeYJsqtLDCoYSvy8rHj6vI3dlh8P0f83Zs= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=