From c64091c1276f018a8bf8071224be1b373448ccdf Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Wed, 27 Dec 2023 16:56:24 +0100 Subject: [PATCH 1/3] fix: correct status code when move is denied --- changelog/unreleased/fix-statuscode-move-denied.md | 5 +++++ .../services/sharesstorageprovider/sharesstorageprovider.go | 2 +- internal/http/services/owncloud/ocdav/move.go | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-statuscode-move-denied.md diff --git a/changelog/unreleased/fix-statuscode-move-denied.md b/changelog/unreleased/fix-statuscode-move-denied.md new file mode 100644 index 0000000000..3f7773e48a --- /dev/null +++ b/changelog/unreleased/fix-statuscode-move-denied.md @@ -0,0 +1,5 @@ +Bugfix: Fixed wrong status code when moving a file to a denied path + +We fixed a bug when the status code was 403 instead of 502 when moving a file to a denied path to be compatible with oc10. + +https://github.com/cs3org/reva/pull/4439 diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 40b48be42d..1a6b95bf6c 100644 --- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -666,7 +666,7 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide if dstReceivedShare.Share.Id.OpaqueId != srcReceivedShare.Share.Id.OpaqueId { return &provider.MoveResponse{ - Status: status.NewUnimplemented(ctx, nil, "sharesstorageprovider: can not move between shares"), + Status: status.NewPermissionDenied(ctx, nil, "sharesstorageprovider: can not move between shares"), }, nil } diff --git a/internal/http/services/owncloud/ocdav/move.go b/internal/http/services/owncloud/ocdav/move.go index bf45df209b..02f0e32b1f 100644 --- a/internal/http/services/owncloud/ocdav/move.go +++ b/internal/http/services/owncloud/ocdav/move.go @@ -281,6 +281,10 @@ func (s *svc) handleMove(ctx context.Context, w http.ResponseWriter, r *http.Req switch mRes.Status.Code { case rpc.Code_CODE_ABORTED: status = http.StatusPreconditionFailed + case rpc.Code_CODE_PERMISSION_DENIED: + status = http.StatusForbidden + // create oc10 compatible error message + m = "Destination directory is not writable" case rpc.Code_CODE_UNIMPLEMENTED: // We translate this into a Bad Gateway error as per https://www.rfc-editor.org/rfc/rfc4918#section-9.9.4 // > 502 (Bad Gateway) - This may occur when the destination is on another From 396839a57f1d3b2b8fe6e44502ee67af018b8106 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Wed, 27 Dec 2023 17:27:03 +0100 Subject: [PATCH 2/3] test: fix unit tests --- .../sharesstorageprovider/sharesstorageprovider_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go index eac7ac8035..efc3f95c8f 100644 --- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go +++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go @@ -808,7 +808,7 @@ var _ = Describe("Sharesstorageprovider", func() { gatewayClient.AssertNotCalled(GinkgoT(), "Move", mock.Anything, mock.Anything) Expect(err).ToNot(HaveOccurred()) Expect(res).ToNot(BeNil()) - Expect(res.Status.Code).To(Equal(rpc.Code_CODE_UNIMPLEMENTED)) + Expect(res.Status.Code).To(Equal(rpc.Code_CODE_PERMISSION_DENIED)) }) It("refuses to move a file between shares resolving to the same space", func() { @@ -826,7 +826,7 @@ var _ = Describe("Sharesstorageprovider", func() { gatewayClient.AssertNotCalled(GinkgoT(), "Move", mock.Anything, mock.Anything) Expect(err).ToNot(HaveOccurred()) Expect(res).ToNot(BeNil()) - Expect(res.Status.Code).To(Equal(rpc.Code_CODE_UNIMPLEMENTED)) + Expect(res.Status.Code).To(Equal(rpc.Code_CODE_PERMISSION_DENIED)) }) It("moves a file", func() { From 6cb36cff01183434a9f8b78a0e1f0054a7413078 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 28 Dec 2023 09:11:26 +0100 Subject: [PATCH 3/3] Update changelog/unreleased/fix-statuscode-move-denied.md Co-authored-by: Phil Davis --- changelog/unreleased/fix-statuscode-move-denied.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/fix-statuscode-move-denied.md b/changelog/unreleased/fix-statuscode-move-denied.md index 3f7773e48a..dee8134ed9 100644 --- a/changelog/unreleased/fix-statuscode-move-denied.md +++ b/changelog/unreleased/fix-statuscode-move-denied.md @@ -1,5 +1,5 @@ Bugfix: Fixed wrong status code when moving a file to a denied path -We fixed a bug when the status code was 403 instead of 502 when moving a file to a denied path to be compatible with oc10. +We fixed a bug when the status code 502 was returned when moving a file to a denied path. Status code 403 (forbidden) is now returned to be compatible with oc10. https://github.com/cs3org/reva/pull/4439