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 21cc4380e148..19e0dcd32126 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 @@ def validate .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 @@ def version_mismatch # 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_found Some(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 @@ def with_unexpected_content # 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.strategy def userless = Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.userless").call diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml index 3afefd17642c..51013896c8d2 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.rb index db6c731e860b..208a14d2269a 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 @@ before { 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" do let(:files_response) do Storages::Peripherals::StorageInteraction::Nextcloud::Util.error(:error)