@@ -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 ) {
0 commit comments