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
[chore] replaced :not_authorized with :unauthorized
Eric Schubert639c258dc197
diff --git a/app/services/oauth_clients/connection_manager.rb b/app/services/oauth_clients/connection_manager.rbindex a523134e421..eefce9cd2f3 100644--- a/app/services/oauth_clients/connection_manager.rb+++ b/app/services/oauth_clients/connection_manager.rb@@ -162,10 +162,10 @@ module OAuthClientsdef request_with_token_refresh(oauth_client_token)# `yield` needs to returns a ServiceResult:# success: result= any object with data- # failure: result= :error or :not_authorized+ # failure: result= :error or :unauthorizedyield_service_result = yield(oauth_client_token)- if yield_service_result.failure? && yield_service_result.result == :not_authorized+ if yield_service_result.failure? && yield_service_result.result == :unauthorizedrefresh_service_result = refresh_tokenif refresh_service_result.failure?failed_service_result = ServiceResult.failure(result: :error)diff --git a/modules/storages/app/common/storages/peripherals/storage_error_helper.rb b/modules/storages/app/common/storages/peripherals/storage_error_helper.rbindex 2dfdb342c29..541cb4e7bb4 100644--- a/modules/storages/app/common/storages/peripherals/storage_error_helper.rb+++ b/modules/storages/app/common/storages/peripherals/storage_error_helper.rb@@ -42,20 +42,5 @@ module Storages::Peripheralsraise API::Errors::InternalError.newendend-- def error_to_code(error)- case error.code- when :bad_request- 400- when :not_authorized- 401- when :forbidden- 403- when :not_found- 404- else- 500- end- endendenddiff --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 9deed6e918a..f1c65488869 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@@ -71,7 +71,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPMethodNotAllowedUtil.error(:not_allowed)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)when Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPConflictdiff --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 7b353f151dd..9956a28663c 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@@ -88,7 +88,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPSuccessUtil.error(:conflict, 'Destination folder already exists.')when Net::HTTPUnauthorized- Util.error(:not_authorized, "Not authorized (validate_destination)")+ Util.error(:unauthorized, "unauthorized (validate_destination)")when Net::HTTPNotFoundServiceResult.success(result: urls)else@@ -111,7 +111,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPCreatedServiceResult.success(message: 'Folder was successfully copied')when Net::HTTPUnauthorized- Util.error(:not_authorized, "Not authorized (copy_folder)")+ Util.error(:unauthorized, "Unauthorized (copy_folder)")when Net::HTTPNotFoundUtil.error(:not_found, "Project folder not found (copy_folder)")when Net::HTTPConflictdiff --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 81b07c2255f..363322e8111 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@@ -58,7 +58,7 @@ module Storages::Peripherals::StorageInteraction::NextcloudUtil.error(:not_allowed)endwhen Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)when Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPConflictdiff --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 01d3fb13283..e9a8c56ed69 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@@ -61,18 +61,18 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found, 'Outbound request destination not found!', response)when Net::HTTPUnauthorized- Util.error(:not_authorized, 'Outbound request not authorized!', response)+ Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')endend- service_result.bind do |response|+ service_result.bind do |resp|# The nextcloud API returns a successful response with empty body if the authorization is missing or expired- if response.body.blank?- Util.error(:not_authorized, 'Outbound request not authorized!')+ if resp.body.blank?+ Util.error(:unauthorized, 'Outbound request not authorized!')else- ServiceResult.success(result: response.body)+ ServiceResult.success(result: resp.body)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 eefa8e18dd4..85d4d8384b8 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@@ -67,7 +67,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found, 'Outbound request destination not found!', response)when Net::HTTPUnauthorized- Util.error(:not_authorized, 'Outbound request not authorized!', response)+ Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')enddiff --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 cd9bcaba857..1fe1dde5782 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@@ -76,7 +76,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found, 'Outbound request destination not found!', response)when Net::HTTPUnauthorized- Util.error(:not_authorized, 'Outbound request not authorized!', response)+ Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')enddiff --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 61531659d17..4c22a48461b 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@@ -58,7 +58,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)elseUtil.error(:error)end@@ -90,7 +90,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudxml['d'].getcontenttypexml['d'].getlastmodifiedxml['oc'].permissions- xml['oc'].send(:"owner-display-name")+ xml['oc'].send(:'owner-display-name')endendend.to_xmldiff --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 b6ebf4b870b..1ccb379fb34 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@@ -55,7 +55,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPMethodNotAllowedUtil.error(:not_allowed)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)when Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPConflictdiff --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 dc22281ccf9..04c7e8ab72e 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@@ -53,7 +53,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internalwhen Net::HTTPNotFoundUTIL.error(:not_found)when Net::HTTPUnauthorized- UTIL.error(:not_authorized)+ UTIL.error(:unauthorized)elseUTIL.error(:error)enddiff --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 a2104e3084a..200f904d2b3 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@@ -122,7 +122,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internalwhen Net::HTTPMethodNotAllowedUTIL.error(:not_allowed)when Net::HTTPUnauthorized- UTIL.error(:not_authorized)+ UTIL.error(:unauthorized)when Net::HTTPNotFoundUTIL.error(:not_found)elsediff --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 c97eb4e3e4d..00568b2716b 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@@ -72,7 +72,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPMethodNotAllowedUtil.error(:not_allowed)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)when Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPConflictdiff --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 59b1aeaddda..f9f2d7b1fc6 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@@ -55,7 +55,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)elseUtil.error(:error)enddiff --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 2660bc0511f..8530e81fbd5 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@@ -54,21 +54,21 @@ module Storages::Peripherals::StorageInteraction::Nextcloud) doxml['d'].set doxml['d'].prop do- xml['nc'].send(:"acl-list") do+ xml['nc'].send(:'acl-list') dogroups_permissions.each do |group, group_permissions|xml['nc'].acl do- xml['nc'].send(:"acl-mapping-type", 'group')- xml['nc'].send(:"acl-mapping-id", group)- xml['nc'].send(:"acl-mask", '31')- xml['nc'].send(:"acl-permissions", group_permissions.to_s)+ xml['nc'].send(:'acl-mapping-type', 'group')+ xml['nc'].send(:'acl-mapping-id', group)+ xml['nc'].send(:'acl-mask', '31')+ xml['nc'].send(:'acl-permissions', group_permissions.to_s)endendusers_permissions.each do |user, user_permissions|xml['nc'].acl do- xml['nc'].send(:"acl-mapping-type", 'user')- xml['nc'].send(:"acl-mapping-id", user)- xml['nc'].send(:"acl-mask", '31')- xml['nc'].send(:"acl-permissions", user_permissions.to_s)+ xml['nc'].send(:'acl-mapping-type', 'user')+ xml['nc'].send(:'acl-mapping-id', user)+ xml['nc'].send(:'acl-mask', '31')+ xml['nc'].send(:'acl-permissions', user_permissions.to_s)endendend@@ -97,7 +97,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloudwhen Net::HTTPNotFoundUtil.error(:not_found)when Net::HTTPUnauthorized- Util.error(:not_authorized)+ Util.error(:unauthorized)elseUtil.error(:error)enddiff --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.rbindex 63ebc9afaac..d0dd7ad4956 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@@ -83,12 +83,12 @@ module Storages::Peripherals::StorageInteraction::Nextcloudresult: JSON.parse(response.body, object_class: OpenStruct) # rubocop:disable Style/OpenStructUse)else- Util.error(:not_authorized, 'Outbound request not authorized!')+ Util.error(:unauthorized, 'Outbound request not authorized!')endwhen Net::HTTPNotFoundUtil.error(:not_found, 'Outbound request destination not found!', response)when Net::HTTPUnauthorized- Util.error(:not_authorized, 'Outbound request not authorized!', response)+ Util.error(:unauthorized, 'Outbound request not authorized!', response)elseUtil.error(:error, 'Outbound request failed!')enddiff --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 dd75ef27e7c..ab6b269d3a1 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@@ -57,13 +57,13 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::UtilFile.join(uri.to_s, *)end- def token(user:, configuration:, &block)+ def token(user:, configuration:, &)connection_manager = ::OAuthClients::ConnectionManager.new(user:, configuration:)connection_manager.get_access_token.match(on_success: ->(token) do- connection_manager.request_with_token_refresh(token) { block.call(token) }+ connection_manager.request_with_token_refresh(token) { yield token }end,- on_failure: ->(_) { error(:not_authorized, 'Query could not be created! No access token found!') }+ on_failure: ->(_) { error(:unauthorized, 'Query could not be created! No access token found!') })enddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rbindex 42b062e081a..642c9e67f8e 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb@@ -73,8 +73,8 @@ module StoragesServiceResult.failure(result: :forbidden,errors: ::Storages::StorageError.new(code: :forbidden, data: json))when Net::HTTPUnauthorized- ServiceResult.failure(result: :not_authorized,- errors: ::Storages::StorageError.new(code: :not_authorized, data: json))+ ServiceResult.failure(result: :unauthorized,+ errors: ::Storages::StorageError.new(code: :unauthorized, data: json))elseServiceResult.failure(result: :error,errors: ::Storages::StorageError.new(code: :error, data: json))diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rbindex d7a971a52a2..9426560f9c2 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb@@ -71,7 +71,7 @@ module StoragesStorageFileInfo.new(id: file_id,status: storage_error.data.dig(:error, :code),- status_code: error_to_code(storage_error)+ status_code: Rack::Utils::SYMBOL_TO_STATUS_CODE[storage_error.code])endenddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rbindex 9dc79cbc072..4fb6e569923 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb@@ -68,7 +68,7 @@ module Storageswhen Net::HTTPNotFoundServiceResult.failure(result: :not_found, errors: ::Storages::StorageError.new(code: :not_found))when Net::HTTPUnauthorized- ServiceResult.failure(result: :not_authorized, errors: ::Storages::StorageError.new(code: :not_authorized))+ ServiceResult.failure(result: :unauthorized, errors: ::Storages::StorageError.new(code: :unauthorized))elseServiceResult.failure(result: :error, errors: ::Storages::StorageError.new(code: :error))enddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rbindex 71b25846131..8f413f9a56e 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb@@ -48,9 +48,9 @@ module Storages::Peripherals::StorageInteraction::OneDrive::Utilend,on_failure: ->(_) doServiceResult.failure(- result: :not_authorized,+ result: :unauthorized,errors: ::Storages::StorageError.new(- code: :not_authorized,+ code: :unauthorized,log_message: 'Query could not be created! No access token found!'))diff --git a/modules/storages/spec/common/storages/peripherals/registry_spec.rb b/modules/storages/spec/common/storages/peripherals/registry_spec.rbindex ccbd089d6d1..2b598e8f245 100644--- a/modules/storages/spec/common/storages/peripherals/registry_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/registry_spec.rb@@ -120,10 +120,10 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doallow(instance).to receive(:get_access_token).and_return(ServiceResult.failure)end- it 'must return ":not_authorized" ServiceResult' do+ it 'must return ":unauthorized" ServiceResult' doresult = registry.resolve('queries.nextcloud.download_link').call(storage:, user:, file_link:)expect(result).to be_failure- expect(result.errors.code).to be(:not_authorized)+ expect(result.errors.code).to be(:unauthorized)endend@@ -132,10 +132,10 @@ RSpec.describe Storages::Peripherals::Registry, :webmock dostub_request(:post, "#{url}/ocs/v2.php/apps/dav/api/v1/direct").to_return(status: 200, body: '')end- it 'must return :not_authorized ServiceResult' do+ it 'must return :unauthorized ServiceResult' doresult = registry.resolve('queries.nextcloud.download_link').call(user:, file_link:, storage:)expect(result).to be_failure- expect(result.errors.code).to be(:not_authorized)+ expect(result.errors.code).to be(:unauthorized)endend@@ -154,7 +154,7 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doendinclude_examples 'outbound is failing', 404, :not_found- include_examples 'outbound is failing', 401, :not_authorized+ include_examples 'outbound is failing', 401, :unauthorizedinclude_examples 'outbound is failing', 500, :errorend@@ -266,10 +266,10 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doallow(instance).to receive(:get_access_token).and_return(ServiceResult.failure)end- it 'must return ":not_authorized" ServiceResult' do+ it 'must return ":unauthorized" ServiceResult' doresult = registry.resolve('queries.nextcloud.files').call(folder: parent, user:, storage:)expect(result).to be_failure- expect(result.errors.code).to be(:not_authorized)+ expect(result.errors.code).to be(:unauthorized)endendend@@ -289,7 +289,7 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doendinclude_examples 'outbound is failing', 404, :not_found- include_examples 'outbound is failing', 401, :not_authorized+ include_examples 'outbound is failing', 401, :unauthorizedinclude_examples 'outbound is failing', 500, :errorend@@ -339,10 +339,10 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doallow(instance).to receive(:get_access_token).and_return(ServiceResult.failure)end- it 'must return ":not_authorized" ServiceResult' do+ it 'must return ":unauthorized" ServiceResult' doresult = registry.resolve('queries.nextcloud.upload_link').call(storage:, user:, data: query_payload)expect(result).to be_failure- expect(result.errors.code).to be(:not_authorized)+ expect(result.errors.code).to be(:unauthorized)endend@@ -361,7 +361,7 @@ RSpec.describe Storages::Peripherals::Registry, :webmock doendinclude_examples 'outbound is failing', 400, :error- include_examples 'outbound is failing', 401, :not_authorized+ include_examples 'outbound is failing', 401, :unauthorizedinclude_examples 'outbound is failing', 404, :not_foundinclude_examples 'outbound is failing', 500, :errorenddiff --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 78beffc58b6..d40f992e679 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@@ -96,7 +96,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesInfoQuit 'must return an error when called' dosubject.call(user:, file_ids:).match(on_success: ->(file_infos) { fail "Expected failure, got #{file_infos}" },- on_failure: ->(error) { expect(error.code).to eq(:not_authorized) }+ on_failure: ->(error) { expect(error.code).to eq(:unauthorized) })endenddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rbindex 88623d72fb0..9434c35deac 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb@@ -118,8 +118,8 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,storage_files = described_class.call(storage:, user:, folder: nil)expect(storage_files).to be_failure- expect(storage_files.result).to eq(:not_authorized)- expect(storage_files.errors.to_s).to eq(Storages::StorageError.new(code: :not_authorized).to_s)+ expect(storage_files.result).to eq(:unauthorized)+ expect(storage_files.errors.to_s).to eq(Storages::StorageError.new(code: :unauthorized).to_s)endendenddiff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rbindex 36b513d9ff0..3f99c781ff3 100644--- a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb+++ b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb@@ -130,7 +130,7 @@ RSpec.describe 'API v3 file links resource' docontext 'when all embedded file link elements are valid' doit_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do- let(:elements) { Storages::FileLink.all.order(id: :asc) }+ let(:elements) { Storages::FileLink.order(id: :asc) }let(:expected_status_code) { 201 }end@@ -267,7 +267,7 @@ RSpec.describe 'API v3 file links resource' docontext 'when all embedded file link elements are valid' doit_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do- let(:elements) { Storages::FileLink.all.order(id: :asc) }+ let(:elements) { Storages::FileLink.order(id: :asc) }let(:expected_status_code) { 201 }end@@ -330,7 +330,7 @@ RSpec.describe 'API v3 file links resource' doendit_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do- let(:elements) { Storages::FileLink.all.order(id: :asc) }+ let(:elements) { Storages::FileLink.order(id: :asc) }let(:expected_status_code) { 201 }end@@ -354,7 +354,7 @@ RSpec.describe 'API v3 file links resource' doendit_behaves_like 'API V3 collection response', 3, 3, 'FileLink' do- let(:elements) { Storages::FileLink.all.order(id: :asc) }+ let(:elements) { Storages::FileLink.order(id: :asc) }let(:expected_status_code) { 201 }end@@ -580,7 +580,7 @@ RSpec.describe 'API v3 file links resource' doenddescribe 'due to authorization failure' do- let(:error) { :not_authorized }+ let(:error) { :unauthorized }it { expect(subject.status).to be(500) }enddiff --git a/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb b/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rbindex 5e019ef4b54..bb3ad7f2ce9 100644--- a/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb+++ b/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb@@ -139,7 +139,7 @@ RSpec.describe 'API v3 storage files', :webmock, content_type: :json doendcontext 'with authorization failure' do- let(:error) { :not_authorized }+ let(:error) { :unauthorized }it { expect(last_response.status).to be(500) }end@@ -291,7 +291,7 @@ RSpec.describe 'API v3 storage files', :webmock, content_type: :json doenddescribe 'due to authorization failure' do- let(:error) { :not_authorized }+ let(:error) { :unauthorized }it { expect(last_response.status).to be(500) }enddiff --git a/spec/services/oauth_clients/connection_manager_spec.rb b/spec/services/oauth_clients/connection_manager_spec.rbindex b0ed6dcfdd8..e6a4179cd92 100644--- a/spec/services/oauth_clients/connection_manager_spec.rb+++ b/spec/services/oauth_clients/connection_manager_spec.rb@@ -30,7 +30,7 @@require 'spec_helper'-RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true do+RSpec.describe OAuthClients::ConnectionManager, :webmock, type: :model dolet(:user) { create(:user) }let(:host) { "https://example.org" }@@ -145,7 +145,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true do# The callback endpoint calls `code_to_token(code)` with the code# received and exchanges the code for a bearer+refresh token# using a HTTP request.- describe '#code_to_token', webmock: true do+ describe '#code_to_token', :webmock dolet(:code) { "7kRGJ...jG3KZ" }subject { instance.code_to_token(code) }@@ -176,7 +176,9 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true docontext 'with known error' dobefore dostub_request(:post, File.join(host, '/index.php/apps/oauth2/api/v1/token'))- .to_return(status: 400, body: { error: error_message }.to_json, headers: { "content-type" => "application/json; charset=utf-8" })+ .to_return(status: 400,+ body: { error: error_message }.to_json,+ headers: { "content-type" => "application/json; charset=utf-8" })endshared_examples 'OAuth2 error response' do@@ -204,7 +206,9 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true docontext 'with known reply invalid_grant' dobefore dostub_request(:post, File.join(host, '/index.php/apps/oauth2/api/v1/token'))- .to_return(status: 400, body: { error: "invalid_grant" }.to_json, headers: { "content-type" => "application/json; charset=utf-8" })+ .to_return(status: 400,+ body: { error: "invalid_grant" }.to_json,+ headers: { "content-type" => "application/json; charset=utf-8" })endit 'returns a specific error message' do@@ -218,7 +222,9 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true docontext 'with unknown reply' dobefore dostub_request(:post, File.join(host, '/index.php/apps/oauth2/api/v1/token'))- .to_return(status: 400, body: { error: "invalid_requesttt" }.to_json, headers: { "content-type" => "application/json; charset=utf-8" })+ .to_return(status: 400,+ body: { error: "invalid_requesttt" }.to_json,+ headers: { "content-type" => "application/json; charset=utf-8" })endit 'returns an unspecific error message' do@@ -334,7 +340,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true do.to_return(status: 200, body: response_body, headers: { "content-type" => "application/json; charset=utf-8" })end- it 'returns a valid ClientToken object', webmock: true do+ it 'returns a valid ClientToken object', :webmock doexpect(subject.success).to be_truthyexpect(subject.result).to be_a OAuthClientTokenexpect(subject.result.access_token).to eq("xyjTDZ...RYvRH")@@ -357,7 +363,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true do.to_return(status: 200, body: response_body, headers: { "content-type" => "application/json; charset=utf-8" })end- it 'returns dependent error from model validation', webmock: true do+ it 'returns dependent error from model validation', :webmock doexpect(subject.success).to be_falseyexpect(subject.errors.size).to be(1)end@@ -366,10 +372,12 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true docontext 'with server error from OAuth2 provider' dobefore dostub_request(:any, File.join(host, '/index.php/apps/oauth2/api/v1/token'))- .to_return(status: 400, body: { error: "invalid_request" }.to_json, headers: { "content-type" => "application/json; charset=utf-8" })+ .to_return(status: 400,+ body: { error: "invalid_request" }.to_json,+ headers: { "content-type" => "application/json; charset=utf-8" })end- it 'returns a server error', webmock: true do+ it 'returns a server error', :webmock doexpect(subject.success).to be_falseyexpect(subject.errors.size).to be(1)end@@ -382,7 +390,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true do.to_timeoutend- it 'returns a valid ClientToken object', webmock: true do+ it 'returns a valid ClientToken object', :webmock doexpect(subject.success).to be_falseyexpect(subject.result).to eq("execution expired")expect(subject.errors.size).to be(1)@@ -445,9 +453,10 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doresponse_body2 = response_body1.dupresponse_body2[:access_token] = "differ...RYvRH"request_url = File.join(host, '/index.php/apps/oauth2/api/v1/token')+ headers = { "content-type" => "application/json; charset=utf-8" }stub_request(:any, request_url)- .to_return(status: 200, body: response_body1.to_json, headers: { "content-type" => "application/json; charset=utf-8" }).then- .to_return(status: 200, body: response_body2.to_json, headers: { "content-type" => "application/json; charset=utf-8" })+ .to_return(status: 200, body: response_body1.to_json, headers:).then+ .to_return(status: 200, body: response_body2.to_json, headers:)result1 = nilresult2 = nil@@ -473,7 +482,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doendcontext 'when token is fresh' do- it 'does not send refresh request and respond with existing token', webmock: true do+ it 'does not send refresh request and respond with existing token', :webmock doexpect(subject.success).to be_truthyexpect(subject.result).to eq(oauth_client_token)expect { subject }.not_to change(oauth_client_token, :access_token)@@ -491,7 +500,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doendend- context 'with access token present', webmock: true do+ context 'with access token present', :webmock dobefore dooauth_client_tokenend@@ -554,7 +563,7 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doendend- context 'with both invalid access token and refresh token', webmock: true do+ context 'with both invalid access token and refresh token', :webmock doit 'returns :failed_authorization' doexpect(subject).to eq :failed_authorizationend@@ -593,19 +602,19 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doendend- context 'with yield returning :not_authorized and the refresh returning a with a success' do- let(:yield_service_result) { ServiceResult.failure(result: :not_authorized) }+ context 'with yield returning :unauthorized and the refresh returning a with a success' do+ let(:yield_service_result) { ServiceResult.failure(result: :unauthorized) }it 'returns a ServiceResult with success, without refresh' doexpect(subject.success).to be_falsey- expect(subject.result).to be :not_authorized+ expect(subject.result).to be :unauthorizedexpect(instance).to have_received(:refresh_token)expect(oauth_client_token).to have_received(:reload)endend- context 'with yield returning :not_authorized and the refresh returning with a :failure' do- let(:yield_service_result) { ServiceResult.failure(result: :not_authorized) }+ context 'with yield returning :unauthorized and the refresh returning with a :failure' do+ let(:yield_service_result) { ServiceResult.failure(result: :unauthorized) }let(:refresh_service_result) { ServiceResult.failure }it 'returns a ServiceResult with success, without refresh' do@@ -616,9 +625,9 @@ RSpec.describe OAuthClients::ConnectionManager, type: :model, webmock: true doendend- context 'with yield returning :not_authorized first time and :success the second time' do+ context 'with yield returning :unauthorized first time and :success the second time' dolet(:yield_double_object) { Object.new }- let(:yield_service_result1) { ServiceResult.failure(result: :not_authorized) }+ let(:yield_service_result1) { ServiceResult.failure(result: :unauthorized) }let(:yield_service_result2) { ServiceResult.success }let(:refresh_service_result) { ServiceResult.success }