Skip to content

Commit

Permalink
return xml body for more error cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Oct 13, 2022
1 parent 1150199 commit 03290c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss p
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound:
st = status.NewNotFound(ctx, "path not found when listing recycle stream")
st = status.NewNotFound(ctx, "resource not found when listing recycle stream")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
default:
Expand Down Expand Up @@ -853,7 +853,7 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound:
st = status.NewNotFound(ctx, "path not found when listing recycle")
st = status.NewNotFound(ctx, "resource not found when listing recycle")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
default:
Expand Down
21 changes: 17 additions & 4 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
rstatus "github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/cs3org/reva/v2/pkg/rhttp/router"
"github.com/cs3org/reva/v2/pkg/utils"
)
Expand Down Expand Up @@ -124,7 +125,10 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
w.WriteHeader(http.StatusInternalServerError)
return
case rpcstatus.Code != rpc.Code_CODE_OK:
errors.HandleErrorStatus(log, w, rpcstatus)
httpStatus := rstatus.HTTPStatusFromCode(rpcstatus.Code)
w.WriteHeader(httpStatus)
b, err := errors.Marshal(httpStatus, rpcstatus.Message, "")
errors.HandleWebdavError(log, w, b, err)
return
}
ref := spacelookup.MakeRelativeReference(space, ".", false)
Expand Down Expand Up @@ -161,7 +165,10 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
return
}
if rpcstatus.Code != rpc.Code_CODE_OK {
errors.HandleErrorStatus(log, w, rpcstatus)
httpStatus := rstatus.HTTPStatusFromCode(rpcstatus.Code)
w.WriteHeader(httpStatus)
b, err := errors.Marshal(httpStatus, rpcstatus.Message, "")
errors.HandleWebdavError(log, w, b, err)
return
}
dstRef := spacelookup.MakeRelativeReference(space, p, false)
Expand Down Expand Up @@ -232,7 +239,10 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
}

if getRecycleRes.Status.Code != rpc.Code_CODE_OK {
errors.HandleErrorStatus(&sublog, w, getRecycleRes.Status)
httpStatus := rstatus.HTTPStatusFromCode(getRecycleRes.Status.Code)
w.WriteHeader(httpStatus)
b, err := errors.Marshal(httpStatus, getRecycleRes.Status.Message, "")
errors.HandleWebdavError(&sublog, w, b, err)
return
}

Expand All @@ -259,7 +269,10 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
}

if getRecycleRes.Status.Code != rpc.Code_CODE_OK {
errors.HandleErrorStatus(&sublog, w, getRecycleRes.Status)
httpStatus := rstatus.HTTPStatusFromCode(getRecycleRes.Status.Code)
w.WriteHeader(httpStatus)
b, err := errors.Marshal(httpStatus, getRecycleRes.Status.Message, "")
errors.HandleWebdavError(&sublog, w, b, err)
return
}
items = append(items, getRecycleRes.RecycleItems...)
Expand Down
1 change: 0 additions & 1 deletion tests/acceptance/expected-failures-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ _ocdav: api compatibility, return correct status code_
- [apiAuthWebDav/webDavPOSTAuth.feature:67](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavPOSTAuth.feature#L67) Scenario: send POST requests to another user's webDav endpoints as normal user using the spaces WebDAV API

#### [Using double slash in URL to access a folder gives 501 and other status codes](https://github.com/owncloud/ocis/issues/1667)
- [apiAuthWebDav/webDavSpecialURLs.feature:24](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L24)
- [apiAuthWebDav/webDavSpecialURLs.feature:121](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L121)
- [apiAuthWebDav/webDavSpecialURLs.feature:132](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L132)
- [apiAuthWebDav/webDavSpecialURLs.feature:163](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L163)
Expand Down
1 change: 0 additions & 1 deletion tests/acceptance/expected-failures-on-S3NG-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ _ocdav: api compatibility, return correct status code_
- [apiAuthWebDav/webDavPOSTAuth.feature:67](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavPOSTAuth.feature#L67) Scenario: send POST requests to another user's webDav endpoints as normal user using the spaces WebDAV API

#### [Using double slash in URL to access a folder gives 501 and other status codes](https://github.com/owncloud/ocis/issues/1667)
- [apiAuthWebDav/webDavSpecialURLs.feature:24](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L24)
- [apiAuthWebDav/webDavSpecialURLs.feature:121](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L121)
- [apiAuthWebDav/webDavSpecialURLs.feature:132](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L132)
- [apiAuthWebDav/webDavSpecialURLs.feature:163](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiAuthWebDav/webDavSpecialURLs.feature#L163)
Expand Down

0 comments on commit 03290c8

Please sign in to comment.