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
[#49043] Fix propfind command to work with NC under a subpath.
Pavel Balashou53426e650fd3
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/propfind_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/propfind_query.rbindex db1fc964c6f..5cc95e27b65 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/propfind_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/propfind_query.rb@@ -93,8 +93,11 @@ module Storages::Peripherals::StorageInteraction::Nextclouddoc = Nokogiri::XML response.bodyresult = {}doc.xpath('/d:multistatus/d:response').each do |resource_section|- resource = CGI.unescape(resource_section.xpath("d:href").text.strip).gsub!("/remote.php/dav/files/#{@username}/", "")+ resource = CGI+ .unescape(resource_section.xpath("d:href").text.strip)+ .gsub!(Util.join_uri_path(@uri.path, "/remote.php/dav/files/#{@username}/"), "")result[resource] = {}+# In future it could be useful to respond not only with found, but not found props as well# resource_section.xpath("d:propstat[d:status[text() = 'HTTP/1.1 404 Not Found']]/d:prop/*")resource_section.xpath("d:propstat[d:status[text() = 'HTTP/1.1 200 OK']]/d:prop/*").each do |node|diff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rbindex 0a8643f9cdd..917364bfef0 100644--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb@@ -858,6 +858,8 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doenddescribe '#propfind_query' do+ let(:nextcloud_subpath) { '' }+ let(:url) { "https://example.com#{nextcloud_subpath}" }let(:expected_request_body) do<<~XML<?xml version="1.0"?>@@ -877,7 +879,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doxmlns:oc="http://owncloud.org/ns"xmlns:nc="http://nextcloud.org/ns"><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/</d:href><d:propstat><d:prop><oc:fileid>349</oc:fileid>@@ -886,7 +888,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/asd/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/asd/</d:href><d:propstat><d:prop><oc:fileid>783</oc:fileid>@@ -895,7 +897,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/Project%231/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/Project%231/</d:href><d:propstat><d:prop><oc:fileid>773</oc:fileid>@@ -904,7 +906,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/Project%20%232/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/Project%20%232/</d:href><d:propstat><d:prop><oc:fileid>381</oc:fileid>@@ -913,7 +915,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/Project%232/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/Project%232/</d:href><d:propstat><d:prop><oc:fileid>398</oc:fileid>@@ -922,7 +924,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/qwe/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/qwe/</d:href><d:propstat><d:prop><oc:fileid>767</oc:fileid>@@ -931,7 +933,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do</d:propstat></d:response><d:response>- <d:href>/remote.php/dav/files/OpenProject/OpenProject/qweekk/</d:href>+ <d:href>#{nextcloud_subpath}/remote.php/dav/files/OpenProject/OpenProject/qweekk/</d:href><d:propstat><d:prop><oc:fileid>802</oc:fileid>@@ -944,7 +946,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doendbefore do- stub_request(:propfind, "https://example.com/remote.php/dav/files/OpenProject/OpenProject").with(+ stub_request(:propfind, "#{url}/remote.php/dav/files/OpenProject/OpenProject").with(body: expected_request_body,headers: {'Authorization' => 'Basic T3BlblByb2plY3Q6T3BlblByb2plY3RTZWN1cmVQYXNzd29yZA==',@@ -953,7 +955,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do).to_return(status: 200, body: expected_response_body, headers: {})end- describe 'with Nextcloud storage type selected' do+ shared_examples 'a propfind_query response' doit 'responds with a list of paths and attributes for each of them' doresult = subject.propfind_query@@ -968,6 +970,14 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true do"OpenProject/qweekk/" => { "fileid" => "802" } })endend++ it_behaves_like 'a propfind_query response'++ context 'when NC is deployed under subpath' do+ let(:nexcloud_subpath) { '/subpath' }++ it_behaves_like 'a propfind_query response'+ endenddescribe '#rename_file_command' do