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] Added unexpected content validation to NextcloudConnectionValidator
Andreas Pfohla5d2472276ef
diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rbindex b5645fa7a4e..8ea89f531d3 100644--- a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb+++ b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb@@ -45,6 +45,7 @@ module Storages.or { missing_dependencies }.or { version_mismatch }.or { request_failed_with_unknown_error }+ .or { with_unexpected_content }.value_or(ConnectionValidation.new(type: :healthy,error_code: :none,timestamp: Time.current,@@ -59,6 +60,17 @@ module Storages.call(storage: @storage, auth_strategy:)end+ def files+ @files ||= Peripherals::Registry+ .resolve("#{@storage.short_provider_type}.queries.files")+ .call(+ storage: @storage,+ auth_strategy: Peripherals::Registry+ .resolve("#{@storage.short_provider_type}.authentication.userless").call,+ folder: ParentFolder.new(@storage.group_folder)+ )+ end+def maybe_is_not_configuredreturn None() if @storage.configured?@@ -147,10 +159,12 @@ module Storagesdef request_failed_with_unknown_errorreturn None() if query.success?- Rails.logger.error("Connection validation failed with unknown error:\n\t" \- "storage: ##{@storage.id} #{@storage.name}\n\t" \- "status: #{query.result}\n\t" \- "response: #{query.error_payload}")+ Rails.logger.error(+ "Connection validation failed with unknown error:\n\t" \+ "storage: ##{@storage.id} #{@storage.name}\n\t" \+ "status: #{query.result}\n\t" \+ "response: #{query.error_payload}"+ )Some(ConnectionValidation.new(type: :error,error_code: :err_unknown,@@ -158,6 +172,26 @@ module Storagesdescription: I18n.t("storages.health.connection_validation.unknown_error")))end+ # rubocop:disable Metrics/AbcSize+ def with_unexpected_content+ return None() unless @storage.automatic_management_enabled?+ return None() if files.failure?++ expected_folder_ids = @storage.project_storages+ .where(project_folder_mode: "automatic")+ .map(&:project_folder_id)++ unexpected_files = files.result.files.reject { |file| expected_folder_ids.include?(file.id) }+ return None() if unexpected_files.empty?++ Some(ConnectionValidation.new(type: :warning,+ error_code: :wrn_unexpected_content,+ timestamp: Time.current,+ description: I18n.t("storages.health.connection_validation.unexpected_content")))+ end++ # rubocop:enable Metrics/AbcSize+def auth_strategy = StorageInteraction::AuthenticationStrategies::Noop.strategydef path_to_configdiff --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 848f06e3cf5..a80dc489d77 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@@ -42,7 +42,7 @@ module Storagesenddef call(auth_strategy:, folder:)- validate_input_data(auth_strategy, folder).on_failure { return _1 }+ validate_input_data(folder).on_failure { return _1 }origin_user = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:).on_failure { return _1 }@@ -56,12 +56,10 @@ module Storagesprivate- def validate_input_data(auth_strategy, folder)+ def validate_input_data(folder)error_data = StorageErrorData.new(source: self.class)- if auth_strategy.user.nil?- Util.error(:error, "Cannot execute query without user context.", error_data)- elsif folder.is_a?(ParentFolder)+ if folder.is_a?(ParentFolder)ServiceResult.successelseUtil.error(:error, "Folder input is not a ParentFolder object.", error_data)