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
WIP - Processing PR: Moved filesinfo path into constants
Frank Bergmann83387cde3207
diff --git a/modules/storages/app/services/storages/file_link_sync_service.rb b/modules/storages/app/services/storages/file_link_sync_service.rbindex 412d5b142a6..c8e1f9de52b 100644--- a/modules/storages/app/services/storages/file_link_sync_service.rb+++ b/modules/storages/app/services/storages/file_link_sync_service.rb@@ -28,6 +28,8 @@# Handle synchronization of FileLinks with external data store such as Storagesclass Storages::FileLinkSyncService+ FILESINFO_URL_PATH = "/ocs/v1.php/apps/integration_openproject/filesinfo".freeze+# @param user Current user# @param file_links An array of FileLink objectsdef initialize(user:)@@ -156,7 +158,7 @@ class Storages::FileLinkSyncService# -X POST -d '{"fileIds":[FILE_ID_1,FILE_ID_2,...]}'def request_files_info(token, file_ids)host = token.oauth_client.integration.host- uri = URI.parse(File.join(host, "/ocs/v1.php/apps/integration_openproject/filesinfo"))+ uri = URI.parse(File.join(host, FILESINFO_URL_PATH))request = build_files_info_request(uri, token, file_ids)begindiff --git a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rbindex bb4f2b74e15..a0f50580593 100644--- a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb+++ b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb@@ -41,6 +41,8 @@ describe ::Storages::FileLinkSyncService, type: :model dolet(:project) { create(:project, members: { user => role }) }let(:work_package) { create(:work_package, project:) }+ let(:filesinfo_path) { '/ocs/v1.php/apps/integration_openproject/filesinfo' }+# We want to check the case of file_links from multiple storageslet(:host1) { "http://host-1.example.org" }let(:host2) { "http://host-2.example.org" }@@ -121,7 +123,7 @@ describe ::Storages::FileLinkSyncService, type: :model dobefore do# Simulate a successfully authorized reply with updates from Nextcloud- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response)end@@ -137,7 +139,7 @@ describe ::Storages::FileLinkSyncService, type: :model dolet(:response) { { ocs: { meta: ocs_meta_s200, data: { '24': file_info_s403 } } }.to_json }before do- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response)end@@ -154,9 +156,9 @@ describe ::Storages::FileLinkSyncService, type: :model dobefore do# Simulate a successfully authorized reply with updates from Nextcloud- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response1)- stub_request(:post, File.join(host2, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host2, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response2)end@@ -178,7 +180,7 @@ describe ::Storages::FileLinkSyncService, type: :model dobefore do# Simulate a successfully authorized reply with updates from Nextcloud- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response)end@@ -192,7 +194,7 @@ describe ::Storages::FileLinkSyncService, type: :model docontext 'with connection timeout Nextcloud' dobefore do# Simulate a complete disconnection- stub_request(:any, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:any, File.join(host1, filesinfo_path)).to_timeoutend@@ -206,7 +208,7 @@ describe ::Storages::FileLinkSyncService, type: :model dolet(:response) { { ocs: { meta: ocs_meta_s200, data: { '24': file_info1_s200 } } }.to_json }before do- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response)end@@ -241,7 +243,7 @@ describe ::Storages::FileLinkSyncService, type: :model do# Mock Nextcloud to return:# first: a 401 indicating an outdated OAuth2 Bearer token and# then: a 200 with a reasonable result- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 401,headers: { 'Content-Type': 'application/json; charset=utf-8' },body: { ocs: { meta: ocs_meta_s401, data: [] } }.to_json)@@ -264,7 +266,7 @@ describe ::Storages::FileLinkSyncService, type: :model docontext 'with expired OAuth2 token and refresh failed' dobefore do# Mock Nextcloud to return 401 (not authorized) indicating an expired OAuth2 Bearer token- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 401,headers: { 'Content-Type': 'application/json; charset=utf-8' },body: { ocs: { meta: ocs_meta_s401, data: [] } }.to_json)@@ -297,7 +299,7 @@ describe ::Storages::FileLinkSyncService, type: :model dolet(:response) { { ocs: { meta: ocs_meta_s200, data: { '24': file_info1_s200 } } }.to_json }before do- stub_request(:post, File.join(host1, '/ocs/v1.php/apps/integration_openproject/filesinfo'))+ stub_request(:post, File.join(host1, filesinfo_path)).to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: response)end