Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use 200..299 ranges to replicate Net::HTTPSuccess.

Pavel Balashou12a3e7ccb2e1
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb
index 1e4f7ad154d..d17f154ee30 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb
@@ -60,7 +60,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 200
+ when 200..299
statuscode = Nokogiri::XML(response.body.to_s).xpath('/ocs/meta/statuscode').text
case statuscode
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
index bbf24cc8f80..02b18ef645d 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
@@ -85,7 +85,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
.head(urls[:destination_url])
case response.status
- when 200
+ when 200..299
Util.error(:conflict, 'Destination folder already exists.')
when 401
Util.error(:unauthorized, "unauthorized (validate_destination)")
@@ -110,7 +110,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
})
case response.status
- when 201
+ when 200..299
ServiceResult.success(message: 'Folder was successfully copied')
when 401
Util.error(:unauthorized, "Unauthorized (copy_folder)")
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb
index 619996c98c8..28b35600c6b 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb
@@ -59,7 +59,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 201
+ when 200..299
ServiceResult.success(message: 'Folder was successfully created.')
when 405
if Util.error_text_from_response(response) == 'The resource you tried to create already exists'
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
index 186645748a9..eb9c5950bbe 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
@@ -58,7 +58,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
}
)
case response.status
- when 200
+ when 200..299
ServiceResult.success(result: response)
when 404
Util.error(:not_found, 'Outbound request destination not found!', response)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_info_query.rb
index 9716db0819c..1343d38cc44 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_info_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_info_query.rb
@@ -60,7 +60,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
.get(Util.join_uri_path(@uri, FILE_INFO_PATH, file_id))
case response.status
- when 200
+ when 200..299
ServiceResult.success(result: response.body)
when 404
Util.error(:not_found, 'Outbound request destination not found!', response)
@@ -82,7 +82,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
def handle_failure
->(response_object) do
case response_object.ocs.data.statuscode
- when 200
+ when 200..299
ServiceResult.success(result: response_object)
when 403
Util.error(:forbidden, 'Access to storage file forbidden!', response_object)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
index 96dad117732..c3224e7d82d 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
@@ -70,7 +70,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
json: { fileIds: file_ids })
case response.status
- when 200
+ when 200..299
ServiceResult.success(result: response.body.to_s)
when 404
Util.error(:not_found, 'Outbound request destination not found!', response)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
index bdd0455219a..9abbab32c3d 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
@@ -65,7 +65,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self, payload: response)
case response.status
- when 207
+ when 200..299
ServiceResult.success(result: response.body)
when 404
Util.error(:not_found, 'Outbound request destination not found', error_data)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
index de17d4c6021..67c21602fa9 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
@@ -53,7 +53,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 200
+ when 200..299
group_users = Nokogiri::XML(response.body.to_s)
.xpath('/ocs/data/users/element')
.map(&:text)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb
index 2472fbcd575..9e9ba9db898 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb
@@ -50,7 +50,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
UTIL.escape_path(location)))
case response.status
- when 204
+ when 200..299
ServiceResult.success
when 404
UTIL.error(:not_found)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb
index 5a2110fa0db..7a7e06441fc 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb
@@ -57,7 +57,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 200
+ when 200..299
statuscode = Nokogiri::XML(response.body.to_s).xpath('/ocs/meta/statuscode').text
case statuscode
when "100"
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
index 09973734337..15164b124db 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
@@ -58,7 +58,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 201
+ when 200..299
ServiceResult.success
when 404
Util.error(:not_found, 'Outbound request destination not found', error_data)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb
index 2e767d916eb..fc1143a2529 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb
@@ -94,7 +94,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
case response.status
- when 207
+ when 200..299
doc = Nokogiri::XML(response.body.to_s)
if doc.xpath("/d:multistatus/d:response/d:propstat[d:status[text() = 'HTTP/1.1 200 OK']]/d:prop/nc:acl-list").present?
ServiceResult.success(result: :success)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
index 0b41fc73def..91a42e49f4c 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
@@ -76,7 +76,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
json: payload
)
case response.status
- when 200
+ when 200..299
# The nextcloud API returns a successful response with empty body if the authorization is missing or expired
if response.body.present?
ServiceResult.success(
diff --git a/modules/storages/app/validator/nextcloud_application_credentials_validator.rb b/modules/storages/app/validator/nextcloud_application_credentials_validator.rb
index 70e544db5f8..5b1c6b677a8 100644
--- a/modules/storages/app/validator/nextcloud_application_credentials_validator.rb
+++ b/modules/storages/app/validator/nextcloud_application_credentials_validator.rb
@@ -43,7 +43,7 @@ class NextcloudApplicationCredentialsValidator
.basic_auth(contract.username, contract.password)
.head(UTIL.join_uri_path(uri, "remote.php/dav"))
case response.status
- when 200
+ when 200..299
true
when 401
contract.errors.add(:password, :invalid_password)