Skip to content

Commit

Permalink
fix(gateway): return 404 in no-fetch contexts
Browse files Browse the repository at this point in the history
applies and tests fix from ipfs/boxo#630
  • Loading branch information
lidel committed Jul 30, 2024
1 parent 3c13793 commit e7d3239
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,5 @@ require (
)

go 1.22

replace github.com/ipfs/boxo => github.com/MichaelMure/boxo v0.0.0-20240730133910-2b6f29f9b7f9
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Jorropo/jsync v1.0.1 h1:6HgRolFZnsdfzRUj+ImB9og1JYOxQoReSywkHOGSaUU=
github.com/Jorropo/jsync v1.0.1/go.mod h1:jCOZj3vrBCri3bSU3ErUYvevKlnbssrXeCivybS5ABQ=
github.com/MichaelMure/boxo v0.0.0-20240730133910-2b6f29f9b7f9 h1:eDE65T5kU3oY/uef8JRwKuB6pmINGpnySdcXESg1v3M=
github.com/MichaelMure/boxo v0.0.0-20240730133910-2b6f29f9b7f9/go.mod h1:NmweAYeY1USOaJJxouy7DLr/Y5M8UBSsCI2KRivO+TY=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
Expand Down Expand Up @@ -330,8 +332,6 @@ 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.21.1-0.20240726143638-ece31b41e672 h1:k9E7AgwcoOBOznlPGi9G4cA4cBSI0+dtBQDHObCTOVM=
github.com/ipfs/boxo v0.21.1-0.20240726143638-ece31b41e672/go.mod h1:NmweAYeY1USOaJJxouy7DLr/Y5M8UBSsCI2KRivO+TY=
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=
Expand Down
10 changes: 5 additions & 5 deletions test/cli/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,12 @@ func TestGateway(t *testing.T) {
t.Run("not present", func(t *testing.T) {
cidFoo := node2.IPFSAddStr("foo")

t.Run("not present key from node 1", func(t *testing.T) {
t.Run("not present CID from node 1", func(t *testing.T) {
t.Parallel()
assert.Equal(t, 500, node1.GatewayClient().Get("/ipfs/"+cidFoo).StatusCode)
assert.Equal(t, 404, node1.GatewayClient().Get("/ipfs/"+cidFoo).StatusCode)
})

t.Run("not present IPNS key from node 1", func(t *testing.T) {
t.Run("not present IPNS Record from node 1", func(t *testing.T) {
t.Parallel()
assert.Equal(t, 500, node1.GatewayClient().Get("/ipns/"+node2PeerID).StatusCode)
})
Expand All @@ -428,12 +428,12 @@ func TestGateway(t *testing.T) {
t.Run("present", func(t *testing.T) {
cidBar := node1.IPFSAddStr("bar")

t.Run("present key from node 1", func(t *testing.T) {
t.Run("present CID from node 1", func(t *testing.T) {
t.Parallel()
assert.Equal(t, 200, node1.GatewayClient().Get("/ipfs/"+cidBar).StatusCode)
})

t.Run("present IPNS key from node 1", func(t *testing.T) {
t.Run("present IPNS Record from node 1", func(t *testing.T) {
t.Parallel()
node2.IPFS("name", "publish", "/ipfs/"+cidBar)
assert.Equal(t, 200, node1.GatewayClient().Get("/ipns/"+node2PeerID).StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion test/cli/http_gateway_over_libp2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGatewayOverLibp2p(t *testing.T) {
t.Run("WillNotServeRemoteContent", func(t *testing.T) {
resp, err := http.Get(fmt.Sprintf("http://%s/ipfs/%s?format=raw", p2pProxyNodeHTTPListenAddr, cidDataNotOnGatewayNode))
require.NoError(t, err)
require.Equal(t, 500, resp.StatusCode)
require.Equal(t, http.StatusNotFound, resp.StatusCode)
})

t.Run("WillNotServeDeserializedResponses", func(t *testing.T) {
Expand Down

0 comments on commit e7d3239

Please sign in to comment.