[#45860] fixed files query for storages with sub path

- https://community.openproject.org/work_packages/45860
pull/11945/head
Eric Schubert 2 years ago
parent 2f75a7f345
commit ac87e7ee64
No known key found for this signature in database
GPG Key ID: 1D346C019BD4BAA2
  1. 6
      modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
  2. 18
      modules/storages/spec/common/peripherals/storage_requests_spec.rb
  3. 4
      modules/storages/spec/requests/api/v3/storages/storage_files_spec.rb

@ -42,7 +42,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
result = @retry_proc.call(@token) do |token|
response = http.propfind(
"#{@base_path}#{requested_folder(parent)}",
request_path(parent),
requested_properties,
{
'Depth' => '1',
@ -58,6 +58,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
private
def request_path(folder)
File.join(@uri.path, @base_path, requested_folder(folder)).gsub(/\/+$/, '')
end
def requested_folder(folder)
return '' if folder.nil?

@ -185,10 +185,11 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
describe '#files_query' do
let(:xml) { create(:webdav_data) }
let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}" }
before do
allow(OAuthClients::ConnectionManager).to receive(:new).and_return(connection_manager)
stub_request(:propfind, "#{url}/remote.php/dav/files/#{origin_user_id}")
stub_request(:propfind, request_url)
.to_return(status: 207, body: xml, headers: {})
end
@ -261,6 +262,21 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
assert_requested(:propfind, request_url)
end
end
describe 'with storage running on a sub path' do
let(:url) { 'https://example.com/storage' }
it do
subject
.files_query(user:)
.match(
on_success: ->(query) { query.call(nil) },
on_failure: ->(error) { raise "Files query could not be created: #{error}" }
)
assert_requested(:propfind, request_url)
end
end
end
describe 'with not supported storage type selected' do

@ -64,9 +64,9 @@ describe 'API v3 storage files', content_type: :json, webmock: true do
let(:files) do
[
Storages::StorageFile.new(1, 'new_younglings.md', 4096, 'plain/text', DateTime.now, DateTime.now,
Storages::StorageFile.new(1, 'new_younglings.md', 4096, 'text/markdown', DateTime.now, DateTime.now,
'Obi-Wan Kenobi', 'Obi-Wan Kenobi', '/'),
Storages::StorageFile.new(2, 'holocron_inventory.md', 4096, 'plain/text', DateTime.now, DateTime.now,
Storages::StorageFile.new(2, 'holocron_inventory.md', 4096, 'text/markdown', DateTime.now, DateTime.now,
'Obi-Wan Kenobi', 'Obi-Wan Kenobi', '/')
]
end

Loading…
Cancel
Save