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
[52779] Add port of Nextcloud storage to CSP directives
Christophe Bliard22f54ee92c18
diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbindex f604a1639c3..4c41131ecea 100644--- a/modules/storages/app/models/storages/storage.rb+++ b/modules/storages/app/models/storages/storage.rb@@ -174,7 +174,8 @@ module Storagesenddef connect_src- ["#{uri.scheme}://#{uri.host}"]+ port_part = [80, 443].include?(uri.port) ? "" : ":#{uri.port}"+ ["#{uri.scheme}://#{uri.host}#{port_part}"]enddef oauth_configurationdiff --git a/modules/storages/spec/lib/append_storages_hosts_to_csp_hook_spec.rb b/modules/storages/spec/lib/append_storages_hosts_to_csp_hook_spec.rbindex 7a70f35d8e0..7ce24de46e6 100644--- a/modules/storages/spec/lib/append_storages_hosts_to_csp_hook_spec.rb+++ b/modules/storages/spec/lib/append_storages_hosts_to_csp_hook_spec.rb@@ -68,7 +68,7 @@ RSpec.describe OpenProject::Storages::AppendStoragesHostsToCspHook doendend- context 'with a project with an active storage' do+ context 'with a project with an active Nextcloud storage' docontext 'when current user is an admin without being a member of any project' docurrent_user { admin }@@ -120,4 +120,32 @@ RSpec.describe OpenProject::Storages::AppendStoragesHostsToCspHook doinclude_examples 'does not change CSP'end++ context 'with an active Nextcloud storage having a host with a non-standard port' do+ let(:storage) { create(:nextcloud_storage, host: 'http://somehost.com:8080') }++ current_user { admin }++ it 'adds the port to the CSP directive' do+ trigger_application_controller_before_action_hook++ expect(controller).to have_received(:append_content_security_policy_directives) do |args|+ expect(args).to eq(connect_src: ['http://somehost.com:8080'])+ end+ end+ end++ context 'with an active Nextcloud storage having a host with a path' do+ let(:storage) { create(:nextcloud_storage, host: 'https://my.server.com/nextcloud') }++ current_user { admin }++ it 'removes the path from the host for the CSP directive' do+ trigger_application_controller_before_action_hook++ expect(controller).to have_received(:append_content_security_policy_directives) do |args|+ expect(args).to eq(connect_src: ['https://my.server.com'])+ end+ end+ endend