diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb index c275c310b732..72047520c102 100644 --- a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb +++ b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb @@ -61,7 +61,7 @@ def validate def capabilities @capabilities ||= Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.capabilities") + .resolve("#{@storage}.queries.capabilities") .call(storage: @storage, auth_strategy: noop) end diff --git a/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb b/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb index 478ca840985c..911f8280f51c 100644 --- a/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb +++ b/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb @@ -57,7 +57,7 @@ def validate def query @query ||= Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.files") + .resolve("#{@storage}.queries.files") .call(storage: @storage, auth_strategy:, folder: root_folder) end @@ -173,7 +173,7 @@ def root_folder end def auth_strategy - Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.userless") + Peripherals::Registry.resolve("#{@storage}.authentication.userless") .call .with_cache(false) end diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb index 364f52427046..28617553f9c2 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb @@ -58,7 +58,7 @@ def self.authorization_state(storage:, user:) auth_strategy = AuthenticationStrategies::OAuthUserToken.strategy.with_user(user) Registry - .resolve("#{storage.short_provider_type}.queries.auth_check") + .resolve("#{storage}.queries.auth_check") .call(storage:, auth_strategy:) .match( on_success: ->(*) { :connected }, diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb index 0f8d107db56c..500628a42f38 100644 --- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb +++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb @@ -8,7 +8,7 @@ ) do |form| flex_layout do |oauth_client_row| oauth_client_row.with_row(mb: 3) do - render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") } + render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.file_storage_view.#{storage}_oauth") } end oauth_client_row.with_row(mb: 3) do diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb index db9ee4cf6d34..d2fda9355e96 100644 --- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb +++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb @@ -52,8 +52,8 @@ def cancel_button_path end def storage_provider_credentials_instructions - I18n.t("storages.instructions.#{storage.short_provider_type}.oauth_configuration", - application_link_text: send(:"#{storage.short_provider_type}_integration_link")).html_safe + I18n.t("storages.instructions.#{storage}.oauth_configuration", + application_link_text: send(:"#{storage}_integration_link")).html_safe end private diff --git a/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb b/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb index d6c7f7493413..04c67a9394bb 100644 --- a/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb +++ b/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb @@ -5,7 +5,7 @@ concat( render( Primer::Beta::Text.new(font_weight: :bold, mr: 1, test_selector: 'storage-oauth-client-label') - ) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") } + ) { I18n.t("storages.file_storage_view.#{storage}_oauth") } ) concat(configuration_check_label_for(:storage_oauth_client_configured)) end diff --git a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb index 71e3bbc37596..b4379d32cf89 100644 --- a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb +++ b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb @@ -46,7 +46,7 @@ def self.wrapper_key = :storage_oauth_client_section def edit_icon_button_options label = I18n.t("storages.buttons.replace_oauth_client", - provider_type: I18n.t("storages.provider_types.#{storage.short_provider_type}.name")) + provider_type: I18n.t("storages.provider_types.#{storage}.name")) { icon: oauth_client_configured? ? :sync : :pencil, @@ -64,7 +64,7 @@ def edit_icon_button_options def edit_icon_button_data_options {}.tap do |data_h| if oauth_client_configured? - provider_type = I18n.t("storages.provider_types.#{storage.short_provider_type}.name") + provider_type = I18n.t("storages.provider_types.#{storage}.name") data_h[:turbo_confirm] = I18n.t("storages.confirm_replace_oauth_client", provider_type:) end data_h[:turbo_stream] = true diff --git a/modules/storages/app/components/storages/admin/storage_row_component.html.erb b/modules/storages/app/components/storages/admin/storage_row_component.html.erb index ce9eaea2a5b6..d44b4819eb27 100644 --- a/modules/storages/app/components/storages/admin/storage_row_component.html.erb +++ b/modules/storages/app/components/storages/admin/storage_row_component.html.erb @@ -21,7 +21,7 @@ end grid.with_area(:provider, tag: :div, color: :subtle, mr: 3, hide: :sm, data: { 'test-selector': 'storage-provider' }) do - render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t("storages.provider_types.#{storage.short_provider_type}.name") } + render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t("storages.provider_types.#{storage}.name") } end grid.with_area(:time, tag: :div, color: :subtle) do diff --git a/modules/storages/app/components/storages/admin/storage_view_information.rb b/modules/storages/app/components/storages/admin/storage_view_information.rb index baf91d6b529e..d019b95d3835 100644 --- a/modules/storages/app/components/storages/admin/storage_view_information.rb +++ b/modules/storages/app/components/storages/admin/storage_view_information.rb @@ -1,5 +1,33 @@ # frozen_string_literal: true +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + module Storages::Admin module StorageViewInformation private @@ -9,7 +37,7 @@ def editable_storage? end def storage_description - [I18n.t("storages.provider_types.#{storage.short_provider_type}.name"), + [I18n.t("storages.provider_types.#{storage}.name"), storage.name, storage.host].compact.join(" - ") end @@ -62,7 +90,7 @@ def provider_oauth_client_description if storage.oauth_client "#{I18n.t('storages.label_oauth_client_id')}: #{storage.oauth_client.client_id}" else - I18n.t("storages.configuration_checks.oauth_client_incomplete.#{storage.short_provider_type}") + I18n.t("storages.configuration_checks.oauth_client_incomplete.#{storage}") end end @@ -70,7 +98,7 @@ def provider_redirect_uri_description if storage.oauth_client "#{I18n.t('storages.label_uri')}: #{storage.oauth_client.redirect_uri}" else - I18n.t("storages.configuration_checks.redirect_uri_incomplete.#{storage.short_provider_type}") + I18n.t("storages.configuration_checks.redirect_uri_incomplete.#{storage}") end end end diff --git a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb index f879ab909b11..23cc88b340d1 100644 --- a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb +++ b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb @@ -57,7 +57,7 @@ def heading_text = I18n.t("storages.oauth_grant_nudge_modal.heading", provider_t def waiting_title = I18n.t("storages.oauth_grant_nudge_modal.requesting_access_to", storage: storage.name) def cancel_button_text = I18n.t(:button_close) def body_text = I18n.t("storages.oauth_grant_nudge_modal.storage_admin.description", provider_type:) - def provider_type = I18n.t("storages.provider_types.#{storage.short_provider_type}.name") + def provider_type = I18n.t("storages.provider_types.#{storage}.name") def login_button_aria_label I18n.t("storages.oauth_grant_nudge_modal.login_button_aria_label", storage: storage.name) diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component.rb b/modules/storages/app/components/storages/open_project_storage_modal_component.rb index 9ad4d22c8981..7af3c0811d76 100644 --- a/modules/storages/app/components/storages/open_project_storage_modal_component.rb +++ b/modules/storages/app/components/storages/open_project_storage_modal_component.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # # This program is free software; you can redistribute it and/or diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb index 583760190f1e..880848165a17 100644 --- a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb +++ b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # # This program is free software; you can redistribute it and/or @@ -24,7 +28,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -class Storages::OpenProjectStorageModalComponent::Body < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent +class Storages::OpenProjectStorageModalComponent::Body < ApplicationComponent options success_title: I18n.t("storages.open_project_storage_modal.success.title"), success_subtitle: I18n.t("storages.open_project_storage_modal.success.subtitle"), waiting_title: I18n.t("storages.open_project_storage_modal.waiting.title"), diff --git a/modules/storages/app/contracts/storages/storages/base_contract.rb b/modules/storages/app/contracts/storages/storages/base_contract.rb index 24180cddf275..9ba945989d20 100644 --- a/modules/storages/app/contracts/storages/storages/base_contract.rb +++ b/modules/storages/app/contracts/storages/storages/base_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/create_contract.rb b/modules/storages/app/contracts/storages/storages/create_contract.rb index d387a435fcb0..f884f3e90442 100644 --- a/modules/storages/app/contracts/storages/storages/create_contract.rb +++ b/modules/storages/app/contracts/storages/storages/create_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb index 88f9089d3e08..7f718f7e9d5e 100644 --- a/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb +++ b/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb index 76fd7a62b0b7..b23554409441 100644 --- a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb +++ b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/update_contract.rb b/modules/storages/app/contracts/storages/storages/update_contract.rb index e78ff523ff6f..1345ed147a6a 100644 --- a/modules/storages/app/contracts/storages/storages/update_contract.rb +++ b/modules/storages/app/contracts/storages/storages/update_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/controllers/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/project_storages_controller.rb index 36aab106ef62..cb3b738e4d37 100644 --- a/modules/storages/app/controllers/storages/project_storages_controller.rb +++ b/modules/storages/app/controllers/storages/project_storages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -45,7 +47,7 @@ def open # check if user "see" project_folder if @object.project_folder_id.present? ::Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.file_info") + .resolve("#{@storage}.queries.file_info") .call(storage: @storage, auth_strategy:, file_id: @object.project_folder_id) .match( on_success: user_can_read_project_folder, diff --git a/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb b/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb index 429342b5800d..4e2609a2fc06 100644 --- a/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb +++ b/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -58,7 +60,7 @@ def provider_type_link href: Storages::UrlBuilder.url(@storage.uri, "settings/admin/openproject"), target: "_blank" ) - ) { I18n.t("storages.instructions.#{@storage.short_provider_type}.integration") } + ) { I18n.t("storages.instructions.#{@storage}.integration") } end end end diff --git a/modules/storages/app/forms/storages/admin/oauth_client_form.rb b/modules/storages/app/forms/storages/admin/oauth_client_form.rb index 35a61299b595..58ce31a07e3d 100644 --- a/modules/storages/app/forms/storages/admin/oauth_client_form.rb +++ b/modules/storages/app/forms/storages/admin/oauth_client_form.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -69,11 +71,11 @@ def provider_default_client_secret_input_options end def label_client_id - I18n.t("storages.provider_types.#{@storage.short_provider_type}.label_oauth_client_id") + I18n.t("storages.provider_types.#{@storage}.label_oauth_client_id") end def label_client_secret - I18n.t("storages.provider_types.#{@storage.short_provider_type}.label_oauth_client_secret") + I18n.t("storages.provider_types.#{@storage}.label_oauth_client_secret") end end end diff --git a/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb b/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb index 8b6d563d43e4..b1c620aad78f 100644 --- a/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb +++ b/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # @@ -26,7 +26,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # See COPYRIGHT and LICENSE files for more details. -# ++ +#++ # # This filter is used to find projects (including archived projects) that use one diff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rb index 72ff63a3f5ff..5eee6413f308 100644 --- a/modules/storages/app/models/storages/project_storage.rb +++ b/modules/storages/app/models/storages/project_storage.rb @@ -88,11 +88,11 @@ def open(user) if project_folder_not_accessible?(user) Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.open_storage") + .resolve("#{storage}.queries.open_storage") .call(storage:, auth_strategy:) else Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.open_file_link") + .resolve("#{storage}.queries.open_file_link") .call(storage:, auth_strategy:, file_id: project_folder_id) end end @@ -118,7 +118,7 @@ def open_with_connection_ensured def managed_folder_identifier @managed_folder_identifier ||= - Peripherals::Registry.resolve("#{storage.short_provider_type}.models.managed_folder_identifier").new(self) + Peripherals::Registry.resolve("#{storage}.models.managed_folder_identifier").new(self) end def project_folder_not_accessible?(user) diff --git a/modules/storages/app/services/storages/oauth_applications/create_service.rb b/modules/storages/app/services/storages/oauth_applications/create_service.rb index 76120a879a87..e8c19d757ce8 100644 --- a/modules/storages/app/services/storages/oauth_applications/create_service.rb +++ b/modules/storages/app/services/storages/oauth_applications/create_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -45,7 +47,7 @@ def call ::OAuth::Applications::CreateService .new(user:) .call( - name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage.short_provider_type}.name")})", + name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage}.name")})", redirect_uri: File.join(storage.host, "index.php/apps/integration_openproject/oauth-redirect"), scopes: "api_v3", confidential: true, diff --git a/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb b/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb index de5059ca198f..3b3e4caae62e 100644 --- a/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb +++ b/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb @@ -74,7 +74,7 @@ def manually_managed_source?(source) def initiate_copy(storage, source_path, destination_path) Peripherals::Registry - .resolve("#{storage.short_provider_type}.commands.copy_template_folder") + .resolve("#{storage}.commands.copy_template_folder") .call(auth_strategy: auth_strategy(storage.short_provider_type), storage:, source_path:, diff --git a/modules/storages/app/services/storages/storage_file_service.rb b/modules/storages/app/services/storages/storage_file_service.rb new file mode 100644 index 000000000000..6b664d92f1a5 --- /dev/null +++ b/modules/storages/app/services/storages/storage_file_service.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +module Storages + class StorageFileService < BaseService + def self.call(storage:, user:, file_id:) + new.call(storage:, user:, file_id:) + end + + def call(user:, storage:, file_id:) + auth_strategy = strategy(storage, user) + + info "Requesting file #{file_id} information on #{storage.name}" + Peripherals::Registry.resolve("#{storage}.queries.file_info").call(storage:, auth_strategy:, file_id:) + end + + private + + def strategy(storage, user) + Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user:) + end + end +end diff --git a/modules/storages/app/services/storages/storage_files_service.rb b/modules/storages/app/services/storages/storage_files_service.rb new file mode 100644 index 000000000000..ce4ab8f9a4bc --- /dev/null +++ b/modules/storages/app/services/storages/storage_files_service.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +module Storages + class StorageFilesService < BaseService + def self.call(storage:, user:, folder:) + new.call(storage:, user:, folder:) + end + + def call(user:, storage:, folder:) + auth_strategy = strategy(storage, user) + + info "Requesting all the files under folder #{folder} for #{storage.name}" + Peripherals::Registry.resolve("#{storage}.queries.files").call(storage:, auth_strategy:, folder:) + end + + private + + def strategy(storage, user) + Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user:) + end + end +end diff --git a/modules/storages/app/services/storages/storages/update_service.rb b/modules/storages/app/services/storages/storages/update_service.rb index efa30027ebbd..7f50b94f2ddd 100644 --- a/modules/storages/app/services/storages/storages/update_service.rb +++ b/modules/storages/app/services/storages/storages/update_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -32,7 +34,7 @@ class UpdateService < ::BaseServices::Update protected def after_perform(service_call) - super(service_call) + super storage = service_call.result if storage.provider_type_nextcloud? @@ -40,7 +42,7 @@ def after_perform(service_call) persist_service_result = ::OAuth::Applications::UpdateService .new(model: application, user:) .call( - name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage.short_provider_type}.name")})", + name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage}.name")})", redirect_uri: File.join(storage.host, "index.php/apps/integration_openproject/oauth-redirect") ) service_call.add_dependent!(persist_service_result) diff --git a/modules/storages/app/services/storages/upload_link_service.rb b/modules/storages/app/services/storages/upload_link_service.rb index 012b5c8433d7..dfc4b7017e3f 100644 --- a/modules/storages/app/services/storages/upload_link_service.rb +++ b/modules/storages/app/services/storages/upload_link_service.rb @@ -56,7 +56,7 @@ def call(user:, upload_data:) private def request_upload_link(auth_strategy, upload_data) - Peripherals::Registry.resolve("#{@storage.short_provider_type}.queries.upload_link") + Peripherals::Registry.resolve("#{@storage}.queries.upload_link") .call(storage: @storage, auth_strategy:, upload_data:) .on_failure do |error| add_error(:base, error.errors, options: { storage_name: @storage.name, folder: upload_data.folder_id }) @@ -74,7 +74,7 @@ def validate_input(...) end def auth_strategy(user) - Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.user_bound").call(user:) + Peripherals::Registry.resolve("#{@storage}.authentication.user_bound").call(user:) end end end diff --git a/modules/storages/app/views/storages/admin/storages/_new.html.erb b/modules/storages/app/views/storages/admin/storages/_new.html.erb index 37eabdfb3c99..3c315c263f29 100644 --- a/modules/storages/app/views/storages/admin/storages/_new.html.erb +++ b/modules/storages/app/views/storages/admin/storages/_new.html.erb @@ -55,7 +55,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= f.text_field :name, required: true, - placeholder: I18n.t("storages.provider_types.#{@storage.short_provider_type}.name_placeholder"), + placeholder: I18n.t("storages.provider_types.#{@storage}.name_placeholder"), container_class: '-slim', data: { 'storages--storage-form-target': 'storageName' diff --git a/modules/storages/app/views/storages/admin/storages/new.html.erb b/modules/storages/app/views/storages/admin/storages/new.html.erb index 53997a99e87e..487a108c1982 100644 --- a/modules/storages/app/views/storages/admin/storages/new.html.erb +++ b/modules/storages/app/views/storages/admin/storages/new.html.erb @@ -1,7 +1,7 @@ <% label_new_file_storage = t("storages.label_new_file_storage", - provider: t("storages.provider_types.#{@storage.short_provider_type}.name")) + provider: t("storages.provider_types.#{@storage}.name")) %> <% html_title t(:label_administration), t("project_module_storages"), label_new_file_storage %> @@ -18,8 +18,8 @@ <% header.with_description(test_selector: 'storage-new-page-header--description') do %> <%= t("storages.instructions.new_storage", - provider_link: ::OpenProject::Static::Links[:storage_docs][:"#{@storage.short_provider_type}_setup"][:href].html_safe, - provider_name: I18n.t("storages.provider_types.#{@storage.short_provider_type}.name") + provider_link: ::OpenProject::Static::Links[:storage_docs][:"#{@storage}_setup"][:href].html_safe, + provider_name: I18n.t("storages.provider_types.#{@storage}.name") ).html_safe %> <% end %> diff --git a/modules/storages/app/views/storages/admin/storages/update.turbo_stream.erb b/modules/storages/app/views/storages/admin/storages/update.turbo_stream.erb index e2ca4d7006e4..66c5f17c4d61 100644 --- a/modules/storages/app/views/storages/admin/storages/update.turbo_stream.erb +++ b/modules/storages/app/views/storages/admin/storages/update.turbo_stream.erb @@ -1,6 +1,6 @@ <% label_storage_provider_part = render(Primer::Beta::Text.new(tag: :span, font_weight: :light, color: :muted)) do - "(#{I18n.t("storages.provider_types.#{@storage.short_provider_type}.name")})" + "(#{I18n.t("storages.provider_types.#{@storage}.name")})" end label_storage_name_with_provider_label = "#{@storage.name} #{label_storage_provider_part}".html_safe %> diff --git a/modules/storages/app/views/storages/project_settings/_storage_select_form.html.erb b/modules/storages/app/views/storages/project_settings/_storage_select_form.html.erb index c245e35e4bee..08d265290ba2 100644 --- a/modules/storages/app/views/storages/project_settings/_storage_select_form.html.erb +++ b/modules/storages/app/views/storages/project_settings/_storage_select_form.html.erb @@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= f.select :storage_id, - @available_storages.map { |storage| ["#{storage.name} (#{storage.short_provider_type})", storage.id] }, + @available_storages.map { |storage| ["#{storage.name} (#{storage})", storage.id] }, class: '-bold', selected: @available_storages.first.id.to_s, container_class: '-slim' diff --git a/modules/storages/app/views/storages/storages_mailer/_health_status_notification.html.erb b/modules/storages/app/views/storages/storages_mailer/_health_status_notification.html.erb index 1e05c21b44c1..220df2dcb493 100644 --- a/modules/storages/app/views/storages/storages_mailer/_health_status_notification.html.erb +++ b/modules/storages/app/views/storages/storages_mailer/_health_status_notification.html.erb @@ -47,7 +47,7 @@ See COPYRIGHT and LICENSE files for more details. <%= placeholder_cell('8px', vertical: true) %> - <%= I18n.t("storages.provider_types.#{storage.short_provider_type}.name") %> - <%= storage.uri %> + <%= I18n.t("storages.provider_types.#{storage}.name") %> - <%= storage.uri %> diff --git a/modules/storages/app/views/storages/storages_mailer/notify_healthy.text.erb b/modules/storages/app/views/storages/storages_mailer/notify_healthy.text.erb index 488f0c42d536..7aa05229ab5d 100644 --- a/modules/storages/app/views/storages/storages_mailer/notify_healthy.text.erb +++ b/modules/storages/app/views/storages/storages_mailer/notify_healthy.text.erb @@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details. <%= I18n.t('mail.storages.health.plaintext.healthy.summary', storage_name: @storage.name) %> -<%= I18n.t('mail.storages.health.plaintext.storage') %>: <%= I18n.t("storages.provider_types.#{@storage.short_provider_type}.name") %> - <%= @storage.host %> +<%= I18n.t('mail.storages.health.plaintext.storage') %>: <%= I18n.t("storages.provider_types.#{@storage}.name") %> - <%= @storage.host %> <%= I18n.t('mail.storages.health.plaintext.unhealthy.error-details') %>: <%= "-" * 30 %> diff --git a/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.text.erb b/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.text.erb index 57c232ae5364..ae03895cc21f 100644 --- a/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.text.erb +++ b/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.text.erb @@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details. <%= I18n.t('mail.storages.health.plaintext.unhealthy.summary', storage_name: @storage.name) %> -<%= I18n.t('mail.storages.health.plaintext.storage') %>: <%= I18n.t("storages.provider_types.#{@storage.short_provider_type}.name") %> - <%= @storage.host %> +<%= I18n.t('mail.storages.health.plaintext.storage') %>: <%= I18n.t("storages.provider_types.#{@storage}.name") %> - <%= @storage.host %> <%= I18n.t('mail.storages.health.plaintext.unhealthy.error-details') %>: <%= "-" * 30 %> diff --git a/modules/storages/app/workers/storages/automatically_managed_storage_sync_job.rb b/modules/storages/app/workers/storages/automatically_managed_storage_sync_job.rb index ecd7544675cf..801518c2c15f 100644 --- a/modules/storages/app/workers/storages/automatically_managed_storage_sync_job.rb +++ b/modules/storages/app/workers/storages/automatically_managed_storage_sync_job.rb @@ -52,7 +52,7 @@ class AutomaticallyManagedStorageSyncJob < ApplicationJob end end - def self.key(storage) = "sync-#{storage.short_provider_type}-#{storage.id}" + def self.key(storage) = "sync-#{storage}-#{storage.id}" def perform(storage) return unless storage.configured? && storage.automatically_managed? diff --git a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb index 9cb8f73d9c06..e57499758623 100644 --- a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb +++ b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb @@ -57,17 +57,14 @@ def fetch_upload_link end def auth_strategy - Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.authentication.user_bound") - .call(user: current_user) + Storages::Peripherals::Registry.resolve("#{@storage}.authentication.user_bound").call(user: current_user) end end resources :files do get do - Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.files") - .call(storage: @storage, auth_strategy:, folder: extract_parent_folder(params)) + Storages::StorageFilesService + .call(storage: @storage, user: current_user, folder: extract_parent_folder(params)) .match( on_success: ->(files) { API::V3::StorageFiles::StorageFilesRepresenter.new(files, @storage, current_user:) }, on_failure: ->(error) { raise_error(error) } @@ -76,9 +73,8 @@ def auth_strategy route_param :file_id, type: String, desc: "Storage file id" do get do - Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.file_info") - .call(storage: @storage, auth_strategy:, file_id: params[:file_id]) + Storages::StorageFileService + .call(storage: @storage, user: current_user, file_id: params[:file_id]) .map { |file_info| to_storage_file(file_info) } .match( on_success: lambda { |storage_file| diff --git a/modules/storages/lib/api/v3/storages/storage_open_api.rb b/modules/storages/lib/api/v3/storages/storage_open_api.rb index 752f3fadc6b3..937c33ba6015 100644 --- a/modules/storages/lib/api/v3/storages/storage_open_api.rb +++ b/modules/storages/lib/api/v3/storages/storage_open_api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -38,7 +40,7 @@ class API::V3::Storages::StorageOpenAPI < API::OpenProjectAPI .with_user(current_user) Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.open_storage") + .resolve("#{@storage}.queries.open_storage") .call(storage: @storage, auth_strategy:) .match( on_success: ->(url) do diff --git a/modules/storages/lib/openproject-storages.rb b/modules/storages/lib/openproject-storages.rb index 0b8622e544c5..bcc8556dbe2d 100644 --- a/modules/storages/lib/openproject-storages.rb +++ b/modules/storages/lib/openproject-storages.rb @@ -1,3 +1,33 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + # The module follows a structure similar to gems. # The name 'openproject-storages' was set with the open_project:plugin generator. # The OpenProject plugins, located in modules/, are defined in `Gemfile.modules`. diff --git a/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb b/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb index f9ddf0a3b403..b34027fbb671 100644 --- a/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb +++ b/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -31,7 +33,7 @@ RSpec.describe Storages::Peripherals::NextcloudConnectionValidator do before do - Storages::Peripherals::Registry.stub("#{storage.short_provider_type}.queries.capabilities", ->(_) { capabilities_response }) + Storages::Peripherals::Registry.stub("#{storage}.queries.capabilities", ->(_) { capabilities_response }) Storages::Peripherals::Registry.stub("#{storage.short_provider_type}.queries.files", ->(_) { files_response }) end diff --git a/modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb b/modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb index 07a1ee456f89..26bdc47292bc 100644 --- a/modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb +++ b/modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -33,7 +35,7 @@ let(:storage) { create(:one_drive_storage, oauth_client: create(:oauth_client)) } before do - Storages::Peripherals::Registry.stub("#{storage.short_provider_type}.queries.files", ->(_) { response }) + Storages::Peripherals::Registry.stub("#{storage}.queries.files", ->(_) { response }) end subject { described_class.new(storage:).validate } diff --git a/modules/storages/spec/features/create_file_links_spec.rb b/modules/storages/spec/features/create_file_links_spec.rb index d6feb7a9f8af..5dac613cef50 100644 --- a/modules/storages/spec/features/create_file_links_spec.rb +++ b/modules/storages/spec/features/create_file_links_spec.rb @@ -63,7 +63,7 @@ allow(Storages::FileLinkSyncService).to receive(:new).and_return(sync_service) Storages::Peripherals::Registry.stub( - "#{storage.short_provider_type}.queries.auth_check", + "#{storage}.queries.auth_check", ->(_) { ServiceResult.success } ) diff --git a/modules/storages/spec/features/manage_project_storage_spec.rb b/modules/storages/spec/features/manage_project_storage_spec.rb index a13d14e31129..2acbb325d66e 100644 --- a/modules/storages/spec/features/manage_project_storage_spec.rb +++ b/modules/storages/spec/features/manage_project_storage_spec.rb @@ -97,7 +97,7 @@ expect(page).to have_current_path new_project_settings_project_storage_path(project_id: project) expect(page).to have_text("Add a file storage") expect(page).to have_select("storages_project_storage_storage_id", - options: ["#{storage.name} (#{storage.short_provider_type})"]) + options: ["#{storage.name} (#{storage})"]) page.click_on("Continue") # by default automatic have to be choosen if storage has automatic management enabled diff --git a/modules/storages/spec/features/show_file_links_spec.rb b/modules/storages/spec/features/show_file_links_spec.rb index e6c4445003cc..74562ff1520d 100644 --- a/modules/storages/spec/features/show_file_links_spec.rb +++ b/modules/storages/spec/features/show_file_links_spec.rb @@ -49,7 +49,7 @@ before do Storages::Peripherals::Registry.stub( - "#{storage.short_provider_type}.queries.auth_check", + "#{storage}.queries.auth_check", ->(_) { authorization_state } ) diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb index dcafe17a51c8..ffc4b5ab7bec 100644 --- a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb +++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb @@ -41,7 +41,7 @@ before do Storages::Peripherals::Registry.stub( - "#{storage.short_provider_type}.queries.auth_check", + "#{storage}.queries.auth_check", ->(_) { auth_check_result } ) end diff --git a/modules/storages/spec/mailers/storages/storages_mailer_spec.rb b/modules/storages/spec/mailers/storages/storages_mailer_spec.rb index a58bd8cf07f5..986022334fc1 100644 --- a/modules/storages/spec/mailers/storages/storages_mailer_spec.rb +++ b/modules/storages/spec/mailers/storages/storages_mailer_spec.rb @@ -1,4 +1,35 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + require "rails_helper" +require_module_spec_helper RSpec.describe Storages::StoragesMailer do let(:admin) { build_stubbed(:admin) } diff --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.rb index 4f5d4265c118..049ae17fb7d0 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 @@ -43,14 +43,14 @@ end let(:oauth_application) { create(:oauth_application) } - let(:storage) { create(:nextcloud_storage, creator: current_user, oauth_application:) } + let(:storage) { create(:nextcloud_storage_configured, creator: current_user, oauth_application:) } + let(:oauth_token) { create(:oauth_client_token, user: current_user, oauth_client: storage.oauth_client) } let(:project_storage) { create(:project_storage, project:, storage:) } - subject(:last_response) do - get path - end + subject(:last_response) { get path } before do + oauth_application project_storage login_as current_user end @@ -205,12 +205,9 @@ context "with query failed" do before do - clazz = Storages::Peripherals::StorageInteraction::Nextcloud::FileInfoQuery - instance = instance_double(clazz) - allow(clazz).to receive(:new).and_return(instance) - allow(instance).to receive(:call).and_return( - ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error)) - ) + Storages::Peripherals::Registry + .stub("#{storage}.queries.file_info", + ->(_) { ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error)) }) end context "with authorization failure" do diff --git a/modules/storages/spec/services/storages/oauth_applications/create_service_spec.rb b/modules/storages/spec/services/storages/oauth_applications/create_service_spec.rb index c8aa5522765d..41b0b9ddae11 100644 --- a/modules/storages/spec/services/storages/oauth_applications/create_service_spec.rb +++ b/modules/storages/spec/services/storages/oauth_applications/create_service_spec.rb @@ -46,7 +46,7 @@ expect(subject).to be_success expect(subject.result).to be_a Doorkeeper::Application expect(subject.result.name).to include storage.name - expect(subject.result.name).to include I18n.t("storages.provider_types.#{storage.short_provider_type}.name") + expect(subject.result.name).to include I18n.t("storages.provider_types.#{storage}.name") expect(subject.result.scopes.to_s).to eql "api_v3" expect(subject.result.redirect_uri).to include storage.host expect(subject.result.redirect_uri).to include "apps/integration_openproject/oauth-redirect" diff --git a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb index 10f3980ee4f0..478abae6cdcb 100644 --- a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb +++ b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb @@ -39,7 +39,7 @@ before do Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.commands.delete_folder", command_double) + .stub("#{storage}.commands.delete_folder", command_double) end context "if project folder mode is set to automatic" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/create_folder_command_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/create_folder_command_examples.rb index 86ba8fe62a9d..7c68f2cc7626 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/create_folder_command_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/create_folder_command_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "create_folder_command: basic command setup" do it "is registered as commands.create_folder" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.commands.create_folder")).to eq(described_class) + .resolve("#{storage}.commands.create_folder")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/file_info_query_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/file_info_query_examples.rb index e0777b059094..df8cbe493e47 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/file_info_query_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/file_info_query_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "file_info_query: basic query setup" do it "is registered as queries.file_info" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.file_info")).to eq(described_class) + .resolve("#{storage}.queries.file_info")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/file_path_to_id_map_query_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/file_path_to_id_map_query_examples.rb index 6abec5e19218..6d84b31c2a76 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/file_path_to_id_map_query_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/file_path_to_id_map_query_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "file_path_to_id_map_query: basic query setup" do it "is registered as queries.file_path_to_id_map" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.file_path_to_id_map")).to eq(described_class) + .resolve("#{storage}.queries.file_path_to_id_map")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/files_query_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/files_query_examples.rb index 7e68098f9c59..17a156294278 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/files_query_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/files_query_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "files_query: basic query setup" do it "is registered as queries.files" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.files")).to eq(described_class) + .resolve("#{storage}.queries.files")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb index 3fc9d4e55a70..1f71426f20c0 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "rename_file_command: basic command setup" do it "is registered as commands.rename_file" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.commands.rename_file")).to eq(described_class) + .resolve("#{storage}.commands.rename_file")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/set_permissions_command_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/set_permissions_command_examples.rb index d6e7926d906d..2e423ea664e9 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/set_permissions_command_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/set_permissions_command_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "set_permissions_command: basic command setup" do it "is registered as commands.set_permissions" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.commands.set_permissions")).to eq(described_class) + .resolve("#{storage}.commands.set_permissions")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/support/shared_examples_for_adapters/upload_link_query_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/upload_link_query_examples.rb index 6c527700ff93..5b8906668120 100644 --- a/modules/storages/spec/support/shared_examples_for_adapters/upload_link_query_examples.rb +++ b/modules/storages/spec/support/shared_examples_for_adapters/upload_link_query_examples.rb @@ -31,7 +31,7 @@ RSpec.shared_examples_for "upload_link_query: basic query setup" do it "is registered as queries.upload_link" do expect(Storages::Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.upload_link")).to eq(described_class) + .resolve("#{storage}.queries.upload_link")).to eq(described_class) end it "responds to #call with correct parameters" do diff --git a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb index 33b45c4ff145..73684682c11d 100644 --- a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb +++ b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb @@ -123,17 +123,17 @@ describe "managed project folders" do before do Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:| + .stub("#{storage}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:| ServiceResult.success(result: target_deep_file_ids) }) Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:| + .stub("#{storage}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:| ServiceResult.success(result: source_file_infos) }) Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.commands.copy_template_folder", + .stub("#{storage}.commands.copy_template_folder", lambda { |auth_strategy:, storage:, source_path:, destination_path:| ServiceResult.success(result: copy_result.with(id: "copied-folder", polling_url:)) }) @@ -172,18 +172,18 @@ before do Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.commands.copy_template_folder", + .stub("#{storage}.commands.copy_template_folder", lambda { |auth_strategy:, storage:, source_path:, destination_path:| ServiceResult.success(result: copy_result.with(polling_url:, requires_polling: true)) }) Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:| + .stub("#{storage}.queries.file_path_to_id_map", lambda { |storage:, auth_strategy:, folder:| ServiceResult.success(result: target_deep_file_ids) }) Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:| + .stub("#{storage}.queries.files_info", lambda { |storage:, auth_strategy:, file_ids:| ServiceResult.success(result: source_file_infos) }) @@ -238,7 +238,7 @@ context "when an error occurs" do before do Storages::Peripherals::Registry - .stub("#{storage.short_provider_type}.commands.copy_template_folder", + .stub("#{storage}.commands.copy_template_folder", lambda { |auth_strategy:, storage:, source_path:, destination_path:| ServiceResult.failure( result: :error, diff --git a/spec/requests/oauth_clients/ensure_connection_flow_spec.rb b/spec/requests/oauth_clients/ensure_connection_flow_spec.rb index 7cd2f3d80c90..b7ac2e2943ea 100644 --- a/spec/requests/oauth_clients/ensure_connection_flow_spec.rb +++ b/spec/requests/oauth_clients/ensure_connection_flow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -36,7 +38,7 @@ before do Storages::Peripherals::Registry.stub( - "#{storage.short_provider_type}.queries.auth_check", + "#{storage}.queries.auth_check", ->(_) { ServiceResult.success } ) end @@ -64,7 +66,7 @@ before do Storages::Peripherals::Registry.stub( - "#{storage.short_provider_type}.queries.auth_check", + "#{storage}.queries.auth_check", ->(_) { ServiceResult.failure(errors: Storages::StorageError.new(code: :unauthorized)) } )