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
Show storage configuration in health status download
Jan Sandbrinkb0ce2dcc78e9
diff --git a/modules/storages/app/controllers/storages/admin/health_status_controller.rb b/modules/storages/app/controllers/storages/admin/health_status_controller.rbindex 40fd6984346..688f811fa69 100644--- a/modules/storages/app/controllers/storages/admin/health_status_controller.rb+++ b/modules/storages/app/controllers/storages/admin/health_status_controller.rb@@ -78,6 +78,7 @@ module Storages{storage: @storage.name,storage_type: @storage.to_s,+ configuration: @storage.non_confidential_configuration,ran_at: timestamp}.merge(@report.to_h).to_yaml(stringify_names: true)enddiff --git a/modules/storages/app/models/storages/nextcloud_storage.rb b/modules/storages/app/models/storages/nextcloud_storage.rbindex 76eacb81bb0..b0ab260e9fc 100644--- a/modules/storages/app/models/storages/nextcloud_storage.rb+++ b/modules/storages/app/models/storages/nextcloud_storage.rb@@ -42,7 +42,6 @@ module StoragesAUTHENTICATION_METHOD_OAUTH2_SSO = "oauth2_sso"].freeze- store_attribute :provider_fields, :automatically_managed, :booleanstore_attribute :provider_fields, :username, :stringstore_attribute :provider_fields, :password, :stringstore_attribute :provider_fields, :group, :string@@ -53,6 +52,10 @@ module Storagesdef self.short_provider_name = :nextcloud+ def self.non_confidential_provider_fields+ super + %i[username group group_folder authentication_method storage_audience token_exchange_scope]+ end+def oauth_configurationAdapters::Providers::Nextcloud::OAuthConfiguration.new(self)enddiff --git a/modules/storages/app/models/storages/one_drive_storage.rb b/modules/storages/app/models/storages/one_drive_storage.rbindex 9417323e497..ac89308be3b 100644--- a/modules/storages/app/models/storages/one_drive_storage.rb+++ b/modules/storages/app/models/storages/one_drive_storage.rb@@ -41,6 +41,10 @@ module Storagesdef self.short_provider_name = :one_drive+ def self.non_confidential_provider_fields+ super + %i[tenant_id drive_id]+ end+def self.allowed_by_enterprise_token?EnterpriseToken.allows_to?(:one_drive_sharepoint_file_storage)enddiff --git a/modules/storages/app/models/storages/share_point_storage.rb b/modules/storages/app/models/storages/share_point_storage.rbindex 3370cac228b..3306fa75244 100644--- a/modules/storages/app/models/storages/share_point_storage.rb+++ b/modules/storages/app/models/storages/share_point_storage.rb@@ -45,9 +45,12 @@ module StoragesRails.env.local?end- store_attribute :provider_fields, :tenant_id, :string-def self.short_provider_name = :share_point++ def self.non_confidential_provider_fields+ super + %i[tenant_id]+ end+def audience = nildef authenticate_via_idp? = falsediff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbindex 2d07c894523..68cd16c4446 100644--- a/modules/storages/app/models/storages/storage.rb+++ b/modules/storages/app/models/storages/storage.rb@@ -104,6 +104,10 @@ module Storagessplit_reason = text.split(/[|:]/)split_reason[index].strip if split_reason.length > indexend++ def non_confidential_provider_fields+ %i[automatically_managed health_notifications_enabled]+ endenddelegate :short_provider_name, :allowed_by_enterprise_token?, :disallowed_by_enterprise_token?, to: :class@@ -170,6 +174,16 @@ module Storagesdef provider_fields_defaults = raise Errors::SubclassResponsibility+ def non_confidential_configuration+ provider_fields.symbolize_keys+ .slice(*self.class.non_confidential_provider_fields)+ .merge(+ host:,+ oauth_client_id: oauth_client&.client_id,+ oauth_application_client_id: oauth_application&.uid+ )+ end+def provider_type_nextcloud?is_a?(NextcloudStorage)enddiff --git a/modules/storages/spec/controllers/storages/admin/health_status_controller_spec.rb b/modules/storages/spec/controllers/storages/admin/health_status_controller_spec.rbindex ca70c167a07..08fd7264700 100644--- a/modules/storages/spec/controllers/storages/admin/health_status_controller_spec.rb+++ b/modules/storages/spec/controllers/storages/admin/health_status_controller_spec.rb@@ -83,6 +83,7 @@ RSpec.describe Storages::Admin::HealthStatusController doexpect(yaml["storage"]).to eq storage.nameexpect(yaml["storage_type"]).to eq storage.to_sexpect(yaml.dig("base_configuration", "storage_configured", "state")).to eq("failure")+ expect(yaml.dig("configuration", "host")).to eq(storage.host)endenddiff --git a/modules/storages/spec/factories/storage_factory.rb b/modules/storages/spec/factories/storage_factory.rbindex a3edbca5036..5bc728561b2 100644--- a/modules/storages/spec/factories/storage_factory.rb+++ b/modules/storages/spec/factories/storage_factory.rb@@ -94,6 +94,13 @@ FactoryBot.define doauthentication_method { "two_way_oauth2" }storage_audience { nil }+ trait :with_oauth_configured do+ after(:create) do |storage, _evaluator|+ create(:oauth_client, integration: storage)+ create(:oauth_application, integration: storage)+ end+ end+trait :oidc_sso_enabled dostorage_audience { "nextcloud" }authentication_method { "oauth2_sso" }diff --git a/modules/storages/spec/models/storages/nextcloud_storage_spec.rb b/modules/storages/spec/models/storages/nextcloud_storage_spec.rbindex cd79151931f..c437e245526 100644--- a/modules/storages/spec/models/storages/nextcloud_storage_spec.rb+++ b/modules/storages/spec/models/storages/nextcloud_storage_spec.rb@@ -235,4 +235,35 @@ RSpec.describe Storages::NextcloudStorage doexpect(storage.provider_fields_defaults).to eq({ automatic_management_enabled: true, username: "OpenProject" })endend++ describe "#non_confidential_configuration" do+ subject { storage.non_confidential_configuration }++ let(:storage) { create(:nextcloud_storage, :with_oauth_configured) }++ it "returns the expected hash" do+ expect(subject).to eq(+ authentication_method: "two_way_oauth2",+ health_notifications_enabled: true,+ host: storage.host,+ oauth_application_client_id: storage.oauth_application.uid,+ oauth_client_id: storage.oauth_client.client_id+ )+ end++ context "when the storage is set-up for SSO" do+ let(:storage) { create(:nextcloud_storage, :oidc_sso_enabled) }++ it "returns the expected hash" do+ expect(subject).to eq(+ authentication_method: "oauth2_sso",+ health_notifications_enabled: true,+ host: storage.host,+ storage_audience: "nextcloud",+ oauth_application_client_id: nil,+ oauth_client_id: nil+ )+ end+ end+ endenddiff --git a/modules/storages/spec/models/storages/one_drive_storage_spec.rb b/modules/storages/spec/models/storages/one_drive_storage_spec.rbindex 142a76eb8bb..5cb0974bbf9 100644--- a/modules/storages/spec/models/storages/one_drive_storage_spec.rb+++ b/modules/storages/spec/models/storages/one_drive_storage_spec.rb@@ -72,4 +72,22 @@ RSpec.describe Storages::OneDriveStorage doendendend++ describe "#non_confidential_configuration" do+ subject { storage.non_confidential_configuration }++ let(:storage) { create(:one_drive_storage_configured) }++ it "returns the expected hash" do+ expect(subject).to eq(+ automatically_managed: false,+ health_notifications_enabled: true,+ host: storage.host,+ drive_id: storage.drive_id,+ tenant_id: storage.tenant_id,+ oauth_application_client_id: storage.oauth_application.uid,+ oauth_client_id: storage.oauth_client.client_id+ )+ end+ endend