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
Use HTTPX for oauth authorization state checks.
Pavel Balashouc22721c03a4b
diff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rbindex be177b34aff..c787eaa8543 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb@@ -42,9 +42,9 @@ module Storagesdef authorization_check_wrappercase yield- when Net::HTTPSuccess+ when 200..299:success- when Net::HTTPForbidden, Net::HTTPUnauthorized+ when 401, 403:refresh_neededelse:errordiff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rbindex 979005c1b0d..a977d630a8e 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb@@ -44,16 +44,14 @@ module Storagesutil = ::Storages::Peripherals::StorageInteraction::Nextcloud::Utilauthorization_check_wrapper do- Net::HTTP.start(@uri.host, @uri.port, use_ssl: true) do |http|- http.get(- util.join_uri_path(@uri.path, '/ocs/v1.php/cloud/user'),- {- 'Authorization' => "Bearer #{token}",- 'OCS-APIRequest' => 'true',- 'Accept' => 'application/json'- }- )- end+ HTTPX.get(+ util.join_uri_path(@uri, '/ocs/v1.php/cloud/user'),+ headers: {+ 'Authorization' => "Bearer #{token}",+ 'OCS-APIRequest' => 'true',+ 'Accept' => 'application/json'+ }+ ).statusendenddiff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rbindex 58e4514aa4e..781129cb833 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb@@ -45,10 +45,13 @@ module Storagesenddef authorization_state_check(access_token)+ util = ::Storages::Peripherals::StorageInteraction::OneDrive::Util+authorization_check_wrapper do- Net::HTTP.start(@uri.host, @uri.port, use_ssl: true) do |http|- http.get('/v1.0/me', { 'Authorization' => "Bearer #{access_token}", 'Accept' => 'application/json' })- end+ HTTPX.get(+ util.join_uri_path(@uri, '/v1.0/me'),+ headers: { 'Authorization' => "Bearer #{access_token}", 'Accept' => 'application/json' }+ ).statusendenddiff --git a/spec/requests/oauth_clients/ensure_connection_flow_spec.rb b/spec/requests/oauth_clients/ensure_connection_flow_spec.rbindex bcaea46d4c7..218e99886b4 100644--- a/spec/requests/oauth_clients/ensure_connection_flow_spec.rb+++ b/spec/requests/oauth_clients/ensure_connection_flow_spec.rb@@ -125,10 +125,8 @@ RSpec.describe "/oauth_clients/:oauth_client_id/ensure_connection endpoint", :we.with(headers: {'Accept' => 'application/json',- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3','Authorization' => "Bearer #{oauth_client_token.access_token}",'Ocs-Apirequest' => 'true',- 'User-Agent' => 'Ruby'}).to_return(status: 200, body: "", headers: {})end