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
[57347] Restructured NextcloudConnectionValidator
Andreas Pfohlfc9c584983e2
diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rbindex 21cc4380e14..19e0dcd3212 100644--- a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb+++ b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb@@ -44,8 +44,9 @@ module Storages.or { host_url_not_found }.or { missing_dependencies }.or { version_mismatch }- .or { request_failed_with_unknown_error }.or { with_unexpected_content }+ .or { group_folder_not_found }+ .or { request_failed_with_unknown_error }.value_or(ConnectionValidation.new(type: :healthy,error_code: :none,timestamp: Time.current,@@ -151,20 +152,13 @@ module Storages# rubocop:enable Metrics/AbcSize- def request_failed_with_unknown_error- return None() if capabilities.success?-- Rails.logger.error(- "Connection validation failed with unknown error:\n\t" \- "storage: ##{@storage.id} #{@storage.name}\n\t" \- "status: #{capabilities.result}\n\t" \- "response: #{capabilities.error_payload}"- )+ def group_folder_not_found+ return None() if files.result != :not_foundSome(ConnectionValidation.new(type: :error,- error_code: :err_unknown,+ error_code: :err_group_folder_not_found,timestamp: Time.current,- description: I18n.t("storages.health.connection_validation.unknown_error")))+ description: I18n.t("storages.health.connection_validation.group_folder_not_found")))end# rubocop:disable Metrics/AbcSize@@ -199,6 +193,34 @@ module Storages# rubocop:enable Metrics/AbcSize+ # rubocop:disable Metrics/AbcSize+ def request_failed_with_unknown_error+ return None() if capabilities.success?++ Rails.logger.error(+ "Connection validation failed with unknown error:\n\t" \+ "storage: ##{@storage.id} #{@storage.name}\n\t" \+ "status: #{capabilities.result}\n\t" \+ "response: #{capabilities.error_payload}"+ )++ return None() if files.success?++ Rails.logger.error(+ "Connection validation failed with unknown error:\n\t" \+ "storage: ##{@storage.id} #{@storage.name}\n\t" \+ "status: #{files.result}\n\t" \+ "response: #{files.error_payload}"+ )++ Some(ConnectionValidation.new(type: :error,+ error_code: :err_unknown,+ timestamp: Time.current,+ description: I18n.t("storages.health.connection_validation.unknown_error")))+ end++ # rubocop:enable Metrics/AbcSize+def noop = StorageInteraction::AuthenticationStrategies::Noop.strategydef userless = Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.userless").calldiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 3afefd17642..51013896c8d 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -211,6 +211,7 @@ en:client_secret_wrong: The configured OAuth 2 client secret is invalid. Please check the configuration.drive_id_wrong: The configured drive id could not be found. Please check the configuration.group_folder_version_mismatch: The Group Folder version is not supported. Please update your Nextcloud server.+ group_folder_not_found: The group folder could not be found.host_not_found: No Nextcloud server found at the configured host url. Please check the configuration.missing_dependencies: 'A required dependency is missing on the file storage. Please add the following dependency: %{dependency}.'not_configured: The connection could not be validated. Please finish configuration first.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.rbindex db6c731e860..208a14d2269 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@@ -163,6 +163,18 @@ RSpec.describe Storages::Peripherals::NextcloudConnectionValidator dobefore { project_storage }+ context "if the request returns not_found" do+ let(:files_response) do+ Storages::Peripherals::StorageInteraction::Nextcloud::Util.error(:not_found)+ end++ it "returns a validation failure" do+ expect(subject.type).to eq(:error)+ expect(subject.error_code).to eq(:err_group_folder_not_found)+ expect(subject.description).to eq("The group folder could not be found.")+ end+ end+context "if the request returns an error" dolet(:files_response) doStorages::Peripherals::StorageInteraction::Nextcloud::Util.error(:error)