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
[#53815] Use authentication in download_link_query
Eric Schubertd0d5cc38bf46
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rbindex 7d572374912..b578af94fbd 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb@@ -32,18 +32,38 @@ module Storages::Peripherals::StorageInteraction::Nextcloudclass DownloadLinkQueryusing Storages::Peripherals::ServiceResultRefinements+ Auth = ::Storages::Peripherals::StorageInteraction::Authentication++ def self.call(storage:, auth_strategy:, file_link:)+ new(storage).call(auth_strategy:, file_link:)+ end+def initialize(storage)- @uri = storage.uri- @configuration = storage.oauth_configuration+ @storage = storageend- def self.call(storage:, user:, file_link:)- new(storage).call(user:, file_link:)+ def call(auth_strategy:, file_link:)+ if file_link.nil?+ return failure(code: :error, payload: nil, log_message: "File link can not be nil.")+ end++ direct_download_request(auth_strategy:, file_link:)+ .bind { |response_body| direct_download_token(body: response_body) }+ .map { |download_token| download_link(download_token, file_link.origin_name) }end- def call(user:, file_link:)- result = Util.token(user:, configuration: @configuration) do |token|- direct_download_request(token, file_link).bind do |resp|+ private++ def http_options+ Util.ocs_api_request.deep_merge(Util.accept_json)+ end++ def direct_download_request(auth_strategy:, file_link:)+ Auth[auth_strategy].call(storage: @storage, http_options:) do |http|+ result = handle_response http.post(Util.join_uri_path(@storage.uri, "/ocs/v2.php/apps/dav/api/v1/direct"),+ json: { fileId: file_link.origin_id })++ result.bind do |resp|# The nextcloud API returns a successful response with empty body if the authorization is missing or expiredif resp.body.blank?Util.error(:unauthorized, "Outbound request not authorized!")@@ -52,41 +72,29 @@ module Storages::Peripherals::StorageInteraction::Nextcloudendendend-- result- .bind { |response_body| direct_download_token(body: response_body) }- .map { |download_token| download_link(download_token, file_link.origin_name) }end- private-- def direct_download_request(token, file_link)- response = OpenProject- .httpx- .post(- Util.join_uri_path(@uri, "/ocs/v2.php/apps/dav/api/v1/direct"),- json: { fileId: file_link.origin_id },- headers: {- "Authorization" => "Bearer #{token.access_token}",- "OCS-APIRequest" => "true",- "Accept" => "application/json",- "Content-Type" => "application/json"- }- )+ def handle_response(response)case responsein { status: 200..299 }ServiceResult.success(result: response)in { status: 404 }- Util.error(:not_found, "Outbound request destination not found!", response)+ failure(code: :not_found,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request destination not found!")in { status: 401 }- Util.error(:unauthorized, "Outbound request not authorized!", response)+ failure(code: :unauthorized,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request not authorized!")else- Util.error(:error, "Outbound request failed!")+ failure(code: :error,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request failed with unknown error!")endenddef download_link(token, origin_name)- Util.join_uri_path(@uri, "index.php/apps/integration_openproject/direct", token, CGI.escape(origin_name))+ Util.join_uri_path(@storage.uri, "index.php/apps/integration_openproject/direct", token, CGI.escape(origin_name))enddef direct_download_token(body:)@@ -113,5 +121,14 @@ module Storages::Peripherals::StorageInteraction::Nextcloudpath.split("/").lastend++ def failure(code:, payload:, log_message:)+ ServiceResult.failure(+ result: code,+ errors: ::Storages::StorageError.new(code:,+ data: ::Storages::StorageErrorData.new(source: self.class, payload:),+ log_message:)+ )+ endendenddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rbindex 8a6f3a091b8..67786974dc5 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb@@ -33,26 +33,23 @@ module Storagesmodule StorageInteractionmodule OneDriveclass DownloadLinkQuery- def initialize(storage)- @storage = storage- @uri = storage.uri+ Auth = ::Storages::Peripherals::StorageInteraction::Authentication++ def self.call(storage:, auth_strategy:, file_link:)+ new(storage).call(auth_strategy:, file_link:)end- def self.call(storage:, user:, file_link:)- new(storage).call(user:, file_link:)+ def initialize(storage)+ @storage = storageend- def call(user:, file_link:)- Util.using_user_token(@storage, user) do |token|- response = OpenProject.httpx.get(- Util.join_uri_path(- @uri,- uri_path_for(file_link.origin_id)- ),- headers: { "Authorization" => "Bearer #{token.access_token}" }- )+ def call(auth_strategy:, file_link:)+ if file_link.nil?+ return failure(code: :error, payload: nil, log_message: "File link can not be nil.")+ end- handle_errors(response)+ Auth[auth_strategy].call(storage: @storage) do |http|+ handle_errors http.get(Util.join_uri_path(@storage.uri, uri_path_for(file_link.origin_id)))endend@@ -63,23 +60,36 @@ module Storagesin { status: 300..399 }ServiceResult.success(result: response.headers["Location"])in { status: 404 }- ServiceResult.failure(result: :not_found,- errors: ::Storages::StorageError.new(code: :not_found, data: response))+ failure(code: :not_found,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request destination not found!")in { status: 403 }- ServiceResult.failure(result: :forbidden,- errors: ::Storages::StorageError.new(code: :forbidden, data: response))+ failure(code: :forbidden,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request forbidden!")in { status: 401 }- ServiceResult.failure(result: :unauthorized,- errors: ::Storages::StorageError.new(code: :unauthorized, data: response))+ failure(code: :unauthorized,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request not authorized!")else- ServiceResult.failure(result: :error,- errors: ::Storages::StorageError.new(code: :error, data: response))+ failure(code: :error,+ payload: response.json(symbolize_keys: true),+ log_message: "Outbound request failed with unknown error!")endenddef uri_path_for(file_id)"/v1.0/drives/#{@storage.drive_id}/items/#{file_id}/content"end++ def failure(code:, payload:, log_message:)+ ServiceResult.failure(+ result: code,+ errors: ::Storages::StorageError.new(code:,+ data: StorageErrorData.new(source: self.class, payload:),+ log_message:)+ )+ endendendenddiff --git a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb b/modules/storages/lib/api/v3/file_links/file_links_download_api.rbindex a1a38ff38f9..41b996b1e7b 100644--- a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb+++ b/modules/storages/lib/api/v3/file_links/file_links_download_api.rb@@ -32,11 +32,19 @@ class API::V3::FileLinks::FileLinksDownloadAPI < API::OpenProjectAPIusing Storages::Peripherals::ServiceResultRefinementshelpers Storages::Peripherals::StorageErrorHelper+ helpers do+ def auth_strategy+ Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken+ .strategy+ .with_user(User.current)+ end+ end+resources :download doget doStorages::Peripherals::Registry.resolve("#{@file_link.storage.short_provider_type}.queries.download_link")- .call(storage: @file_link.storage, user: User.current, file_link: @file_link)+ .call(storage: @file_link.storage, auth_strategy:, file_link: @file_link).match(on_success: ->(url) doredirect(url, body: "The requested resource can be downloaded from #{url}")diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/download_link_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/download_link_query_spec.rbindex 51efef36875..8caa36d8bf2 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/download_link_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/download_link_query_spec.rb@@ -32,80 +32,73 @@ require "spec_helper"require_module_spec_helperRSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::DownloadLinkQuery, :webmock do- let(:file_link) { create(:file_link) }- let(:download_token) { "8dM3dC9iy1N74F5AJ0ClnjSF4dWTxfymVy1HTXBh8rbZVM81CpcBJaIYZvmR" }- let(:uri) do- "#{url}/index.php/apps/integration_openproject/direct/#{download_token}/#{CGI.escape(file_link.origin_name)}"+ using Storages::Peripherals::ServiceResultRefinements++ let(:user) { create(:user) }+ let(:storage) do+ create(:nextcloud_storage_with_local_connection, :as_not_automatically_managed, oauth_client_token_user: user)end- let(:json) do- {- ocs: {- meta: {- status: "ok",- statuscode: 200,- message: "OK"- },- data: {- url: "https://example.com/remote.php/direct/#{download_token}"- }- }- }.to_json+ let(:auth_strategy) do+ Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken.strategy.with_user(user)end- let(:url) { storage.host }- let(:storage) { create(:nextcloud_storage, :with_oauth_client) }- let(:user) { create(:user) }- let(:token) { create(:oauth_client_token, user:, oauth_client: storage.oauth_client) }+ let(:file_link) { create(:file_link, origin_id: "182") }+ let(:not_existent_file_link) { create(:file_link, origin_id: "DeathStarNumberThree") }- before do- allow(Storages::Peripherals::StorageInteraction::Nextcloud::Util).to receive(:token).and_yield(token)+ subject { described_class.new(storage) }- stub_request(:post, "#{url}/ocs/v2.php/apps/dav/api/v1/direct").to_return(status: 200, body: json, headers: {})- end+ describe "#call" do+ it "responds with correct parameters" do+ expect(described_class).to respond_to(:call)- it "must return a download link URL" do- result = described_class.call(storage:, user:, file_link:)- expect(result).to be_success- expect(result.result).to eql(uri)- end+ method = described_class.method(:call)+ expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq auth_strategy], %i[keyreq file_link])+ end- context "if Nextcloud is running on a sub path" do- let(:storage) { create(:nextcloud_storage, :with_oauth_client, host: "https://example.com/html") }+ context "without outbound request involved" do+ context "with nil" do+ it "returns an error" do+ result = subject.call(auth_strategy:, file_link: nil)- it "must return a download link URL" do- result = described_class.call(storage:, user:, file_link:)- expect(result).to be_success- expect(result.result).to eql(uri)+ expect(result).to be_failure+ expect(result.error_source).to eq(described_class)+ expect(result.result).to eq(:error)+ end+ endend- end- describe "with outbound request returning 200 and an empty body" do- before do- stub_request(:post, "#{url}/ocs/v2.php/apps/dav/api/v1/direct").to_return(status: 200, body: "")- end+ context "with outbound request successful" do+ it "returns a result with a download url", vcr: "nextcloud/download_link_query_success" do+ download_link = subject.call(auth_strategy:, file_link:)- it "must return :unauthorized ServiceResult" do- result = described_class.call(user:, file_link:, storage:)- expect(result).to be_failure- expect(result.errors.code).to be(:unauthorized)- end- end+ expect(download_link).to be_success- shared_examples_for "outbound is failing" do |code = 500, symbol = :error|- describe "with outbound request returning #{code}" do- before do- stub_request(:post, "#{url}/ocs/v2.php/apps/dav/api/v1/direct").to_return(status: code)+ uri = URI(download_link.result)+ expect(uri.host).to eq("nextcloud.local")+ expect(uri.path)+ .to match(/index.php\/apps\/integration_openproject\/direct\/[0-9a-zA-Z]+\/#{file_link.origin_name}/)end- it "must return :#{symbol} ServiceResult" do- result = described_class.call(user:, file_link:, storage:)- expect(result).to be_failure- expect(result.errors.code).to eq(symbol)+ it "returns an error if the file is not found", vcr: "nextcloud/download_link_query_not_found" do+ download_link = subject.call(auth_strategy:, file_link: not_existent_file_link)++ expect(download_link).to be_failure+ expect(download_link.error_source).to eq(described_class)+ expect(download_link.result).to eq(:not_found)endend- end- include_examples "outbound is failing", 404, :not_found- include_examples "outbound is failing", 401, :unauthorized- include_examples "outbound is failing", 500, :error+ context "with outbound request returning 200 and an empty body" do+ it "refreshes the token and returns success", vcr: "nextcloud/download_link_query_unauthorized" do+ download_link = subject.call(auth_strategy:, file_link:)++ expect(download_link).to be_success++ uri = URI(download_link.result)+ expect(uri.host).to eq("nextcloud.local")+ expect(uri.path)+ .to match(/index.php\/apps\/integration_openproject\/direct\/[0-9a-zA-Z]+\/#{file_link.origin_name}/)+ end+ end+ endenddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/download_link_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/download_link_query_spec.rbindex c46e1a5cae3..73462763681 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/download_link_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/download_link_query_spec.rb@@ -31,36 +31,58 @@require "spec_helper"require_module_spec_helper-RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::DownloadLinkQuery, :webmock do- let(:storage) { create(:one_drive_storage, :with_oauth_client, drive_id: "JUMBLEOFLETTERSANDNUMB3R5") }+RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::DownloadLinkQuery, :vcr, :webmock do+ using Storages::Peripherals::ServiceResultRefinements+let(:user) { create(:user) }- let(:file_link) { create(:file_link) }- let(:token) { create(:oauth_client_token, oauth_client: storage.oauth_client, user:) }+ let(:storage) { create(:sharepoint_dev_drive_storage, oauth_client_token_user: user) }+ let(:auth_strategy) do+ Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken.strategy.with_user(user)+ end- subject(:download_link_query) { described_class.new(storage) }+ let(:file_link) { create(:file_link, origin_id: "01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE") }+ let(:not_existent_file_link) { create(:file_link, origin_id: "DeathStarNumberThree") }- before do- allow(Storages::Peripherals::StorageInteraction::OneDrive).to receive(:token).and_yield(token)- stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_link.origin_id}/content")- .with(headers: { "Authorization" => "Bearer #{token.access_token}" })- .and_return(status: 302, body: nil, headers: { "Location" => "https://somecool.link/from/microsoft" })- end+ subject { described_class.new(storage) }- it "returns a result with a download url" do- download_link = download_link_query.call(user:, file_link:)+ describe "#call" do+ it "responds with correct parameters" do+ expect(described_class).to respond_to(:call)- expect(download_link).to be_success- expect(download_link.result).to eq("https://somecool.link/from/microsoft")- end+ method = described_class.method(:call)+ expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq auth_strategy], %i[keyreq file_link])+ end++ context "without outbound request involved" do+ context "with nil" do+ it "returns an error" do+ result = subject.call(auth_strategy:, file_link: nil)++ expect(result).to be_failure+ expect(result.error_source).to eq(described_class)+ expect(result.result).to eq(:error)+ end+ end+ end++ context "with outbound request successful" do+ it "returns a result with a download url", vcr: "one_drive/download_link_query_success" do+ download_link = subject.call(auth_strategy:, file_link:)++ expect(download_link).to be_success- it "return an error if any other response is received" do- stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_link.origin_id}/content")- .with(headers: { "Authorization" => "Bearer #{token.access_token}" })- .and_return(status: 200, body: "")+ uri = URI(download_link.result)+ expect(uri.host).to eq("finn.sharepoint.com")+ expect(uri.path).to eq("/sites/openprojectfilestoragetests/_layouts/15/download.aspx")+ end- download_link = download_link_query.call(user:, file_link:)+ it "returns an error if the file is not found", vcr: "one_drive/download_link_query_not_found" do+ download_link = subject.call(auth_strategy:, file_link: not_existent_file_link)- expect(download_link).to be_failure- expect(download_link.result).to eq :error+ expect(download_link).to be_failure+ expect(download_link.error_source).to eq(described_class)+ expect(download_link.result).to eq(:not_found)+ end+ endendenddiff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_not_found.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_not_found.ymlnew file mode 100644index 00000000000..928ae15557d--- /dev/null+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_not_found.yml@@ -0,0 +1,83 @@+---+http_interactions:+- request:+ method: post+ uri: https://nextcloud.local/ocs/v2.php/apps/dav/api/v1/direct+ body:+ encoding: UTF-8+ string: '{"fileId":"DeathStarNumberThree"}'+ headers:+ Ocs-Apirequest:+ - 'true'+ Accept:+ - application/json+ Authorization:+ - Bearer <BEARER TOKEN>+ User-Agent:+ - httpx.rb/1.2.3+ Accept-Encoding:+ - gzip, deflate+ Content-Type:+ - application/json; charset=utf-8+ Content-Length:+ - '33'+ response:+ status:+ code: 404+ message: Not Found+ headers:+ Cache-Control:+ - no-cache, no-store, must-revalidate+ Content-Security-Policy:+ - default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'+ Content-Type:+ - application/json; charset=utf-8+ Date:+ - Mon, 08 Apr 2024 11:45:08 GMT+ Expires:+ - Thu, 19 Nov 1981 08:52:00 GMT+ Feature-Policy:+ - autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone+ 'none';payment 'none'+ Pragma:+ - no-cache+ Referrer-Policy:+ - no-referrer+ Server:+ - Apache/2.4.57 (Debian)+ Set-Cookie:+ - ocirabgzify6=a2f996f3ca668255552213b8f9f091a2; path=/; secure; HttpOnly; SameSite=Lax,+ oc_sessionPassphrase=aIbW5xgiklv%2Fcfy4ntVIlzu3JMbuSiRJiXSk8ppLfI2gFKnJYXdBBVkte0boPAZC1p58VWSVgWFrZpFn8JNXGvMmRARg4nkegifImFgoO3njSdxgOPyt2MmBRp%2BNBTkp;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, __Host-nc_sameSiteCookielax=true;+ path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax,+ __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri,+ 31-Dec-2100 23:59:59 GMT; SameSite=strict, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=a2f996f3ca668255552213b8f9f091a2;+ path=/; secure; HttpOnly; SameSite=Lax+ X-Content-Type-Options:+ - nosniff+ X-Frame-Options:+ - SAMEORIGIN+ X-Permitted-Cross-Domain-Policies:+ - none+ X-Powered-By:+ - PHP/8.2.16+ X-Request-Id:+ - pmHzKTYbkUkfiUSko8Er+ X-Robots-Tag:+ - noindex, nofollow+ X-Xss-Protection:+ - 1; mode=block+ Content-Length:+ - '77'+ body:+ encoding: UTF-8+ string: '{"ocs":{"meta":{"status":"failure","statuscode":404,"message":""},"data":[]}}'+ recorded_at: Mon, 08 Apr 2024 11:45:08 GMT+recorded_with: VCR 6.2.0diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_success.ymlnew file mode 100644index 00000000000..233b1009c28--- /dev/null+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_success.yml@@ -0,0 +1,85 @@+---+http_interactions:+- request:+ method: post+ uri: https://nextcloud.local/ocs/v2.php/apps/dav/api/v1/direct+ body:+ encoding: UTF-8+ string: '{"fileId":"182"}'+ headers:+ Ocs-Apirequest:+ - 'true'+ Accept:+ - application/json+ Authorization:+ - Bearer <BEARER TOKEN>+ User-Agent:+ - httpx.rb/1.2.3+ Accept-Encoding:+ - gzip, deflate+ Content-Type:+ - application/json; charset=utf-8+ Content-Length:+ - '16'+ response:+ status:+ code: 200+ message: OK+ headers:+ Cache-Control:+ - no-cache, no-store, must-revalidate+ Content-Encoding:+ - gzip+ Content-Security-Policy:+ - default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'+ Content-Type:+ - application/json; charset=utf-8+ Date:+ - Mon, 08 Apr 2024 11:34:13 GMT+ Expires:+ - Thu, 19 Nov 1981 08:52:00 GMT+ Feature-Policy:+ - autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone+ 'none';payment 'none'+ Pragma:+ - no-cache+ Referrer-Policy:+ - no-referrer+ Server:+ - Apache/2.4.57 (Debian)+ Set-Cookie:+ - ocirabgzify6=d78505eb55e4bc58109b19b7121e8152; path=/; secure; HttpOnly; SameSite=Lax,+ oc_sessionPassphrase=de%2Fy4BrNKSmwAyqI5TXmTQEm00bLbAQuUO588brHwO3mqMDbLAX%2FV8UsKg79X3dVOiiu2ciGAFtiECiAa6vPM43vv3kwIZ6ko8gRqNfmTyKCGrXUj5HJlXGrM6hLOVkZ;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, __Host-nc_sameSiteCookielax=true;+ path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax,+ __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri,+ 31-Dec-2100 23:59:59 GMT; SameSite=strict, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=d78505eb55e4bc58109b19b7121e8152;+ path=/; secure; HttpOnly; SameSite=Lax+ X-Content-Type-Options:+ - nosniff+ X-Frame-Options:+ - SAMEORIGIN+ X-Permitted-Cross-Domain-Policies:+ - none+ X-Powered-By:+ - PHP/8.2.16+ X-Request-Id:+ - 2Qcm5eyA9mV2rlnCD0bF+ X-Robots-Tag:+ - noindex, nofollow+ X-Xss-Protection:+ - 1; mode=block+ Content-Length:+ - '183'+ body:+ encoding: UTF-8+ string: '{"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"url":"https:\/\/nextcloud.local\/remote.php\/direct\/I5uqL5tARwsUPNuqSzTMJ8dvsCmqAxBF18ltlmzDEEFn5ZOyfbkAFoJ4rMSV"}}}'+ recorded_at: Mon, 08 Apr 2024 11:34:13 GMT+recorded_with: VCR 6.2.0diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_unauthorized.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_unauthorized.ymlnew file mode 100644index 00000000000..3cafd5c27d0--- /dev/null+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/download_link_query_unauthorized.yml@@ -0,0 +1,231 @@+---+http_interactions:+- request:+ method: post+ uri: https://nextcloud.local/ocs/v2.php/apps/dav/api/v1/direct+ body:+ encoding: UTF-8+ string: '{"fileId":"182"}'+ headers:+ Ocs-Apirequest:+ - 'true'+ Accept:+ - application/json+ Authorization:+ - Bearer <BEARER TOKEN>+ User-Agent:+ - httpx.rb/1.2.3+ Accept-Encoding:+ - gzip, deflate+ Content-Type:+ - application/json; charset=utf-8+ Content-Length:+ - '16'+ response:+ status:+ code: 200+ message: OK+ headers:+ Cache-Control:+ - no-store, no-cache, must-revalidate+ Content-Security-Policy:+ - 'default-src ''self''; script-src ''self'' ''nonce-Ym5ici9rMUMyVXhrTW4xZVdnSGpteDlTM3NqbERtQVBwS09McHdLTzVFWT06WGlEYnl5c2txWHRXV2dVSkkxYTUvRkEwbkszT1hSQmgzUGJqa2s3WjFpMD0='';+ style-src ''self'' ''unsafe-inline''; frame-src *; img-src * data: blob:;+ font-src ''self'' data:; media-src *; connect-src *; object-src ''none'';+ base-uri ''self'';'+ Content-Type:+ - text/html; charset=UTF-8+ Date:+ - Mon, 08 Apr 2024 11:49:14 GMT+ Expires:+ - Thu, 19 Nov 1981 08:52:00 GMT+ Pragma:+ - no-cache+ Referrer-Policy:+ - no-referrer+ Server:+ - Apache/2.4.57 (Debian)+ Set-Cookie:+ - ocirabgzify6=7571b36253a7b5bb08fed3bd3704a948; path=/; secure; HttpOnly; SameSite=Lax,+ oc_sessionPassphrase=bRr4g92CSjqgQHBqGoGukTd2MQWaMuNIcD7RCXfooQDf4YOxz4NEnLUgmyGoA%2BMKZDSpxUt9At8WmawFyvoXg6Y%2FHEHr9n8WcdD%2B1sV3NeAoDhgfBBew7jUrk8N8p15w;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=7571b36253a7b5bb08fed3bd3704a948;+ path=/; secure; HttpOnly; SameSite=Lax, __Host-nc_sameSiteCookielax=true;+ path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax,+ __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri,+ 31-Dec-2100 23:59:59 GMT; SameSite=strict, ocirabgzify6=7571b36253a7b5bb08fed3bd3704a948;+ path=/; secure; HttpOnly; SameSite=Lax+ X-Content-Type-Options:+ - nosniff+ X-Frame-Options:+ - SAMEORIGIN+ X-Permitted-Cross-Domain-Policies:+ - none+ X-Powered-By:+ - PHP/8.2.16+ X-Robots-Tag:+ - noindex, nofollow+ X-Xss-Protection:+ - 1; mode=block+ Content-Length:+ - '0'+ body:+ encoding: UTF-8+ string: ''+ recorded_at: Mon, 08 Apr 2024 11:49:14 GMT+- request:+ method: post+ uri: https://nextcloud.local/index.php/apps/oauth2/api/v1/token+ body:+ encoding: ASCII-8BIT+ string: grant_type=refresh_token&scope=&client_id=7fj7lpG0GOqwOGhHAyfGwd1oEgtbTto7mctu0IaSN3SE79o9Xs0q8k3kDiEwXDrM&client_secret=j7RoyauWeIpMc7cYdY3lewCGKxdgiAowonpGzmAuj9iRSvYBAGXhP7hvz9Hp7skR&refresh_token=FONj4kNQyzalItisiPfffipcIL0Ou4X5Q0fy0le2OmBkozdkzh8JNWGXnK9ZuQbDbCBe9B5wEpZzKofVUJdANHQ1yfX8wrqJtB6SbRqCcDEjzuSTssNwNYqIRsLHj4br+ headers:+ User-Agent:+ - httpx.rb/1.2.3+ Accept:+ - "*/*"+ Accept-Encoding:+ - gzip, deflate+ Content-Type:+ - application/x-www-form-urlencoded+ Content-Length:+ - '328'+ response:+ status:+ code: 200+ message: OK+ headers:+ Cache-Control:+ - no-cache, no-store, must-revalidate+ Content-Encoding:+ - gzip+ Content-Security-Policy:+ - default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'+ Content-Type:+ - application/json; charset=utf-8+ Date:+ - Mon, 08 Apr 2024 11:49:14 GMT+ Expires:+ - Thu, 19 Nov 1981 08:52:00 GMT+ Feature-Policy:+ - autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone+ 'none';payment 'none'+ Pragma:+ - no-cache+ Referrer-Policy:+ - no-referrer+ Server:+ - Apache/2.4.57 (Debian)+ Set-Cookie:+ - ocirabgzify6=32fdd4735f2889baa600992b8dce34b1; path=/; secure; HttpOnly; SameSite=Lax,+ oc_sessionPassphrase=8abrUaAOLRAvEmRgGKwbze42COmfd9SdI%2BnXosFrAs1UrBWMf0GfrM4hkElBwutAyn0uDZOjQDePQZHXmvzzTAHvKCHnq%2B3X%2BmqWeuUpUqP9eTeRAcKgNe8JpDXPxVq2;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=32fdd4735f2889baa600992b8dce34b1;+ path=/; secure; HttpOnly; SameSite=Lax, __Host-nc_sameSiteCookielax=true;+ path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax,+ __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri,+ 31-Dec-2100 23:59:59 GMT; SameSite=strict, ocirabgzify6=32fdd4735f2889baa600992b8dce34b1;+ path=/; secure; HttpOnly; SameSite=Lax+ X-Content-Type-Options:+ - nosniff+ X-Frame-Options:+ - SAMEORIGIN+ X-Nextcloud-Bruteforce-Throttled:+ - 200ms+ X-Permitted-Cross-Domain-Policies:+ - none+ X-Powered-By:+ - PHP/8.2.16+ X-Request-Id:+ - 8qP63HFarS2USyt8ZWfG+ X-Robots-Tag:+ - noindex, nofollow+ X-Xss-Protection:+ - 1; mode=block+ Content-Length:+ - '270'+ body:+ encoding: UTF-8+ string: '{"access_token":"<ACCESS_TOKEN>","token_type":"Bearer","expires_in":3600,"refresh_token":"4QiBy5UYfaB2F0akcmEEAX2k930io4lSDlyt6GAp8YZrbel9u8RNpEG1iJacenEn4Het529v6MSOUEp7F1dGK3TanOHs8rIRY9cGtmJzPpmb4mBsaevAVhZOZhpxDA6h","user_id":"admin"}'+ recorded_at: Mon, 08 Apr 2024 11:49:14 GMT+- request:+ method: post+ uri: https://nextcloud.local/ocs/v2.php/apps/dav/api/v1/direct+ body:+ encoding: UTF-8+ string: '{"fileId":"182"}'+ headers:+ Ocs-Apirequest:+ - 'true'+ Accept:+ - application/json+ User-Agent:+ - httpx.rb/1.2.3+ Accept-Encoding:+ - gzip, deflate+ Content-Type:+ - application/json; charset=utf-8+ Content-Length:+ - '16'+ Authorization:+ - Bearer <BEARER TOKEN>+ response:+ status:+ code: 200+ message: OK+ headers:+ Cache-Control:+ - no-cache, no-store, must-revalidate+ Content-Encoding:+ - gzip+ Content-Security-Policy:+ - default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'+ Content-Type:+ - application/json; charset=utf-8+ Date:+ - Mon, 08 Apr 2024 11:49:14 GMT+ Expires:+ - Thu, 19 Nov 1981 08:52:00 GMT+ Feature-Policy:+ - autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone+ 'none';payment 'none'+ Pragma:+ - no-cache+ Referrer-Policy:+ - no-referrer+ Server:+ - Apache/2.4.57 (Debian)+ Set-Cookie:+ - ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854; path=/; secure; HttpOnly; SameSite=Lax,+ oc_sessionPassphrase=joJPkVh672p401VEcBmDAEvEYVHvoMbBKBc1LdvxY%2B%2F4S9SplYlscEqJjQ4luQ%2BdbtIilHtt0tYbcg%2BeIvyrXUVgy5seyiJFU%2BQu3K7p7uqBN90cD6keFsGMNXuf%2FyQf;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, __Host-nc_sameSiteCookielax=true;+ path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax,+ __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri,+ 31-Dec-2100 23:59:59 GMT; SameSite=strict, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax, ocirabgzify6=b4494cef0f6f34a42b21ee3db7141854;+ path=/; secure; HttpOnly; SameSite=Lax+ X-Content-Type-Options:+ - nosniff+ X-Frame-Options:+ - SAMEORIGIN+ X-Permitted-Cross-Domain-Policies:+ - none+ X-Powered-By:+ - PHP/8.2.16+ X-Request-Id:+ - y3jxZktoCQ4WGfESLoyu+ X-Robots-Tag:+ - noindex, nofollow+ X-Xss-Protection:+ - 1; mode=block+ Content-Length:+ - '182'+ body:+ encoding: UTF-8+ string: '{"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"url":"https:\/\/nextcloud.local\/remote.php\/direct\/tfqJBvmg8n89HX0iFVMhQHVYLTKsJx69aNnbGjU8HOrXfKTTVMBTFFu60SMI"}}}'+ recorded_at: Mon, 08 Apr 2024 11:49:14 GMT+recorded_with: VCR 6.2.0diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_not_found.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_not_found.ymlnew file mode 100644index 00000000000..cabdb7d75b7--- /dev/null+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_not_found.yml@@ -0,0 +1,45 @@+---+http_interactions:+- request:+ method: get+ uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/DeathStarNumberThree/content+ body:+ encoding: US-ASCII+ string: ''+ headers:+ Authorization:+ - Bearer <BEARER TOKEN>+ User-Agent:+ - httpx.rb/1.2.3+ Accept:+ - "*/*"+ Accept-Encoding:+ - gzip, deflate+ response:+ status:+ code: 404+ message: Not Found+ headers:+ Cache-Control:+ - no-store, no-cache+ Content-Type:+ - application/json; charset=utf-8+ Content-Encoding:+ - gzip+ Vary:+ - Accept-Encoding+ Strict-Transport-Security:+ - max-age=31536000+ Request-Id:+ - b1a39085-f4ec-4c47-9c42-611df2c6d1d4+ Client-Request-Id:+ - b1a39085-f4ec-4c47-9c42-611df2c6d1d4+ X-Ms-Ags-Diagnostic:+ - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"FR1PEPF00000C20"}}'+ Date:+ - Mon, 08 Apr 2024 11:15:04 GMT+ body:+ encoding: UTF-8+ string: '{"error":{"code":"itemNotFound","message":"Item not found"}}'+ recorded_at: Mon, 08 Apr 2024 11:15:04 GMT+recorded_with: VCR 6.2.0diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_success.ymlnew file mode 100644index 00000000000..9f38287a8c4--- /dev/null+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/download_link_query_success.yml@@ -0,0 +1,45 @@+---+http_interactions:+- request:+ method: get+ uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE/content+ body:+ encoding: US-ASCII+ string: ''+ headers:+ Authorization:+ - Bearer <BEARER TOKEN>+ User-Agent:+ - httpx.rb/1.2.3+ Accept:+ - "*/*"+ Accept-Encoding:+ - gzip, deflate+ response:+ status:+ code: 302+ message: Found+ headers:+ Cache-Control:+ - no-store, no-cache+ Content-Type:+ - application/octet-stream+ Location:+ - https://finn.sharepoint.com/sites/openprojectfilestoragetests/_layouts/15/download.aspx?UniqueId=035fa4a3-922a-4431-9825-8d6daea99e44&Translate=false&tempauth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBfZGlzcGxheW5hbWUiOiJPcGVuUHJvamVjdCBEZXYgQXBwIiwiYXBwaWQiOiI0MjYyZGYyYi03N2JiLTQ5YzItYTVkZi0yODM1NWRhNjc2ZDIiLCJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvZmlubi5zaGFyZXBvaW50LmNvbUA0ZDQ0YmYzNi05YjU2LTQ1YzAtODgwNy1iYmYzODZkZDA0N2YiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzMjAwMmVkMmNhMDBlQGxpdmUuY29tIiwiY2lkIjoiSmlBTzVId0Rva1d4ZnEwUzZOZDJmZz09IiwiZW5kcG9pbnR1cmwiOiIwdHp4QWFzNTVycUZJNU1RVUF5eFN4Sk1iYTgxRktaU0pObWJDMnNQMGtVPSIsImVuZHBvaW50dXJsTGVuZ3RoIjoiMTQ5IiwiZXhwIjoiMTcxMjU3NzY4MCIsImZhbWlseV9uYW1lIjoiU2NodWJlcnQiLCJnaXZlbl9uYW1lIjoiRXJpYyIsImlwYWRkciI6IjIwLjE5MC4xOTAuOTYiLCJpc2xvb3BiYWNrIjoiVHJ1ZSIsImlzcyI6IjAwMDAwMDAzLTAwMDAtMGZmMS1jZTAwLTAwMDAwMDAwMDAwMCIsIm5iZiI6IjE3MTI1NzQwODAiLCJwdWlkIjoiMTAwMzIwMDJFRDJDQTAwRSIsInNjcCI6ImFsbGZpbGVzLndyaXRlIGFsbHNpdGVzLnJlYWQgYWxsc2l0ZXMud3JpdGUgYWxscHJvZmlsZXMucmVhZCIsInNpdGVpZCI6Ik1XSTBZalkxTnpZdE9UQTJaQzAwWkRrMExUaG1ORGt0Tm1Rd01HRTVOVEEzWWpVdyIsInRpZCI6IjRkNDRiZjM2LTliNTYtNDVjMC04ODA3LWJiZjM4NmRkMDQ3ZiIsInR0IjoiMiIsInVwbiI6ImVzY2h1YmVydC5vcF9vdXRsb29rLmNvbSNleHQjQGZpbm4ub25taWNyb3NvZnQuY29tIiwidmVyIjoiaGFzaGVkcHJvb2Z0b2tlbiJ9.Umai1d7GO_BKZYAU-63vCUp4nHbp7nQq2cUbowxNhS8&ApiVersion=2.0+ Strict-Transport-Security:+ - max-age=31536000+ Request-Id:+ - e40e2026-037c-45a2-b17e-ad12e8d7767e+ Client-Request-Id:+ - e40e2026-037c-45a2-b17e-ad12e8d7767e+ X-Ms-Ags-Diagnostic:+ - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"FR1PEPF00000AF2"}}'+ Date:+ - Mon, 08 Apr 2024 11:01:19 GMT+ Content-Length:+ - '0'+ body:+ encoding: UTF-8+ string: ''+ recorded_at: Mon, 08 Apr 2024 11:01:20 GMT+recorded_with: VCR 6.2.0