Allow changing forbidden storage characters via API

This commit is contained in:
Jan Sandbrink
2026-02-26 16:04:08 +01:00
parent 2a1c725c0f
commit 0934ca1056
4 changed files with 37 additions and 0 deletions
@@ -54,6 +54,13 @@ properties:
Whether the storage has the application password to use for the Nextcloud storage.
Ignored if the provider type is not Nextcloud.
forbiddenFileNameCharacters:
type: string
description: |-
A string with all the characters forbidden to be used for file and folder names in the storage. Used by OpenProject to avoid
creating files with unsupported names (e.g. when creating project folders).
Only supported for provider type Nextcloud so far.
createdAt:
type: string
format: date-time
@@ -29,6 +29,13 @@ properties:
If a string is provided, the password is set and automatic management is enabled for the storage.
If null is provided, the password is unset and automatic management is disabled for the storage.
forbiddenFileNameCharacters:
type: string
description: |-
A string with all the characters forbidden to be used for file and folder names in the storage. Used by OpenProject to avoid
creating files with unsupported names (e.g. when creating project folders).
Only supported for provider type Nextcloud so far.
_links:
type: object
required:
@@ -140,6 +140,13 @@ module API::V3::Storages
end,
setter: ->(*) {}
property :forbiddenFileNameCharacters,
skip_render: ->(represented:, **) { !represented.provider_type_nextcloud? },
getter: ->(represented:, **) do
represented.forbidden_file_name_characters if represented.provider_type_nextcloud?
end,
setter: ->(fragment:, represented:, **) { represented.forbidden_file_name_characters = fragment }
date_time_property :created_at
date_time_property :updated_at
@@ -227,11 +227,19 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" do
let(:oauth_application) { build_stubbed(:oauth_application) }
let(:storage) { build_stubbed(:nextcloud_storage, oauth_application:, oauth_client: oauth_client_credentials) }
it "fulfills the documented schema" do
expect(generated).to match_json_schema.from_docs("storage_read_model")
end
it_behaves_like "common file storage properties"
context "if file storage is not completely configured" do
let(:storage) { build_stubbed(:nextcloud_storage, oauth_client: nil) }
it "fulfills the documented schema" do
expect(generated).to match_json_schema.from_docs("storage_read_model")
end
it_behaves_like "property", :configured do
let(:value) { false }
end
@@ -357,11 +365,19 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" do
context "if file storage has provider type OneDrive" do
let(:storage) { build_stubbed(:one_drive_storage, oauth_client: oauth_client_credentials) }
it "fulfills the documented schema" do
expect(generated).to match_json_schema.from_docs("storage_read_model")
end
it_behaves_like "common file storage properties"
context "if file storage is not completely configured" do
let(:storage) { build_stubbed(:one_drive_storage, drive_id: nil, oauth_client: oauth_client_credentials) }
it "fulfills the documented schema" do
expect(generated).to match_json_schema.from_docs("storage_read_model")
end
it_behaves_like "property", :configured do
let(:value) { false }
end