Skip to content

Commit

Permalink
test: denylist on ?format=car
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Mar 1, 2024
1 parent 5cb6d20 commit 4e78933
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/cli/content_blocking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@ func TestContentBlocking(t *testing.T) {
assert.False(t, has)
})

/* TODO: this was already broken in 0.26, but we should fix it
t.Run("Gateway returns CAR without directly blocked CID", func(t *testing.T) {
allowedDirWithDirectlyBlockedCID := node.IPFS("add", "--raw-leaves", "-Q", "-rw", filepath.Join(h.Dir, "directly-blocked-file.txt")).Stdout.Trimmed()
resp := client.Get("/ipfs/" + allowedDirWithDirectlyBlockedCID + "?format=car")
assert.Equal(t, http.StatusOK, resp.StatusCode)
bs, err := carstore.NewReadOnly(strings.NewReader(resp.Body), nil)
assert.NoError(t, err)
has, err := bs.Has(context.Background(), cid.MustParse(blockedCID))
assert.NoError(t, err)
assert.False(t, has)
})
*/

// Confirm CAR responses skip blocked subpaths
t.Run("Gateway returns CAR without blocked subpath", func(t *testing.T) {
resp := client.Get("/ipfs/" + allowedParentDirCID + "/subdir?format=car")
assert.Equal(t, http.StatusOK, resp.StatusCode)

bs, err := carstore.NewReadOnly(strings.NewReader(resp.Body), nil)
assert.NoError(t, err)

has, err := bs.Has(context.Background(), cid.MustParse(blockedSubDirCID))
assert.NoError(t, err)
assert.False(t, has)
})

// Ok, now the full list of test cases we want to cover in both CLI and Gateway
testCases := []struct {
name string
Expand Down

0 comments on commit 4e78933

Please sign in to comment.