[#174] Fix object keys with slashes in chi #174

Merged
alexvanin merged 1 commit from dkirillov/frostfs-s3-gw:bugfix/key_with_slashes into master 2023-07-26 21:08:01 +00:00
3 changed files with 36 additions and 10 deletions
Showing only changes of commit 361d10cc78 - Show all commits

View file

@ -165,7 +165,7 @@ func bucketRouter(h Handler, log *zap.Logger) chi.Router {
bktRouter.Group(func(r chi.Router) { bktRouter.Group(func(r chi.Router) {
r.Method(http.MethodGet, "/", NewHandlerFilter(). r.Method(http.MethodGet, "/", NewHandlerFilter().
Add(NewFilter(). Add(NewFilter().
Queries("upload"). Queries("uploads").
Handler(named("ListMultipartUploads", h.ListMultipartUploadsHandler))). Handler(named("ListMultipartUploads", h.ListMultipartUploadsHandler))).
Add(NewFilter(). Add(NewFilter().
Queries("location"). Queries("location").

View file

@ -222,9 +222,13 @@ func (h *handlerMock) ListObjectsV2MHandler(http.ResponseWriter, *http.Request)
panic("implement me") panic("implement me")
} }
func (h *handlerMock) ListObjectsV2Handler(http.ResponseWriter, *http.Request) { func (h *handlerMock) ListObjectsV2Handler(w http.ResponseWriter, r *http.Request) {
//TODO implement me res := &handlerResult{
panic("implement me") Method: "ListObjectsV2",
ReqInfo: middleware.GetReqInfo(r.Context()),
}
h.writeResponse(w, res)
} }
func (h *handlerMock) ListBucketObjectVersionsHandler(http.ResponseWriter, *http.Request) { func (h *handlerMock) ListBucketObjectVersionsHandler(http.ResponseWriter, *http.Request) {
@ -232,9 +236,13 @@ func (h *handlerMock) ListBucketObjectVersionsHandler(http.ResponseWriter, *http
panic("implement me") panic("implement me")
} }
func (h *handlerMock) ListObjectsV1Handler(http.ResponseWriter, *http.Request) { func (h *handlerMock) ListObjectsV1Handler(w http.ResponseWriter, r *http.Request) {
//TODO implement me res := &handlerResult{
panic("implement me") Method: "ListObjectsV1",
ReqInfo: middleware.GetReqInfo(r.Context()),
}
h.writeResponse(w, res)
} }
func (h *handlerMock) PutBucketLifecycleHandler(http.ResponseWriter, *http.Request) { func (h *handlerMock) PutBucketLifecycleHandler(http.ResponseWriter, *http.Request) {
@ -359,9 +367,13 @@ func (h *handlerMock) ListPartsHandler(http.ResponseWriter, *http.Request) {
panic("implement me") panic("implement me")
} }
func (h *handlerMock) ListMultipartUploadsHandler(http.ResponseWriter, *http.Request) { func (h *handlerMock) ListMultipartUploadsHandler(w http.ResponseWriter, r *http.Request) {
//TODO implement me res := &handlerResult{
panic("implement me") Method: "ListMultipartUploads",
ReqInfo: middleware.GetReqInfo(r.Context()),
}
h.writeResponse(w, res)
} }
func (h *handlerMock) ResolveBucket(context.Context, string) (*data.BucketInfo, error) { func (h *handlerMock) ResolveBucket(context.Context, string) (*data.BucketInfo, error) {

View file

@ -32,6 +32,20 @@ func TestRouterUploadPart(t *testing.T) {
require.Equal(t, "UploadPart", resp.Method) require.Equal(t, "UploadPart", resp.Method)
} }
func TestRouterListMultipartUploads(t *testing.T) {
chiRouter := prepareRouter(t)
w := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/test-bucket", nil)
query := make(url.Values)
query.Set("uploads", "")
r.URL.RawQuery = query.Encode()
chiRouter.ServeHTTP(w, r)
resp := readResponse(t, w)
require.Equal(t, "ListMultipartUploads", resp.Method)
}
func TestRouterObjectWithSlashes(t *testing.T) { func TestRouterObjectWithSlashes(t *testing.T) {
chiRouter := prepareRouter(t) chiRouter := prepareRouter(t)