From b060ddc9c1800fb3ab71288faaa14f1b3393b72b Mon Sep 17 00:00:00 2001 From: Andre Duffeck Date: Tue, 5 Jul 2022 17:14:22 +0200 Subject: [PATCH] Fix conflict response code (#3031) * Return 409 Conflict instead of 400 when detecting recursive operations * Add changelog --- changelog/unreleased/fix-response-code.md | 5 +++++ internal/http/services/owncloud/ocdav/copy.go | 2 +- internal/http/services/owncloud/ocdav/move.go | 2 +- tests/acceptance/expected-failures-on-OCIS-storage.md | 5 ----- tests/acceptance/expected-failures-on-S3NG-storage.md | 5 ----- 5 files changed, 7 insertions(+), 12 deletions(-) create mode 100644 changelog/unreleased/fix-response-code.md diff --git a/changelog/unreleased/fix-response-code.md b/changelog/unreleased/fix-response-code.md new file mode 100644 index 0000000000..2f9d9290d1 --- /dev/null +++ b/changelog/unreleased/fix-response-code.md @@ -0,0 +1,5 @@ +Bugfix: Return proper response code when detecting recursive copy/move operations + +We changed the ocdav response code to "409 - Conflict" when a recursive operation was detected. + +https://github.com/cs3org/reva/pull/3031 diff --git a/internal/http/services/owncloud/ocdav/copy.go b/internal/http/services/owncloud/ocdav/copy.go index 335617b5bc..cde7e937ba 100644 --- a/internal/http/services/owncloud/ocdav/copy.go +++ b/internal/http/services/owncloud/ocdav/copy.go @@ -506,7 +506,7 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re } } if isChild { - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusConflict) b, err := errors.Marshal(http.StatusBadRequest, "can not copy a folder into one of its children", "") errors.HandleWebdavError(log, w, b, err) return nil diff --git a/internal/http/services/owncloud/ocdav/move.go b/internal/http/services/owncloud/ocdav/move.go index 85a7ed9b5b..283e11ee38 100644 --- a/internal/http/services/owncloud/ocdav/move.go +++ b/internal/http/services/owncloud/ocdav/move.go @@ -152,7 +152,7 @@ func (s *svc) handleMove(ctx context.Context, w http.ResponseWriter, r *http.Req } } if isChild { - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusConflict) b, err := errors.Marshal(http.StatusBadRequest, "can not move a folder into one of its children", "") errors.HandleWebdavError(&log, w, b, err) return diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.md b/tests/acceptance/expected-failures-on-OCIS-storage.md index 931d5ae771..aa77ab3f5d 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-on-OCIS-storage.md @@ -1490,10 +1490,5 @@ moving outside of the Shares folder gives 501 Not Implemented. - [apiShareOperationsToShares1/gettingShares.feature:40](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L40) - [apiShareOperationsToShares1/gettingShares.feature:39](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L39) -#### [apiWebdavMove1/moveFolder.feature:135 fails with 400 status](https://github.com/owncloud/ocis/issues/3023) -- [apiWebdavMove1/moveFolder.feature:147](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L147) -- [apiWebdavMove1/moveFolder.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L148) -- [apiWebdavMove1/moveFolder.feature:153](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L153) - - Note: always have an empty line at the end of this file. The bash script that processes this file may not process a scenario reference on the last line. diff --git a/tests/acceptance/expected-failures-on-S3NG-storage.md b/tests/acceptance/expected-failures-on-S3NG-storage.md index 61b0013919..408f81139e 100644 --- a/tests/acceptance/expected-failures-on-S3NG-storage.md +++ b/tests/acceptance/expected-failures-on-S3NG-storage.md @@ -1488,10 +1488,5 @@ _ocs: api compatibility, return correct status code_ - [apiShareOperationsToShares1/gettingShares.feature:40](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L40) - [apiShareOperationsToShares1/gettingShares.feature:39](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares1/gettingShares.feature#L39) -#### [apiWebdavMove1/moveFolder.feature:135 fails with 400 status](https://github.com/owncloud/ocis/issues/3023) -- [apiWebdavMove1/moveFolder.feature:147](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L147) -- [apiWebdavMove1/moveFolder.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L148) -- [apiWebdavMove1/moveFolder.feature:153](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavMove1/moveFolder.feature#L153) - Note: always have an empty line at the end of this file. The bash script that processes this file may not process a scenario reference on the last line.