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
Still broken uploads, and maybe a lot more! fun times!
Marcello Rocha79fdf7f3d9c1
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rbindex 8d6439d7f39..582a2a5bda1 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb@@ -66,7 +66,7 @@ module Storagescase responsewhen Net::HTTPSuccessupload_url = MultiJson.load(response.body, symbolize_keys: true)[:uploadUrl]- ServiceResult.success(result: ::Storages::UploadLink.new(URI(upload_url)))+ ServiceResult.success(result: ::Storages::UploadLink.new(URI(upload_url), :put))when Net::HTTPNotFoundServiceResult.failure(result: :not_found, errors: ::Storages::StorageError.new(code: :not_found))when Net::HTTPUnauthorized@@ -77,7 +77,7 @@ module Storagesenddef uri_path_for(folder, filename)- "/v1.0/drives/#{@storage.drive_id}/items/#{folder}:/#{filename}:/createUploadSession"+ "/v1.0/drives/#{@storage.drive_id}/items/#{folder}:/#{URI.encode_uri_component(filename)}:/createUploadSession"endendenddiff --git a/modules/storages/app/models/storages/one_drive_storage.rb b/modules/storages/app/models/storages/one_drive_storage.rbindex 3fa5f7e8fe3..f12e07996a5 100644--- a/modules/storages/app/models/storages/one_drive_storage.rb+++ b/modules/storages/app/models/storages/one_drive_storage.rb@@ -47,6 +47,10 @@ module StoragesURI('https://graph.microsoft.com').normalizeend+ def connect_src+ %w[https://*.sharepoint.com https://*.up.1drv.com]+ end+def open_link::Storages::Peripherals::Registry.resolve("queries.one_drive.open_drive_link").call(storage: self, user: User.current)diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbindex 1bcb79a1035..f8572ec8f8a 100644--- a/modules/storages/app/models/storages/storage.rb+++ b/modules/storages/app/models/storages/storage.rb@@ -107,7 +107,11 @@ module Storagesenddef uri- URI(host).normalize+ @uri ||= URI(host).normalize+ end++ def connect_src+ ["#{uri.scheme}://#{uri.host}"]enddef open_linkdiff --git a/modules/storages/lib/api/v3/file_links/create_endpoint.rb b/modules/storages/lib/api/v3/file_links/create_endpoint.rbindex dbd8dd82b44..3692242c595 100644--- a/modules/storages/lib/api/v3/file_links/create_endpoint.rb+++ b/modules/storages/lib/api/v3/file_links/create_endpoint.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH@@ -59,6 +61,7 @@ class API::V3::FileLinks::CreateEndpoint < API::Utilities::Endpoints::Create# rollback records created if an error occurred (validation failed)raise ActiveRecord::Rollback if global_result.failure?end+global_resultenddiff --git a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rbindex 1eaa3548009..af47ef2a748 100644--- a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb+++ b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2022 the OpenProject GmbH@@ -44,24 +46,15 @@ class ::OpenProject::Storages::AppendStoragesHostsToCspHook < OpenProject::Hook:# (work packages module, BCF module, notification center, boards, ...).def application_controller_before_action(context)storage_ids = ::Storages::ProjectStorage.where(- project_id: Project.allowed_to(User.current, :manage_file_links),+ project_id: Project.allowed_to(User.current, :manage_file_links)).select(:storage_id)storages_hosts = ::Storages::Storage.where(id: storage_ids)- .where.not(host: nil)- .pluck(:host)- .map(&method(:remove_uri_path))+ .flat_map(&:connect_src)if storages_hosts.present?# secure_headers gem provides this helper method to append to the current content security policycontext[:controller].append_content_security_policy_directives(connect_src: storages_hosts)endend-- private-- def remove_uri_path(url)- uri = URI.parse(url)- "#{uri.scheme}://#{uri.host}"- endenddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/upload_link_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/upload_link_query_spec.rbindex 74f7a858a5d..ed86a17bc59 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/upload_link_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/upload_link_query_spec.rb@@ -66,7 +66,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::UploadLinkQulink = upload_query.call(user:, data: query_payload).resultexpect(link.destination).not_to be_nil- expect(link.method).to eq(:post)+ expect(link.method).to eq(:put)endshared_examples_for 'outbound is failing' do |code, symbol|diff --git a/modules/storages/spec/contracts/storages/file_links/shared_contract_examples.rb b/modules/storages/spec/contracts/storages/file_links/shared_contract_examples.rbindex e55c91f7db2..a66f90c55ce 100644--- a/modules/storages/spec/contracts/storages/file_links/shared_contract_examples.rb+++ b/modules/storages/spec/contracts/storages/file_links/shared_contract_examples.rb@@ -67,13 +67,13 @@ RSpec.shared_examples_for 'file_link contract' docontext 'when empty' dolet(:file_link_attributes) { { origin_id: '' } }- include_examples 'contract is invalid', origin_id: :blank+ include_examples 'contract is invalid', origin_id: %i[blank too_short]endcontext 'when nil' dolet(:file_link_attributes) { { origin_id: nil } }- include_examples 'contract is invalid', origin_id: :blank+ include_examples 'contract is invalid', origin_id: %i[blank too_short]endcontext 'when numeric' do@@ -91,11 +91,11 @@ RSpec.shared_examples_for 'file_link contract' docontext 'when having non ascii characters' dolet(:file_link_attributes) { { origin_id: 'Hëllò Wôrłd!' } }- include_examples 'contract is invalid', origin_id: :invalid+ include_examples 'contract is valid'endcontext 'when longer than 100 characters' do- let(:file_link_attributes) { { origin_id: '1' * 101 } }+ let(:file_link_attributes) { { origin_id: '1' * 201 } }include_examples 'contract is invalid', origin_id: :too_longenddiff --git a/modules/storages/spec/factories/file_link_element_factory.rb b/modules/storages/spec/factories/file_link_element_factory.rbindex 2b083f1f15a..c4d4d5898d1 100644--- a/modules/storages/spec/factories/file_link_element_factory.rb+++ b/modules/storages/spec/factories/file_link_element_factory.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH@@ -39,7 +41,7 @@ FactoryBot.define dostorage_url { "https://nextcloud.example.com" }trait :invalid do- origin_id { "I'm invalid" }+ origin_id { ' ' }endinitialize_with do