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
Add missing property to storages API
Jan Sandbrinked8310840c02
diff --git a/docs/api/apiv3/components/schemas/storage_read_model.yml b/docs/api/apiv3/components/schemas/storage_read_model.ymlindex 9beab56c8de..4fbfed50382 100644--- a/docs/api/apiv3/components/schemas/storage_read_model.yml+++ b/docs/api/apiv3/components/schemas/storage_read_model.yml@@ -25,6 +25,13 @@ properties:This is only required for authentication through single-sign-on and so faronly supported for provider type Nextcloud.+ tokenExchangeScope:+ type: string+ description: |-+ The scope that will be requested when requesting a token for the storage through token exchange. Has no effect if no+ token exchange is performed.++ This is only required for authentication through single-sign-on and so far only supported for provider type Nextcloud.tenantId:type: stringdescription: |-diff --git a/docs/api/apiv3/components/schemas/storage_write_model.yml b/docs/api/apiv3/components/schemas/storage_write_model.ymlindex c9526819795..c47b7673539 100644--- a/docs/api/apiv3/components/schemas/storage_write_model.yml+++ b/docs/api/apiv3/components/schemas/storage_write_model.yml@@ -13,6 +13,13 @@ properties:This is only required for authentication through single-sign-on and so faronly supported for provider type Nextcloud.+ tokenExchangeScope:+ type: string+ description: |-+ The scope that will be requested when requesting a token for the storage through token exchange. Has no effect if no+ token exchange is performed.++ This is only required for authentication through single-sign-on and so far only supported for provider type Nextcloud.applicationPassword:type:- stringdiff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex fbd945564e5..4eb134024ef 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -99,6 +99,11 @@ module API::V3::Storagesgetter: ->(represented:, **) { represented.provider_type_nextcloud? && represented.storage_audience },setter: ->(fragment:, represented:, **) { represented.storage_audience = fragment }+ property :tokenExchangeScope,+ skip_render: ->(represented:, **) { !represented.provider_type_nextcloud? },+ getter: ->(represented:, **) { represented.provider_type_nextcloud? && represented.token_exchange_scope },+ setter: ->(fragment:, represented:, **) { represented.token_exchange_scope = fragment }+property :applicationPassword,skip_render: ->(*) { true },getter: ->(*) {},diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rbindex 17db7d8a901..f42f6056583 100644--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_parsing_spec.rb@@ -100,6 +100,7 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "parsing" do"href" => "urn:openproject-org:api:v3:storages:authenticationMethod:OAuth2SSO"}parsed_hash["storageAudience"] = "the-new-storage-audience"+ parsed_hash["tokenExchangeScope"] = "one-scope two-scope"endit "parses the authentication method" do@@ -109,6 +110,10 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "parsing" doit "parses the storage audience" doexpect(parsed.storage_audience).to eq("the-new-storage-audience")end++ it "parses the token exchange scope" do+ expect(parsed.token_exchange_scope).to eq("one-scope two-scope")+ endenddescribe "automatically managed project folders" dodiff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rbindex ac82556cf45..2882b498481 100644--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb@@ -265,6 +265,26 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" doendendend++ describe "tokenExchangeScope" do+ it_behaves_like "no property", :tokenExchangeScope++ context "when the storage is configured for SSO authentication" do+ let(:storage) { create(:nextcloud_storage, :oidc_sso_enabled, token_exchange_scope: "a-scope") }++ it_behaves_like "property", :tokenExchangeScope do+ let(:value) { "a-scope" }+ end+ end++ context "when the storage is configured for SSO authentication, but has an empty scope" do+ let(:storage) { create(:nextcloud_storage, :oidc_sso_enabled, token_exchange_scope: "") }++ it_behaves_like "property", :tokenExchangeScope do+ let(:value) { "" }+ end+ end+ endendit_behaves_like "common file storage links"