Skip to content

Commit

Permalink
fix: auth and test
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Feb 23, 2024
1 parent 71bd8ba commit deb3627
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,18 @@ func TestBzzFiles(t *testing.T) {
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"),
jsonhttptest.WithNonEmptyResponseHeader(api.SwarmTagHeader),
)
})

t.Run("head", func(t *testing.T) {
rootHash := "65148cd89b58e91616773f5acea433f7b5a6274f2259e25f4893a332b74a7e28"

jsonhttptest.Request(t, client, http.MethodHead, fileDownloadResource(rootHash), http.StatusOK,
jsonhttptest.WithRequestHeader(api.SwarmPostageBatchIdHeader, batchOkStr),
jsonhttptest.WithRequestBody(bytes.NewReader(simpleData)),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"),
jsonhttptest.WithExpectedContentLength(21),
)
})
})
}

// TestRangeRequests validates that all endpoints are serving content with
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestCors(t *testing.T) {
expectedMethods: "POST",
}, {
endpoint: "bzz/0101011",
expectedMethods: "GET",
expectedMethods: "GET, HEAD",
},
{
endpoint: "chunks",
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ func (e encrypter) decrypt(data []byte) ([]byte, error) {

func applyPolicies(e *casbin.Enforcer) error {
_, err := e.AddPolicies([][]string{
{"consumer", "/bytes/*", "GET"},
{"consumer", "/bytes/*", "(GET)|(HEAD)"},
{"creator", "/bytes", "POST"},
{"consumer", "/chunks/*", "GET"},
{"creator", "/chunks", "POST"},
{"consumer", "/bzz/*", "GET"},
{"creator", "/bzz/*", "PATCH"},
{"creator", "/bzz", "POST"},
{"creator", "/bzz?*", "POST"},
{"consumer", "/bzz/*/*", "GET"},
{"consumer", "/bzz/*/*", "(GET)|(HEAD)"},
{"creator", "/tags", "GET"},
{"creator", "/tags?*", "GET"},
{"creator", "/tags", "POST"},
Expand Down

0 comments on commit deb3627

Please sign in to comment.