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

Merge branch 'dev' into feature/63518-add-error-codes-to-health-check-results

Eric Schubert98c01c30124c
diff --cc modules/storages/app/common/storages/peripherals/connection_validators/check_result.rb
index 4020495fea7,4d96968e62b..0437a50f549
--- a/modules/storages/app/common/storages/peripherals/connection_validators/check_result.rb
+++ b/modules/storages/app/common/storages/peripherals/connection_validators/check_result.rb
@@@ -51,20 -50,13 +51,24 @@@ module Storage
end
def success? = state == :success
+
def failure? = state == :failure
+
def warning? = state == :warning
+
def skipped? = state == :skipped
+ def humanize_title(group) = I18n.t("storages.health.checks.#{group}.#{key}")
+
+ def humanize_error_message
+ return nil if code.nil?
+
+ I18n.t("storages.health.connection_validation.#{code}", **context)
+ end
++
+ def to_h
+ { state: state.to_s, message:, timestamp: timestamp&.iso8601 }
+ end
end
end
end
diff --cc modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator.rb
index c2ada69c2b5,49d292c57e9..03e81fb6c66
--- a/modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator.rb
+++ b/modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator.rb
@@@ -58,9 -57,26 +59,26 @@@ module Storage
end
end
+ def group_folder_app_checks
+ required_version = SemanticVersion.parse(
+ nextcloud_dependencies.dig("dependencies", "group_folders_app", "min_version")
+ )
+
+ capabilities = Registry["nextcloud.queries.capabilities"].call(storage: @storage, auth_strategy: noop).result
+ dependency = I18n.t("storages.dependencies.nextcloud.group_folders_app")
+
+ if capabilities.group_folder_disabled?
- fail_check(:group_folder_app, message(:missing_dependencies, dependency:))
++ fail_check(:group_folder_app, :nc_dependency_missing, context: { dependency: })
+ elsif capabilities.group_folder_version < required_version
- fail_check(:group_folder_app, message(:dependency_version_mismatch, dependency:))
++ fail_check(:group_folder_app, :nc_dependency_version_mismatch, context: { dependency: })
+ else
+ pass_check(:group_folder_app)
+ end
+ end
+
def group_folder_not_found
if files.result == :not_found
- fail_check(:group_folder_presence, message(:group_folder_not_found))
+ fail_check(:group_folder_presence, :nc_group_folder_not_found)
else
pass_check(:group_folder_presence)
end
@@@ -105,9 -121,17 +123,17 @@@
def files
@files ||= Peripherals::Registry
- .resolve("#{@storage}.queries.files")
- .call(storage: @storage, auth_strategy:, folder: ParentFolder.new(@storage.group_folder))
+ .resolve("#{@storage}.queries.files")
+ .call(storage: @storage, auth_strategy:, folder: ParentFolder.new(@storage.group_folder))
end
+
+ def noop = StorageInteraction::AuthenticationStrategies::Noop.strategy
+
+ def nextcloud_dependencies
+ @nextcloud_dependencies ||= YAML.load_file(path_to_config).deep_stringify_keys
+ end
+
+ def path_to_config = Rails.root.join("modules/storages/config/nextcloud_dependencies.yml")
end
end
end
diff --cc modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator.rb
index afc28b44ce6,7a9fe0b25ba..c7da540791a
--- a/modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator.rb
+++ b/modules/storages/app/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator.rb
@@@ -67,9 -65,10 +67,10 @@@ module Storage
def version_mismatch
min_app_version = SemanticVersion.parse(nextcloud_dependencies.dig("dependencies", "integration_app", "min_version"))
capabilities_result = capabilities.result
- app_name = I18n.t("storages.dependencies.nextcloud.integration_app")
++ dependency = I18n.t("storages.dependencies.nextcloud.integration_app")
if capabilities_result.app_version < min_app_version
- fail_check(:dependencies_versions, :nc_integration_app_version_mismatch)
- fail_check(:dependencies_versions, message(:dependency_version_mismatch, dependency: app_name))
++ fail_check(:dependencies_versions, :nc_dependency_version_mismatch, context: { dependency: })
else
pass_check(:dependencies_versions)
end
@@@ -77,9 -76,10 +78,10 @@@
def missing_dependencies
capabilities_result = capabilities.result
- app_name = I18n.t("storages.dependencies.nextcloud.integration_app")
++ dependency = I18n.t("storages.dependencies.nextcloud.integration_app")
if capabilities_result.app_disabled?
- fail_check(:dependencies_check, :nc_integration_app_missing)
- fail_check(:dependencies_check, message(:missing_dependencies, dependency: app_name))
++ fail_check(:dependencies_check, :nc_dependency_missing, context: { dependency: })
else
pass_check(:dependencies_check)
end
diff --cc modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb
index 0ada5194903,b3cfd0677aa..84aac5a7d77
--- a/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb
+++ b/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb
@@@ -73,18 -70,9 +73,22 @@@ module Storage
@results.values.filter_map(&:timestamp).max
end
+ def humanize_title = I18n.t("storages.health.checks.#{key}.header")
+
+ def humanize_summary
+ case tally
+ in { failure: 1.. }
+ I18n.t("storages.health.checks.failures", count: tally[:failure])
+ in { warning: 1.. }
+ I18n.t("storages.health.checks.warnings", count: tally[:warning])
+ else
+ I18n.t("storages.health.checks.failures", count: 0)
+ end
+ end
++
+ def to_h
+ @results.transform_values(&:to_h)
+ end
end
end
end
diff --cc modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb
index 647b39f735a,e0a312d4dfa..4bcb88e7ec1
--- a/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb
+++ b/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb
@@@ -66,16 -63,9 +66,20 @@@ module Storage
group_results.values.filter_map(&:timestamp).max
end
+ def humanize_summary
+ case tally
+ in { failure: 1.. }
+ I18n.t("storages.health.checks.failures", count: tally[:failure])
+ in { warning: 1.. }
+ I18n.t("storages.health.checks.warnings", count: tally[:warning])
+ else
+ I18n.t("storages.health.checks.failures", count: 0)
+ end
+ end
++
+ def to_h
+ group_results.transform_values(&:to_h)
+ end
end
end
end
diff --cc modules/storages/config/locales/en.yml
index 90c3f286e86,5ccb4e187f1..61955fa1f16
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@@ -236,10 -238,8 +238,11 @@@ en
checked: Last checked %{datetime}
checks:
ampf_configuration:
+ client_folder_creation: Automatic folder creation
+ client_folder_removal: Automatic folder deletion
+ drive_contents: Drive has expected content
files_request: Fetching group folder files
+ group_folder_app: 'Dependency: Group Folders'
group_folder_contents: Group folder has expected content
group_folder_presence: Group folder exists
header: Automatically managed project folder configuration
@@@ -272,30 -272,20 +275,28 @@@
one: "%{count} check returned a warning"
other: "%{count} checks returned a warning"
connection_validation:
- client_id_wrong: The configured OAuth 2 client id is invalid. Please check the configuration.
- client_secret_wrong: The configured OAuth 2 client secret is invalid. Please check the configuration.
- dependency_version_mismatch: The %{dependency} app version is not supported. Please update your Nextcloud server.
- drive_id_wrong: The configured drive id could not be found. Please check the configuration.
- group_folder_not_found: The group folder could not be found.
- group_folder_version_mismatch: The Group Folder version is not supported. Please update your Nextcloud server.
- 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}.'
- nextcloud:
- oauth_request_not_found: OpenProject couldn't find the root folder of Nextcloud using the current logged-in user. Please check the server logs for further information.
- oauth_request_unauthorized: The current user isn't authorized to see the main folder of Nextcloud or we couldn't acquire a token. Please check the server logs for further information.
- oauth_token_missing: OpenProject cannot test the user level communication with Nextcloud as the user did not yet link their Nextcloud account.
- unexpected_content: Unexpected content found in the managed group folder.
+ client_id_invalid: The configured OAuth 2 client id is invalid. Please check the configuration.
+ client_secret_invalid: The configured OAuth 2 client secret is invalid. Please check the configuration.
- nc_group_folder_app_missing: A required dependency is missing on the file storage. Please add 'Group folders' to your installation.
++ nc_dependency_missing: 'A required dependency is missing on the file storage. Please add the following dependency: %{dependency}.'
++ nc_dependency_version_mismatch: The %{dependency} app version is not supported. Please update your Nextcloud server.
+ nc_group_folder_not_found: The group folder could not be found.
- nc_group_folder_version_mismatch: The Group folders app version is not supported. Please update your Nextcloud server.
+ nc_host_not_found: No Nextcloud server found at the configured host url. Please check the configuration.
- nc_integration_app_missing: A required dependency is missing on the file storage. Please add 'Integration OpenProject' to your installation.
- nc_integration_app_version_mismatch: The Integration OpenProject app version is not supported. Please update your Nextcloud server.
+ nc_oauth_request_not_found: OpenProject couldn't find the root folder of Nextcloud using the current logged-in user. Please check the server logs for further information.
+ nc_oauth_request_unauthorized: The current user isn't authorized to see the main folder of Nextcloud or we couldn't acquire a token. Please check the server logs for further information.
+ nc_oauth_token_missing: OpenProject cannot test the user level communication with Nextcloud as the user did not yet link their Nextcloud account.
+ nc_unexpected_content: Unexpected content found in the managed group folder.
+ nc_userless_access_denied: The configured app password is invalid.
not_configured: The connection could not be validated. Please finish configuration first.
+ od_client_cant_delete_folder: The client is having trouble deleting folders. Please check the setup documentation for your storage.
+ od_client_write_permission_missing: The client seems to have write permissions missing. Please check the setup documentation for your storage.
+ od_drive_id_invalid: The configured drive id seems invalid. Please check the configuration.
+ od_drive_id_not_found: The configured drive id could not be found. Please check the configuration.
+ od_existing_test_folder: The folder %{folder_name} needed for testing already exists. Please delete it and try again.
+ od_oauth_request_not_found: OpenProject couldn't find the root folder in the drive using the current logged-in user. Please check the server logs for further information.
+ od_oauth_request_unauthorized: The current user isn't authorized to see the root folder of OneDrive/SharePoint or we couldn't acquire a token. Please check the server logs for further information.
+ od_oauth_token_missing: OpenProject cannot test the user level communication with OneDrive/SharePoint as the user did not yet link their Microsoft account.
+ od_tenant_id_wrong: The configured directory (tenant) id is invalid. Please check the configuration.
+ od_unexpected_content: Unexpected content found in the drive.
oidc_cant_acquire_token: Your OpenID Connect setup doesn't provide the necessary audience, nor provides token exchange capabilities. Please check out our documentation for more information.
oidc_cant_exchange_token: There seems to be a problem with the Token Exchange setup on your OpenID Connect Provider. Please check its configuration and try again.
oidc_cant_refresh_token: There was an error while trying to check your access to the storage. Please check the server logs for further information.
diff --cc modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator_spec.rb
index 7b645a9f92f,c77cfc1d98a..488a0a5954a
--- a/modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/ampf_configuration_validator_spec.rb
@@@ -67,9 -106,9 +106,9 @@@ module Storage
results = validator.call
states = results.tally
- expect(states).to eq({ success: 1, failure: 1, skipped: 2 })
+ expect(states).to eq({ success: 2, failure: 1, skipped: 2 })
expect(results[:userless_access]).to be_failure
- expect(results[:userless_access].message).to eq(i18n_message(:userless_access_denied))
+ expect(results[:userless_access].code).to eq(:nc_userless_access_denied)
end
end
diff --cc modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator_spec.rb
index a33185b96dc,5a478eef9d4..8d415e8b47c
--- a/modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/connection_validators/nextcloud/storage_configuration_validator_spec.rb
@@@ -73,7 -73,8 +73,8 @@@ module Storage
results = validator.call
expect(results[:dependencies_versions]).to be_a_failure
- expect(results[:dependencies_versions].code).to eq(:nc_integration_app_version_mismatch)
- expect(results[:dependencies_versions].message)
- .to eq(I18n.t(i18n_key(:dependency_version_mismatch), dependency: "Integration OpenProject"))
++ expect(results[:dependencies_versions].code).to eq(:nc_dependency_version_mismatch)
++ expect(results[:dependencies_versions].context[:dependency]).to eq("Integration OpenProject")
end
it "integration app disabled / missing", vcr: "nextcloud/capabilities_success_app_disabled" do