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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#50684] Migrate to httpx http ruby client
Pavel Balashou822608741fbe
diff --git a/Gemfile b/Gemfileindex 0035a68a01c..69b817053e6 100644--- a/Gemfile+++ b/Gemfile@@ -218,6 +218,8 @@ gem 'factory_bot_rails', '~> 6.4.0', require: falsegem 'turbo-rails', "~> 1.1"+gem 'httpx'+group :test dogem 'launchy', '~> 2.5.0'gem 'rack-test', '~> 2.1.0'diff --git a/Gemfile.lock b/Gemfile.lockindex de7d6f946b3..4a3f2e9a51b 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -574,8 +574,11 @@ GEMhtmlbeautifier (1.4.2)htmldiff (0.0.1)htmlentities (4.3.4)+ http-2-next (1.0.1)http_parser.rb (0.6.0)httpclient (2.8.3)+ httpx (1.0.2)+ http-2-next (>= 1.0.1)i18n (1.14.1)concurrent-ruby (~> 1.0)i18n-js (4.2.3)@@ -1115,6 +1118,7 @@ DEPENDENCIESgrids!html-pipeline (~> 2.14.0)htmldiff+ httpxi18n-js (~> 4.2.3)json_schemer (~> 2.1.0)json_spec (~> 1.1.4)@@ -1245,4 +1249,4 @@ RUBY VERSIONruby 3.2.1p31BUNDLED WITH- 2.4.7+ 2.4.6diff --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.rbindex 8e5896573e8..1e4f7ad154d 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@@ -43,21 +43,25 @@ module Storages::Peripherals::StorageInteraction::Nextcloudenddef call(user:, group: @group)- response = Util.http(@uri).post(- Util.join_uri_path(@uri.path, 'ocs/v1.php/cloud/users', CGI.escapeURIComponent(user), 'groups'),- "groupid=#{CGI.escapeURIComponent(group)}",- Util- .basic_auth_header(@username, @password)- .merge(- 'OCS-APIRequest' => 'true'- )- )+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .with(headers: { 'OCS-APIRequest' => 'true' })+ .post(+ Util.join_uri_path(+ @uri,+ 'ocs/v1.php/cloud/users',+ CGI.escapeURIComponent(user),+ 'groups'+ ),+ form: { "groupid" => CGI.escapeURIComponent(group) },+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess- statuscode = Nokogiri::XML(response.body).xpath('/ocs/meta/statuscode').text+ case response.status+ when 200+ statuscode = Nokogiri::XML(response.body.to_s).xpath('/ocs/meta/statuscode').textcase statuscodewhen "100"@@ -73,13 +77,13 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen "105"Util.error(:error, "Failed to add user to group", error_data)end- when Net::HTTPMethodNotAllowed+ when 405Util.error(:not_allowed, 'Outbound request method not allowed', error_data)- when Net::HTTPNotFound+ when 401Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 404Util.error(:unauthorized, 'Outbound request not authorized', error_data)- when Net::HTTPConflict+ when 409Util.error(:conflict, Util.error_text_from_response(response), error_data)elseUtil.error(:error, 'Outbound request failed', error_data)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.rbindex b41c18b35b7..f4ea5b8916f 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@@ -60,14 +60,14 @@ module Storages::Peripherals::StorageInteraction::Nextcloudescaped_username = CGI.escapeURIComponent(@username)source = Util.join_uri_path(- @uri.path,+ @uri,"remote.php/dav/files",escaped_username,Util.escape_path(input[:source_path]))destination = Util.join_uri_path(- @uri.path,+ @uri,"remote.php/dav/files",escaped_username,Util.escape_path(input[:destination_path])@@ -82,14 +82,17 @@ module Storages::Peripherals::StorageInteraction::Nextcloudrequest = Net::HTTP::Head.new(urls[:destination_url])request.initialize_http_header Util.basic_auth_header(@username, @password)- response = Util.http(@uri).request(request)+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .head(urls[:destination_url])- case response- when Net::HTTPSuccess+ case response.status+ when 200Util.error(:conflict, 'Destination folder already exists.')- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, "unauthorized (validate_destination)")- when Net::HTTPNotFound+ when 404ServiceResult.success(result: urls)elseUtil.error(:unknown, "Unexpected response (validate_destination): #{response.code}", response)@@ -100,24 +103,27 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:disable Metrics/AbcSizedef copy_folder->(urls) do- headers = Util.basic_auth_header(@username, @password)- headers['Destination'] = urls[:destination_url]- headers['Depth'] = 'infinity'-- request = Net::HTTP::Copy.new(urls[:source_url], headers)- response = Util.http(@uri).request(request)-- case response- when Net::HTTPCreated+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .request("COPY",+ urls[:source_url],+ headers: {+ 'Destination' => urls[:destination_url],+ 'Depth' => 'infinity',+ })++ case response.status+ when 201ServiceResult.success(message: 'Folder was successfully copied')- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, "Unauthorized (copy_folder)")- when Net::HTTPNotFound+ when 404Util.error(:not_found, "Project folder not found (copy_folder)")- when Net::HTTPConflict+ when 409Util.error(:conflict, Util.error_text_from_response(response))else- Util.error(:unknown, "Unexpected response (copy_folder): #{response.code}", response)+ Util.error(:unknown, "Unexpected response (copy_folder): #{response.status}", response)endendenddiff --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.rbindex c8fb5ef0382..619996c98c8 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@@ -44,28 +44,34 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:disable Metrics/AbcSizedef call(folder_path:)- response = Util.http(@uri).mkcol(- Util.join_uri_path(@uri.path, "remote.php/dav/files", CGI.escapeURIComponent(@username), Util.escape_path(folder_path)),- nil,- Util.basic_auth_header(@username, @password)- )+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .mkcol(+ Util.join_uri_path(+ @uri,+ "remote.php/dav/files",+ CGI.escapeURIComponent(@username),+ Util.escape_path(folder_path)+ )+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess+ case response.status+ when 201ServiceResult.success(message: 'Folder was successfully created.')- when Net::HTTPMethodNotAllowed+ when 405if Util.error_text_from_response(response) == 'The resource you tried to create already exists'ServiceResult.success(message: 'Folder already exists.')elseUtil.error(:not_allowed, 'Outbound request method not allowed', error_data)end- when Net::HTTPNotFound- Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)- when Net::HTTPConflict+ when 404+ Util.error(:not_found, 'Outbound request destination not found', error_data)+ when 409Util.error(:conflict, Util.error_text_from_response(response), error_data)elseUtil.error(:error, 'Outbound request failed', error_data)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.rbindex e9a8c56ed69..186645748a9 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@@ -45,22 +45,24 @@ module Storages::Peripherals::StorageInteraction::Nextclouddef call(user:, file_link:)result = Util.token(user:, configuration: @configuration) do |token|service_result = begin- response = Util.http(@uri).post(- Util.join_uri_path(@uri.path, '/ocs/v2.php/apps/dav/api/v1/direct'),- { fileId: file_link.origin_id }.to_json,- {- 'Authorization' => "Bearer #{token.access_token}",- 'OCS-APIRequest' => 'true',- 'Accept' => 'application/json',- 'Content-Type' => 'application/json'- }- )- case response- when Net::HTTPSuccess+ response = Util+ .httpx+ .post(+ Util.join_uri_path(@uri, '/ocs/v2.php/apps/dav/api/v1/direct'),+ json: { fileId: file_link.origin_id },+ headers: {+ 'Authorization' => "Bearer #{token.access_token}",+ 'OCS-APIRequest' => 'true',+ 'Accept' => 'application/json',+ 'Content-Type' => 'application/json'+ }+ )+ case response.status+ when 200ServiceResult.success(result: response)- when Net::HTTPNotFound+ when 404Util.error(:not_found, 'Outbound request destination not found!', response)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')@@ -72,7 +74,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudif resp.body.blank?Util.error(:unauthorized, 'Outbound request not authorized!')else- ServiceResult.success(result: resp.body)+ ServiceResult.success(result: resp.body.to_s)endendenddiff --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.rbindex 85d4d8384b8..3f1a544c640 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@@ -52,21 +52,23 @@ module Storages::Peripherals::StorageInteraction::Nextcloudprivatedef file_info(file_id, token)- response = Util.http(@uri).get(- Util.join_uri_path(@uri.path, FILE_INFO_PATH, file_id),- {- 'Authorization' => "Bearer #{token.access_token}",- 'Accept' => 'application/json',- 'OCS-APIRequest' => 'true'- }- )-- case response- when Net::HTTPSuccess+ response = Util+ .httpx+ .get(+ Util.join_uri_path(@uri, FILE_INFO_PATH, file_id),+ {+ 'Authorization' => "Bearer #{token.access_token}",+ 'Accept' => 'application/json',+ 'OCS-APIRequest' => 'true'+ }+ )++ case response.status+ when 200ServiceResult.success(result: response.body)- when Net::HTTPNotFound+ when 404Util.error(:not_found, 'Outbound request destination not found!', response)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')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.rbindex 1ad6192aeb4..3038fde0a9b 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@@ -60,22 +60,22 @@ module Storages::Peripherals::StorageInteraction::Nextcloudprivatedef files_info(file_ids, token)- response = Util.http(@uri).post(- Util.join_uri_path(@uri.path, FILES_INFO_PATH),- { fileIds: file_ids }.to_json,- {- 'Authorization' => "Bearer #{token.access_token}",- 'Accept' => 'application/json',- 'Content-Type' => 'application/json',- 'OCS-APIRequest' => 'true'- }- )- case response- when Net::HTTPSuccess- ServiceResult.success(result: response.body)- when Net::HTTPNotFound+ httpx = HTTPX.with(headers:+ {+ 'Authorization' => "Bearer #{token.access_token}",+ 'Accept' => 'application/json',+ 'Content-Type' => 'application/json',+ 'OCS-APIRequest' => 'true'+ }+ )+ response = httpx.post(Util.join_uri_path(@uri.to_s, FILES_INFO_PATH), json: { fileIds: file_ids })++ case response.status+ when 200+ ServiceResult.success(result: response.body.to_s)+ when 404Util.error(:not_found, 'Outbound request destination not found!', response)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!', 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.rbindex cf33c90830d..0c0bbcac81a 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@@ -39,17 +39,19 @@ module Storages::Peripherals::StorageInteraction::Nextclouddef call(user:, folder:)result = Util.token(user:, configuration: @configuration) do |token|- base_path = Util.join_uri_path(@uri.path, "remote.php/dav/files")- @location_prefix = Util.join_uri_path(base_path, token.origin_user_id.gsub(' ', '%20'))-- response = Util.http(@uri).propfind(- Util.join_uri_path(base_path, CGI.escapeURIComponent(token.origin_user_id), requested_folder(folder)),- requested_properties,- {- 'Depth' => '1',- 'Authorization' => "Bearer #{token.access_token}"- }- )+ @location_prefix = Util.join_uri_path(@uri.path, "remote.php/dav/files", token.origin_user_id.gsub(' ', '%20'))++ response = Util+ .httpx+ .request(+ "PROPFIND",+ Util.join_uri_path(@uri, "remote.php/dav/files", CGI.escapeURIComponent(token.origin_user_id), requested_folder(folder)),+ xml: requested_properties,+ headers: {+ 'Depth' => '1',+ 'Authorization' => "Bearer #{token.access_token}"+ }+ )handle_response(response)end@@ -62,12 +64,12 @@ module Storages::Peripherals::StorageInteraction::Nextclouddef handle_response(response)error_data = Storages::StorageErrorData.new(source: self, payload: response)- case response- when Net::HTTPSuccess+ case response.status+ when 207ServiceResult.success(result: response.body)- when Net::HTTPNotFound+ when 404Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)elseUtil.error(:error, 'Outbound request failed', error_data)@@ -108,9 +110,9 @@ module Storages::Peripherals::StorageInteraction::Nextcloud.to_aparent, *files =- a.map do |file_element|- storage_file(file_element)- end+ a.map do |file_element|+ storage_file(file_element)+ end::Storages::StorageFiles.new(files, parent, ancestors(parent.location))enddiff --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.rbindex 92e63054a8f..de17d4c6021 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@@ -44,27 +44,28 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:disable Metrics/AbcSizedef call(group:)- response = Util.http(@uri).get(- Util.join_uri_path(@uri.path, "ocs/v1.php/cloud/groups", CGI.escapeURIComponent(group)),- Util.basic_auth_header(@username, @password).merge('OCS-APIRequest' => 'true')- )+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .with(headers: {'OCS-APIRequest' => 'true'})+ .get(Util.join_uri_path(@uri, "ocs/v1.php/cloud/groups", CGI.escapeURIComponent(group)))error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess- group_users = Nokogiri::XML(response.body)+ case response.status+ when 200+ group_users = Nokogiri::XML(response.body.to_s).xpath('/ocs/data/users/element').map(&:text)ServiceResult.success(result: group_users)- when Net::HTTPMethodNotAllowed+ when 405Util.error(:not_allowed, 'Outbound request method not allowed', error_data)- when Net::HTTPNotFound- Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)- when Net::HTTPConflict- Util.error(:conflict, Util.error_text_from_response(response), error_data)+ when 404+ Util.error(:not_found, 'Outbound request destination not found', error_data)+ when 409+ Util.error(:conflict, error_text_from_response(response), error_data)elseUtil.error(:error, 'Outbound request failed', error_data)enddiff --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.rbindex 04c7e8ab72e..b2a65fdd633 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@@ -32,7 +32,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internaldef initialize(storage)@uri = storage.uri- @base_path = UTIL.join_uri_path(@uri.path, "remote.php/dav/files", CGI.escapeURIComponent(storage.username))+ @base_path =@username = storage.username@password = storage.passwordend@@ -42,17 +42,17 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internalenddef call(location:)- response = UTIL.http(@uri).delete(- UTIL.join_uri_path(@base_path, UTIL.escape_path(location)),- UTIL.basic_auth_header(@username, @password)- )+ response = UTIL+ .httpx+ .basic_auth(@username, @password)+ .delete(UTIL.join_uri_path(@uri, "remote.php/dav/files", CGI.escapeURIComponent(@username), UTIL.escape_path(location)))- case response- when Net::HTTPSuccess+ case response.status+ when 204ServiceResult.success- when Net::HTTPNotFound+ when 404UTIL.error(:not_found)- when Net::HTTPUnauthorized+ when 401UTIL.error(:unauthorized)elseUTIL.error(:error)diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rbindex 866e11fca73..b70863a8ae4 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb@@ -90,22 +90,26 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internalendend.to_xml- response = UTIL.http(@uri).propfind(- UTIL.join_uri_path(- @uri.path,- 'remote.php/dav/files',- CGI.escapeURIComponent(@username),- UTIL.escape_path(path)- ),- body,- UTIL.basic_auth_header(@username, @password).merge('Depth' => depth)- )+ response = UTIL+ .httpx+ .basic_auth(@username, @password)+ .with(headers: { "Depth" => depth})+ .request(+ "PROPFIND",+ UTIL.join_uri_path(+ @uri,+ 'remote.php/dav/files',+ CGI.escapeURIComponent(@username),+ UTIL.escape_path(path)+ ),+ xml: body,+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess- doc = Nokogiri::XML response.body+ case response.status+ when 200..299+ doc = Nokogiri::XML(response.body.to_s)result = {}doc.xpath('/d:multistatus/d:response').each do |resource_section|resource = CGI.unescape(resource_section.xpath("d:href").text.strip)@@ -121,12 +125,12 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::InternalendServiceResult.success(result:)- when Net::HTTPMethodNotAllowed+ when 405UTIL.error(:not_allowed, 'Outbound request method not allowed', error_data)- when Net::HTTPNotFound- UTIL.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401UTIL.error(:unauthorized, 'Outbound request not authorized', error_data)+ when 404+ UTIL.error(:not_found, 'Outbound request destination not found', error_data)elseUTIL.error(:error, 'Outbound request failed', error_data)enddiff --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.rbindex 06bb0daf0ff..5a2110fa0db 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@@ -43,21 +43,22 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:disable Metrics/AbcSizedef call(user:, group: @group)- response = Util.http(@uri).delete(- Util.join_uri_path(@uri.path,- "ocs/v1.php/cloud/users",- CGI.escapeURIComponent(user),- "groups?groupid=#{CGI.escapeURIComponent(group)}"),- Util.basic_auth_header(@username, @password).merge(- 'OCS-APIRequest' => 'true'- )- )+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .with(headers: { 'OCS-APIRequest' => 'true' })+ .delete(+ Util.join_uri_path(@uri,+ "ocs/v1.php/cloud/users",+ CGI.escapeURIComponent(user),+ "groups?groupid=#{CGI.escapeURIComponent(group)}")+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess- statuscode = Nokogiri::XML(response.body).xpath('/ocs/meta/statuscode').text+ case response.status+ when 200+ statuscode = Nokogiri::XML(response.body.to_s).xpath('/ocs/meta/statuscode').textcase statuscodewhen "100"ServiceResult.success(message: "User has been removed from group")@@ -73,13 +74,13 @@ module Storages::Peripherals::StorageInteraction::Nextcloudmessage = Nokogiri::XML(response.body).xpath('/ocs/meta/message').textUtil.error(:error, "Failed to remove user #{user} from group #{group}: #{message}", error_data)end- when Net::HTTPMethodNotAllowed+ when 405Util.error(:not_allowed, 'Outbound request method not allowed', error_data)- when Net::HTTPNotFound- Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)- when Net::HTTPConflict+ when 404+ Util.error(:not_found, 'Outbound request destination not found', error_data)+ when 409Util.error(:conflict, Util.error_text_from_response(response), error_data)elseUtil.error(:error, 'Outbound request failed', error_data)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.rbindex f4e85a078b5..09973734337 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@@ -34,7 +34,7 @@ module Storages::Peripherals::StorageInteraction::Nextclouddef initialize(storage)@uri = storage.uri- @base_path = Util.join_uri_path(@uri.path, "remote.php/dav/files", CGI.escapeURIComponent(storage.username))+ @base_path = Util.join_uri_path(@uri, "remote.php/dav/files", CGI.escapeURIComponent(storage.username))@username = storage.username@password = storage.passwordend@@ -44,21 +44,25 @@ module Storages::Peripherals::StorageInteraction::Nextcloudenddef call(source:, target:)- response = Util.http(@uri).move(- Util.join_uri_path(@base_path, Util.escape_path(source)),- Util.basic_auth_header(@username, @password).merge(- 'Destination' => Util.join_uri_path(@base_path, Util.escape_path(target))- )- )+ response = Util+ .httpx+ .basic_auth(@username, @password)+ .request(+ "MOVE",+ Util.join_uri_path(@base_path, Util.escape_path(source)),+ headers: {+ 'Destination' => Util.join_uri_path(@uri.path, "remote.php/dav/files", CGI.escapeURIComponent(@username), Util.escape_path(target))+ }+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess+ case response.status+ when 201ServiceResult.success- when Net::HTTPNotFound+ when 404Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)elseUtil.error(:error, 'Outbound request failed', 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.rbindex 5de94706e7d..18f90cde322 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@@ -79,28 +79,32 @@ module Storages::Peripherals::StorageInteraction::Nextcloudendend.to_xml- response = Util.http(@uri).proppatch(- Util.join_uri_path(@uri.path,- "remote.php/dav/files",- CGI.escapeURIComponent(@username),- Util.escape_path(path)),- body,- Util.basic_auth_header(@username, @password)- )+ response = Util+ .httpx+ .with(debug_level: 1, debug: $stdout)+ .basic_auth(@username, @password)+ .request(+ "PROPPATCH",+ Util.join_uri_path(@uri,+ "remote.php/dav/files",+ CGI.escapeURIComponent(@username),+ Util.escape_path(path)),+ xml: body+ )error_data = Storages::StorageErrorData.new(source: self.class, payload: response)- case response- when Net::HTTPSuccess- doc = Nokogiri::XML(response.body)+ case response.status+ when 207+ 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)elseUtil.error(:error, "nc:acl properly has not been set for #{path}", error_data)end- when Net::HTTPNotFound+ when 404Util.error(:not_found, 'Outbound request destination not found', error_data)- when Net::HTTPUnauthorized+ when 401Util.error(:unauthorized, 'Outbound request not authorized', error_data)elseUtil.error(:error, 'Outbound request failed', error_data)diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rbindex 55b29a50606..19acdbcb7a7 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb@@ -79,6 +79,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Utilhttpend+ def httpx+ HTTPX.plugin(:basic_auth).plugin(:webdav)+ end+def error_text_from_response(response)Nokogiri::XML(response.body).xpath("//s:message").textenddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command_spec.rbindex 2ab785810b1..431d79de298 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command_spec.rb@@ -116,6 +116,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::CopyTemplatexpect(result).to be_failureexpect(result.errors.code).to eq(:conflict)+ expect(result.errors.log_message).to eq("The destination node is not found")endendenddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_info_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_info_query_spec.rbindex d40f992e679..a18ff41bc57 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_info_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_info_query_spec.rb@@ -31,7 +31,7 @@require 'spec_helper'require_module_spec_helper-RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesInfoQuery, :vcr, :webmock do+RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesInfoQuery, :webmock dousing Storages::Peripherals::ServiceResultRefinementslet(:user) { create(:user) }diff --git a/spec/services/oauth_clients/redirect_uri_from_state_service_spec.rb b/spec/services/oauth_clients/redirect_uri_from_state_service_spec.rbindex 360cb841928..b0527091d91 100644--- a/spec/services/oauth_clients/redirect_uri_from_state_service_spec.rb+++ b/spec/services/oauth_clients/redirect_uri_from_state_service_spec.rb@@ -27,7 +27,6 @@#++require 'spec_helper'-require 'webmock/rspec'RSpec.describe OAuthClients::RedirectUriFromStateService, type: :model dolet(:state) { 'asdf123425' }diff --git a/spec/support/webmock.rb b/spec/support/webmock.rbindex ce192bf8139..3b6ccb9bb11 100644--- a/spec/support/webmock.rb+++ b/spec/support/webmock.rb@@ -25,7 +25,9 @@## See COPYRIGHT and LICENSE files for more details.#+++require 'webmock/rspec'+require "httpx/adapters/webmock"RSpec.configure do |config|config.before(:suite) do