Skip to content

Commit 431116c

Browse files
committed
test: enable CAR blocking tests
Updates boxo to include the fix for blocked CIDs appearing in CAR responses and enables the previously commented test cases. Uses boxo PR #1019 which ensures content filtering policies are enforced for CAR format responses by properly separating DAGService usage during traversal. Ref: ipfs/boxo#1019 Closes #10361
1 parent 1905aef commit 431116c

File tree

7 files changed

+30
-11
lines changed

7 files changed

+30
-11
lines changed

docs/examples/kubo-as-a-library/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.25
77
replace github.com/ipfs/kubo => ./../../..
88

99
require (
10-
github.com/ipfs/boxo v0.34.0
10+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269
1111
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
1212
github.com/libp2p/go-libp2p v0.43.0
1313
github.com/multiformats/go-multiaddr v0.16.1

docs/examples/kubo-as-a-library/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.25.0 h1:OqNqsGZPX8zh3eFMO8Lf8EHRRnSGBMqcd
287287
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0/go.mod h1:BxhUdtBgOXg1B+gAPEplkg/GpyTZY+kCMSfsJvvydqU=
288288
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
289289
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
290-
github.com/ipfs/boxo v0.34.0 h1:pMP9bAsTs4xVh8R0ZmxIWviV7kjDa60U24QrlGgHb1g=
291-
github.com/ipfs/boxo v0.34.0/go.mod h1:kzdH/ewDybtO3+M8MCVkpwnIIc/d2VISX95DFrY4vQA=
290+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269 h1:dX/2mGYW0b8XvMzk5yqauaHO/N6pXMCEQyZ5ySCpIac=
291+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269/go.mod h1:rXql6ncaLZZfLqDG3Cuw9ZYQKd3rMU5bk1TGXF0+ZL0=
292292
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
293293
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
294294
github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/hashicorp/go-version v1.7.0
2323
github.com/ipfs-shipyard/nopfs v0.0.14
2424
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0
25-
github.com/ipfs/boxo v0.34.0
25+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269
2626
github.com/ipfs/go-block-format v0.2.2
2727
github.com/ipfs/go-cid v0.5.0
2828
github.com/ipfs/go-cidutil v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.25.0 h1:OqNqsGZPX8zh3eFMO8Lf8EHRRnSGBMqcd
354354
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0/go.mod h1:BxhUdtBgOXg1B+gAPEplkg/GpyTZY+kCMSfsJvvydqU=
355355
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
356356
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
357-
github.com/ipfs/boxo v0.34.0 h1:pMP9bAsTs4xVh8R0ZmxIWviV7kjDa60U24QrlGgHb1g=
358-
github.com/ipfs/boxo v0.34.0/go.mod h1:kzdH/ewDybtO3+M8MCVkpwnIIc/d2VISX95DFrY4vQA=
357+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269 h1:dX/2mGYW0b8XvMzk5yqauaHO/N6pXMCEQyZ5ySCpIac=
358+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269/go.mod h1:rXql6ncaLZZfLqDG3Cuw9ZYQKd3rMU5bk1TGXF0+ZL0=
359359
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
360360
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
361361
github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=

test/cli/content_blocking_test.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,15 @@ func TestContentBlocking(t *testing.T) {
115115
assert.False(t, has)
116116
})
117117

118-
/* TODO: this was already broken in 0.26, but we should fix it
118+
// TODO: this was already broken in 0.26, but we should fix it
119119
t.Run("Gateway returns CAR without directly blocked CID", func(t *testing.T) {
120+
// First verify that the blocked CID is actually blocked when accessed directly
121+
directResp := client.Get("/ipfs/" + blockedCID)
122+
assert.Equal(t, http.StatusGone, directResp.StatusCode, "Direct access to blocked CID should return 410")
123+
120124
allowedDirWithDirectlyBlockedCID := node.IPFS("add", "--raw-leaves", "-Q", "-rw", filepath.Join(h.Dir, "directly-blocked-file.txt")).Stdout.Trimmed()
125+
t.Logf("Directory CID containing blocked file: %s", allowedDirWithDirectlyBlockedCID)
126+
t.Logf("Blocked CID that should not appear in CAR: %s", blockedCID)
121127
resp := client.Get("/ipfs/" + allowedDirWithDirectlyBlockedCID + "?format=car")
122128
assert.Equal(t, http.StatusOK, resp.StatusCode)
123129

@@ -128,7 +134,20 @@ func TestContentBlocking(t *testing.T) {
128134
assert.NoError(t, err)
129135
assert.False(t, has, "Returned CAR should not include blockedCID")
130136
})
131-
*/
137+
138+
// Test that requesting a CAR with a blocked root CID returns 410
139+
t.Run("Gateway returns 410 for CAR request with blocked root CID", func(t *testing.T) {
140+
resp := client.Get("/ipfs/" + blockedCID + "?format=car")
141+
assert.Equal(t, http.StatusGone, resp.StatusCode, "CAR request for blocked root CID should return 410 Gone")
142+
assert.Contains(t, resp.Body, blockedMsg, "Error message should indicate content is blocked")
143+
})
144+
145+
// Test that requesting raw format with a blocked root CID returns 410
146+
t.Run("Gateway returns 410 for raw request with blocked root CID", func(t *testing.T) {
147+
resp := client.Get("/ipfs/" + blockedCID + "?format=raw")
148+
assert.Equal(t, http.StatusGone, resp.StatusCode, "Raw request for blocked root CID should return 410 Gone")
149+
assert.Contains(t, resp.Body, blockedMsg, "Error message should indicate content is blocked")
150+
})
132151

133152
// Confirm CAR responses skip blocked subpaths
134153
t.Run("Gateway returns CAR without blocked subpath", func(t *testing.T) {

test/dependencies/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ require (
134134
github.com/huin/goupnp v1.3.0 // indirect
135135
github.com/inconshreveable/mousetrap v1.1.0 // indirect
136136
github.com/ipfs/bbloom v0.0.4 // indirect
137-
github.com/ipfs/boxo v0.34.0 // indirect
137+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269 // indirect
138138
github.com/ipfs/go-bitfield v1.1.0 // indirect
139139
github.com/ipfs/go-block-format v0.2.2 // indirect
140140
github.com/ipfs/go-cid v0.5.0 // indirect

test/dependencies/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
332332
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
333333
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
334334
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
335-
github.com/ipfs/boxo v0.34.0 h1:pMP9bAsTs4xVh8R0ZmxIWviV7kjDa60U24QrlGgHb1g=
336-
github.com/ipfs/boxo v0.34.0/go.mod h1:kzdH/ewDybtO3+M8MCVkpwnIIc/d2VISX95DFrY4vQA=
335+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269 h1:dX/2mGYW0b8XvMzk5yqauaHO/N6pXMCEQyZ5ySCpIac=
336+
github.com/ipfs/boxo v0.34.1-0.20250830010039-334247a47269/go.mod h1:rXql6ncaLZZfLqDG3Cuw9ZYQKd3rMU5bk1TGXF0+ZL0=
337337
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
338338
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
339339
github.com/ipfs/go-block-format v0.2.2 h1:uecCTgRwDIXyZPgYspaLXoMiMmxQpSx2aq34eNc4YvQ=

0 commit comments

Comments
 (0)