Skip to content

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

Slowly replace the calls with the oauth_client for call with configuration

Marcello Rochac49050baec13
diff --git a/app/services/oauth_clients/connection_manager.rb b/app/services/oauth_clients/connection_manager.rb
index 51c8d412dbe..9bca7971b75 100644
--- a/app/services/oauth_clients/connection_manager.rb
+++ b/app/services/oauth_clients/connection_manager.rb
@@ -34,12 +34,11 @@ require "uri/http"
module OAuthClients
class ConnectionManager
# Nextcloud API endpoint to check if Bearer token is valid
- AUTHORIZATION_CHECK_PATH = '/ocs/v1.php/cloud/user'
TOKEN_IS_FRESH_DURATION = 10.seconds.freeze
- def initialize(user:, configuration:, oauth_client: nil)
+ def initialize(user:, configuration:)
@user = user
- @oauth_client = oauth_client || configuration.oauth_client
+ @oauth_client = configuration.oauth_client
@config = configuration
end
diff --git a/modules/storages/app/common/storages/errors.rb b/modules/storages/app/common/storages/errors.rb
index 7043618b2e8..574d9272c49 100644
--- a/modules/storages/app/common/storages/errors.rb
+++ b/modules/storages/app/common/storages/errors.rb
@@ -34,6 +34,11 @@ module Storages
class MissingContract < BaseError; end
class OperationNotSupported < BaseError; end
class ResolverStandardError < BaseError; end
- class SubclassResponsibility < BaseError; end
+
+ class SubclassResponsibility < BaseError
+ def message
+ "A subclass needs to implement its own version of this method."
+ end
+ end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb
index 2463197effa..df6345b8745 100644
--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb
+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb
@@ -1,6 +1,31 @@
# frozen_string_literal: true
#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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
diff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
index 63e9ced15a6..7994160026a 100644
--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
@@ -1,6 +1,31 @@
# frozen_string_literal: true
#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
index 4140c96129c..5c74aa6da02 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -32,7 +34,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
def initialize(storage)
@uri = storage.uri
- @oauth_client = storage.oauth_client
+ @configuration = storage.oauth_configuration
end
def self.call(storage:, user:, file_link:)
@@ -41,7 +43,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
# rubocop:disable Metrics/AbcSize
def call(user:, file_link:)
- result = Util.token(user:, oauth_client: @oauth_client) do |token|
+ result = Util.token(user:, configuration: @configuration) do |token|
service_result = begin
response = Util.http(@uri).post(
Util.join_uri_path(@uri.path, '/ocs/v2.php/apps/dav/api/v1/direct'),
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
index b6787ab161e..cd9bcaba857 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -30,11 +32,11 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
class FilesInfoQuery
using Storages::Peripherals::ServiceResultRefinements
- FILES_INFO_PATH = 'ocs/v1.php/apps/integration_openproject/filesinfo'.freeze
+ FILES_INFO_PATH = 'ocs/v1.php/apps/integration_openproject/filesinfo'
def initialize(storage)
@uri = storage.uri
- @oauth_client = storage.oauth_client
+ @configuration = storage.oauth_configuration
end
def self.call(storage:, user:, file_ids: [])
@@ -50,7 +52,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
return ServiceResult.success(result: [])
end
- Util.token(user:, oauth_client: @oauth_client) do |token|
+ Util.token(user:, configuration: @configuration) do |token|
files_info(file_ids, token).map(&parse_json) >> handle_failure >> create_storage_file_infos
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
index 1bb6b63d9ac..63ebc9afaac 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -30,12 +32,12 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
class UploadLinkQuery
using Storages::Peripherals::ServiceResultRefinements
- URI_TOKEN_REQUEST = 'index.php/apps/integration_openproject/direct-upload-token'.freeze
- URI_UPLOAD_BASE_PATH = 'index.php/apps/integration_openproject/direct-upload'.freeze
+ URI_TOKEN_REQUEST = 'index.php/apps/integration_openproject/direct-upload-token'
+ URI_UPLOAD_BASE_PATH = 'index.php/apps/integration_openproject/direct-upload'
def initialize(storage)
@uri = storage.uri
- @oauth_client = storage.oauth_client
+ @configuration = storage.oauth_configuration
end
def self.call(storage:, user:, data:)
@@ -43,7 +45,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
end
def call(user:, data:)
- Util.token(user:, oauth_client: @oauth_client) do |token|
+ Util.token(user:, configuration: @configuration) do |token|
if data.nil? || data['parent'].nil?
Util.error(:error, 'Data is invalid', data)
else
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
index ab2381b099d..dd75ef27e7c 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -55,8 +57,8 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Util
File.join(uri.to_s, *)
end
- def token(user:, oauth_client: nil, configuration: nil, &block)
- connection_manager = ::OAuthClients::ConnectionManager.new(user:, oauth_client:, configuration:)
+ def token(user:, configuration:, &block)
+ 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) }
diff --git a/modules/storages/app/helpers/storage_login_helper.rb b/modules/storages/app/helpers/storage_login_helper.rb
index b588670db7c..36e46aeab73 100644
--- a/modules/storages/app/helpers/storage_login_helper.rb
+++ b/modules/storages/app/helpers/storage_login_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -30,7 +32,8 @@ module StorageLoginHelper
def storage_login_input(storage)
return {} if storage&.oauth_client.blank?
- connection_manager = ::OAuthClients::ConnectionManager.new(user: current_user, oauth_client: storage.oauth_client)
+ connection_manager = ::OAuthClients::ConnectionManager
+ .new(user: current_user, configuration: storage.oauth_configuration)
{
storageType: API::V3::Storages::STORAGE_TYPE_URN_MAP[storage.provider_type],
diff --git a/modules/storages/app/models/storages/nextcloud_storage.rb b/modules/storages/app/models/storages/nextcloud_storage.rb
index 9b403f4b9cd..922a0a7f966 100644
--- a/modules/storages/app/models/storages/nextcloud_storage.rb
+++ b/modules/storages/app/models/storages/nextcloud_storage.rb
@@ -50,7 +50,7 @@ module Storages
where("provider_fields->>'automatically_managed' = 'true'")
.includes(:oauth_client)
.each do |storage|
- Storages::GroupFolderPropertiesSyncService.new(storage).call
+ GroupFolderPropertiesSyncService.new(storage).call
end
true
end
diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rb
index 92f491533da..ab9f6c54c1b 100644
--- a/modules/storages/app/models/storages/storage.rb
+++ b/modules/storages/app/models/storages/storage.rb
@@ -38,90 +38,92 @@
# It defines defines checks and permissions on the Ruby level.
# Additional attributes and constraints are defined in
# db/migrate/20220113144323_create_storage.rb "migration".
-class Storages::Storage < ApplicationRecord
- self.inheritance_column = :provider_type
+module Storages
+ class Storage < ApplicationRecord
+ self.inheritance_column = :provider_type
- # One Storage can have multiple FileLinks, representing external files.
- #
- # FileLink deletion is done:
- # - through a on_delete: :cascade at the database level when deleting a
- # Storage
- # - through a before_destroy hook at the application level when deleting a
- # ProjectStorage
- has_many :file_links, class_name: 'Storages::FileLink'
- # Basically every OpenProject object has a creator
- belongs_to :creator, class_name: 'User'
- # A project manager can enable/disable Storages per project.
- has_many :project_storages, dependent: :destroy, class_name: 'Storages::ProjectStorage'
- # We can get the list of projects with this Storage enabled.
- has_many :projects, through: :project_storages
- # The OAuth client credentials that OpenProject will use to obtain user specific
- # access tokens from the storage server, i.e a Nextcloud serer.
- has_one :oauth_client, as: :integration, dependent: :destroy
- has_one :oauth_application, class_name: '::Doorkeeper::Application', as: :integration, dependent: :destroy
+ # One Storage can have multiple FileLinks, representing external files.
+ #
+ # FileLink deletion is done:
+ # - through a on_delete: :cascade at the database level when deleting a
+ # Storage
+ # - through a before_destroy hook at the application level when deleting a
+ # ProjectStorage
+ has_many :file_links, class_name: 'Storages::FileLink'
+ # Basically every OpenProject object has a creator
+ belongs_to :creator, class_name: 'User'
+ # A project manager can enable/disable Storages per project.
+ has_many :project_storages, dependent: :destroy, class_name: 'Storages::ProjectStorage'
+ # We can get the list of projects with this Storage enabled.
+ has_many :projects, through: :project_storages
+ # The OAuth client credentials that OpenProject will use to obtain user specific
+ # access tokens from the storage server, i.e a Nextcloud serer.
+ has_one :oauth_client, as: :integration, dependent: :destroy
+ has_one :oauth_application, class_name: '::Doorkeeper::Application', as: :integration, dependent: :destroy
- PROVIDER_TYPES = [
- PROVIDER_TYPE_NEXTCLOUD = 'Storages::NextcloudStorage',
- PROVIDER_TYPE_ONE_DRIVE = 'Storages::OneDriveStorage'
- ].freeze
+ PROVIDER_TYPES = [
+ PROVIDER_TYPE_NEXTCLOUD = 'Storages::NextcloudStorage',
+ PROVIDER_TYPE_ONE_DRIVE = 'Storages::OneDriveStorage'
+ ].freeze
- validates_uniqueness_of :host, allow_nil: true
- validates_uniqueness_of :name
+ validates_uniqueness_of :host, allow_nil: true
+ validates_uniqueness_of :name
- # Creates a scope of all storages, which belong to a project the user is a member
- # and has the permission ':view_file_links'
- scope :visible, ->(user = User.current) do
- if user.allowed_to_globally?(:manage_storages_in_project)
- all
- else
- where(
- project_storages: ::Storages::ProjectStorage.where(
- project: Project.allowed_to(user, :view_file_links)
+ # Creates a scope of all storages, which belong to a project the user is a member
+ # and has the permission ':view_file_links'
+ scope :visible, ->(user = User.current) do
+ if user.allowed_to_globally?(:manage_storages_in_project)
+ all
+ else
+ where(
+ project_storages: ::Storages::ProjectStorage.where(
+ project: Project.allowed_to(user, :view_file_links)
+ )
)
- )
+ end
end
- end
- scope :not_enabled_for_project, ->(project) do
- where.not(id: project.project_storages.pluck(:storage_id))
- end
+ scope :not_enabled_for_project, ->(project) do
+ where.not(id: project.project_storages.pluck(:storage_id))
+ end
- def self.shorten_provider_type(provider_type)
- case /Storages::(?'provider_name'.*)Storage/.match(provider_type)
- in provider_name:
- provider_name.underscore
- else
- raise ArgumentError,
- "Unknown provider_type! Given: #{provider_type}. " \
- "Expected the following signature: Storages::{Name of the provider}Storage"
+ def self.shorten_provider_type(provider_type)
+ case /Storages::(?'provider_name'.*)Storage/.match(provider_type)
+ in provider_name:
+ provider_name.underscore
+ else
+ raise ArgumentError,
+ "Unknown provider_type! Given: #{provider_type}. " \
+ "Expected the following signature: Storages::{Name of the provider}Storage"
+ end
end
- end
- def configured?
- configuration_checks.values.all?
- end
+ def configured?
+ configuration_checks.values.all?
+ end
- def configuration_checks
- raise Errors::SubclassResponsibility
- end
+ def configuration_checks
+ raise Errors::SubclassResponsibility
+ end
- def uri
- URI(host).normalize
- end
+ def uri
+ URI(host).normalize
+ end
- def oauth_configuration
- raise Errors::SubclassResponsibility
- end
+ def oauth_configuration
+ raise Errors::SubclassResponsibility
+ end
- def short_provider_type
- @short_provider_type ||= self.class.shorten_provider_type(provider_type)
- end
+ def short_provider_type
+ @short_provider_type ||= self.class.shorten_provider_type(provider_type)
+ end
- def provider_type_nextcloud?
- provider_type == ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
- end
+ def provider_type_nextcloud?
+ provider_type == ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
+ end
- def provider_type_one_drive?
- provider_type == ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
+ def provider_type_one_drive?
+ provider_type == ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
+ end
end
end
diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rb
index 4cc5eba7f98..486a19a6c94 100644
--- a/modules/storages/lib/api/v3/storages/storage_representer.rb
+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -72,7 +74,7 @@ module API::V3::Storages
def initialize(model, current_user:, embed_links: nil)
@connection_manager =
- ::OAuthClients::ConnectionManager.new(user: current_user, oauth_client: model.oauth_client)
+ ::OAuthClients::ConnectionManager.new(user: current_user, configuration: model.oauth_configuration)
super
end
diff --git a/modules/storages/spec/common/peripherals/copy_template_folder_command_spec.rb b/modules/storages/spec/common/peripherals/copy_template_folder_command_spec.rb
index 43bce8615f5..18e775ab240 100644
--- a/modules/storages/spec/common/peripherals/copy_template_folder_command_spec.rb
+++ b/modules/storages/spec/common/peripherals/copy_template_folder_command_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -27,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::CopyTemplateFolderCommand, webmock: true do
using Storages::Peripherals::ServiceResultRefinements
diff --git a/modules/storages/spec/common/peripherals/files_info_query_spec.rb b/modules/storages/spec/common/peripherals/files_info_query_spec.rb
index 21fa894e433..af613fbd6f5 100644
--- a/modules/storages/spec/common/peripherals/files_info_query_spec.rb
+++ b/modules/storages/spec/common/peripherals/files_info_query_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -27,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesInfoQuery, webmock: true do
using Storages::Peripherals::ServiceResultRefinements
diff --git a/modules/storages/spec/common/peripherals/registry_spec.rb b/modules/storages/spec/common/peripherals/registry_spec.rb
index 6418afa209f..938cb6cbd4f 100644
--- a/modules/storages/spec/common/peripherals/registry_spec.rb
+++ b/modules/storages/spec/common/peripherals/registry_spec.rb
@@ -29,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe Storages::Peripherals::Registry, webmock: true do
using Storages::Peripherals::ServiceResultRefinements
diff --git a/modules/storages/spec/common/peripherals/util_spec.rb b/modules/storages/spec/common/peripherals/util_spec.rb
index 6196cd4e06f..0154ebf90ee 100644
--- a/modules/storages/spec/common/peripherals/util_spec.rb
+++ b/modules/storages/spec/common/peripherals/util_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -27,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::Util do
describe '.basic_auth_header' do
diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb
index b783b0c0baf..6fc0d84563c 100644
--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb
+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -27,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe API::V3::Storages::StorageRepresenter, 'parsing' do
let(:storage) { build_stubbed(:nextcloud_storage) }
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 7a397783fae..4d67e392ac1 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
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -27,6 +29,7 @@
#++
require 'spec_helper'
+require_module_spec_helper
RSpec.describe API::V3::Storages::StorageRepresenter, 'rendering' do
let(:oauth_application) { build_stubbed(:oauth_application) }
@@ -42,9 +45,7 @@ RSpec.describe API::V3::Storages::StorageRepresenter, 'rendering' do
allow(OAuthClients::ConnectionManager)
.to receive(:new).and_return(connection_manager)
allow(connection_manager)
- .to receive(:authorization_state).and_return(:connected)
- allow(connection_manager)
- .to receive(:get_authorization_uri).and_return('https://example.com/authorize')
+ .to receive_messages(authorization_state: :connected, get_authorization_uri: 'https://example.com/authorize')
end
describe '_links' do
@@ -262,7 +263,7 @@ RSpec.describe API::V3::Storages::StorageRepresenter, 'rendering' do
context 'with a non-Nextcloud storage' do
let(:storage) do
- build(:storage, provider_type: 'unknown', oauth_application:, oauth_client: oauth_client_credentials)
+ build(:one_drive_storage, oauth_application:, oauth_client: oauth_client_credentials)
end
it 'does not include the property hasApplicationPassword' do
diff --git a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
index 7560cafbe35..3bb694b6de0 100644
--- a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
+++ b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -123,7 +125,6 @@ RSpec.describe 'API v3 file links resource' do
subject { last_response }
before do
- storage_good
project_storage_good
oauth_client_good
diff --git a/modules/storages/spec/spec_helper.rb b/modules/storages/spec/spec_helper.rb
index 8c8d772a756..e51dfc5b54b 100644
--- a/modules/storages/spec/spec_helper.rb
+++ b/modules/storages/spec/spec_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -38,6 +40,6 @@ require 'dry/container/stub'
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
RSpec.configure do |config|
- config.before(:suite) { Storages::Peripherals::Registry.enable_stubs! }
+ config.prepend_before { Storages::Peripherals::Registry.enable_stubs! }
config.append_after { Storages::Peripherals::Registry.unstub }
end