Skip to content

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

[#55899] refactor rename files command

Eric Schubert99066008b95a
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
index 12f4da101ee..edb210771e6 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb
@@ -28,47 +28,77 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module Storages::Peripherals::StorageInteraction::Nextcloud
- class RenameFileCommand
- using Storages::Peripherals::ServiceResultRefinements
+module Storages
+ module Peripherals
+ module StorageInteraction
+ module Nextcloud
+ class RenameFileCommand
+ def self.call(storage:, auth_strategy:, file_id:, name:)
+ new(storage).call(auth_strategy:, file_id:, name:)
+ end
- def initialize(storage)
- @uri = storage.uri
- @base_path = Util.join_uri_path(@uri, "remote.php/dav/files", CGI.escapeURIComponent(storage.username))
- @username = storage.username
- @password = storage.password
- end
+ def initialize(storage)
+ @storage = storage
+ end
- def self.call(storage:, source:, target:)
- new(storage).call(source:, target:)
- end
+ def call(auth_strategy:, file_id:, name:)
+ validate_input_data(file_id:, name:).on_failure { |failure| return failure }
+
+ origin_user_id = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
+ .on_failure { |failure| return failure }
+ .result
+
+ info = FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
+ .on_failure { |failure| return failure }
+ .result
+
+ make_request(auth_strategy, origin_user_id, info, name).on_failure { |failure| return failure }
+
+ FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
+ .map { |file_info| Util.storage_file_from_file_info(file_info) }
+ end
+
+ private
+
+ def make_request(auth_strategy, user, file_info, name)
+ base_path = Util.join_uri_path(@storage.uri, "remote.php/dav/files", user)
+ source_path = Util.join_uri_path(base_path, file_info.location)
+ destination = Util.join_uri_path(base_path, target_path(file_info, name))
+
+ Authentication[auth_strategy].call(storage: @storage) do |http|
+ handle_response http.request("MOVE", source_path, headers: { "Destination" => destination })
+ end
+ end
- def call(source:, target:)
- response = OpenProject
- .httpx
- .basic_auth(@username, @password)
- .request(
- "MOVE",
- Util.join_uri_path(@base_path, Util.escape_path(source)),
- headers: {
- "Destination" => Util.join_uri_path(@uri.path,
- "remote.php/dav/files",
- CGI.escapeURIComponent(@username),
- Util.escape_path(target))
- }
- )
+ def target_path(info, name)
+ info.location.gsub(CGI.escapeURIComponent(info.name), CGI.escapeURIComponent(name))
+ end
- error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
+ def validate_input_data(file_id:, name:)
+ if file_id.blank? || name.blank?
+ ServiceResult.failure(result: :error,
+ errors: StorageError.new(code: :error,
+ data: StorageErrorData.new(source: self.class),
+ log_message: "Invalid input data!"))
+ else
+ ServiceResult.success
+ end
+ end
- case response
- in { status: 200..299 }
- ServiceResult.success
- in { status: 404 }
- Util.error(:not_found, "Outbound request destination not found", error_data)
- in { status: 401 }
- Util.error(:unauthorized, "Outbound request not authorized", error_data)
- else
- Util.error(:error, "Outbound request failed", error_data)
+ def handle_response(response)
+ error_data = StorageErrorData.new(source: self.class, payload: response)
+ case response
+ in { status: 200..299 }
+ ServiceResult.success
+ in { status: 404 }
+ Util.error(:not_found, "Outbound request destination not found", error_data)
+ in { status: 401 }
+ Util.error(:unauthorized, "Outbound request not authorized", error_data)
+ else
+ Util.error(:error, "Outbound request failed", error_data)
+ end
+ end
+ end
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
index 23ebcad28f5..f94717bafb8 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
@@ -69,11 +69,8 @@ module Storages
end
def join_uri_path(uri, *)
- # We use `File.join` to ensure single `/` in between every part. This API will break if executed on a
- # Windows context, as it used `\` as file separators. But we anticipate that OpenProject
- # Server is not run on a Windows context.
- # URI::join cannot be used, as it behaves very different for the path parts depending on trailing slashes.
- File.join(uri.to_s, *)
+ joined = File.join(uri.to_s, *)
+ joined.tr("\\", "/")
end
def token(user:, configuration:, &)
@@ -134,6 +131,21 @@ module Storages
def failure(code:, data:, log_message:)
ServiceResult.failure(result: code, errors: StorageError.new(code:, data:, log_message:))
end
+
+ def storage_file_from_file_info(storage_file_info)
+ StorageFile.new(
+ id: storage_file_info.id,
+ name: storage_file_info.name,
+ size: storage_file_info.size,
+ mime_type: storage_file_info.mime_type,
+ created_at: storage_file_info.created_at,
+ last_modified_at: storage_file_info.last_modified_at,
+ created_by_name: storage_file_info.owner_name,
+ last_modified_by_name: storage_file_info.last_modified_by_name,
+ location: storage_file_info.location,
+ permissions: storage_file_info.permissions
+ )
+ end
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/auth_check_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/auth_check_query.rb
index efb9588f8ae..9fe43ff52b4 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/auth_check_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/auth_check_query.rb
@@ -33,10 +33,6 @@ module Storages
module StorageInteraction
module OneDrive
class AuthCheckQuery
- Auth = ::Storages::Peripherals::StorageInteraction::Authentication
-
- using ServiceResultRefinements
-
def self.call(storage:, auth_strategy:)
new(storage).call(auth_strategy:)
end
@@ -46,7 +42,7 @@ module Storages
end
def call(auth_strategy:)
- Auth[auth_strategy].call(storage: @storage) do |http|
+ Authentication[auth_strategy].call(storage: @storage) do |http|
handle_response http.get(Util.join_uri_path(@storage.uri, "/v1.0/me"))
end
end
@@ -58,12 +54,12 @@ module Storages
in { status: 200..299 }
ServiceResult.success
in { status: 401 }
- ServiceResult.failure(result: :unauthorized, errors: ::Storages::StorageError.new(code: :unauthorized))
+ ServiceResult.failure(result: :unauthorized, errors: StorageError.new(code: :unauthorized))
in { status: 403 }
- ServiceResult.failure(result: :forbidden, errors: ::Storages::StorageError.new(code: :forbidden))
+ ServiceResult.failure(result: :forbidden, errors: StorageError.new(code: :forbidden))
else
- data = ::Storages::StorageErrorData.new(source: self.class, payload: response)
- ServiceResult.failure(result: :error, errors: ::Storages::StorageError.new(code: :error, data:))
+ data = StorageErrorData.new(source: self.class, payload: response)
+ ServiceResult.failure(result: :error, errors: StorageError.new(code: :error, data:))
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
index 3ea82367012..e7c5db32354 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
@@ -64,7 +64,7 @@ module Storages
def handle_response(response)
case response
in { status: 200..299 }
- ServiceResult.success(result: file_info_for(MultiJson.load(response.body, symbolize_keys: true)),
+ ServiceResult.success(result: Util.storage_file_from_json(MultiJson.load(response.body, symbolize_keys: true)),
message: "Folder was successfully created.")
in { status: 404 }
ServiceResult.failure(result: :not_found,
@@ -81,21 +81,6 @@ module Storages
end
end
- def file_info_for(json_file)
- StorageFile.new(
- id: json_file[:id],
- name: json_file[:name],
- size: json_file[:size],
- mime_type: Util.mime_type(json_file),
- created_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :createdDateTime)),
- last_modified_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :lastModifiedDateTime)),
- created_by_name: json_file.dig(:createdBy, :user, :displayName),
- last_modified_by_name: json_file.dig(:lastModifiedBy, :user, :displayName),
- location: Util.extract_location(json_file[:parentReference], json_file[:name]),
- permissions: %i[readable writeable]
- )
- end
-
def payload(folder_name)
{
name: folder_name,
diff --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.rb
index 6c1e50c3a26..000ac6c43e1 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,8 +33,6 @@ module Storages
module StorageInteraction
module OneDrive
class DownloadLinkQuery
- Auth = ::Storages::Peripherals::StorageInteraction::Authentication
-
def self.call(storage:, auth_strategy:, file_link:)
new(storage).call(auth_strategy:, file_link:)
end
@@ -50,7 +48,7 @@ module Storages
log_message: "File link can not be nil."))
end
- Auth[auth_strategy].call(storage: @storage) do |http|
+ Authentication[auth_strategy].call(storage: @storage) do |http|
handle_errors http.get(Util.join_uri_path(@storage.uri, uri_path_for(file_link.origin_id)))
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
index f9d90395bca..4c0d64d7cca 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
@@ -35,8 +35,6 @@ module Storages
class FilesQuery
FIELDS = "?$select=id,name,size,webUrl,lastModifiedBy,createdBy,fileSystemInfo,file,folder,parentReference"
- using ServiceResultRefinements
-
def self.call(storage:, auth_strategy:, folder:)
new(storage).call(auth_strategy:, folder:)
end
@@ -81,27 +79,12 @@ module Storages
end
def storage_files(json_files)
- files = json_files.map { |json| storage_file(json) }
+ files = json_files.map { |json| Util.storage_file_from_json(json) }
parent_reference = json_files.first[:parentReference]
StorageFiles.new(files, parent(parent_reference), forge_ancestors(parent_reference))
end
- def storage_file(json_file)
- StorageFile.new(
- id: json_file[:id],
- name: json_file[:name],
- size: json_file[:size],
- mime_type: Util.mime_type(json_file),
- created_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :createdDateTime)),
- last_modified_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :lastModifiedDateTime)),
- created_by_name: json_file.dig(:createdBy, :user, :displayName),
- last_modified_by_name: json_file.dig(:lastModifiedBy, :user, :displayName),
- location: Util.escape_path(Util.extract_location(json_file[:parentReference], json_file[:name])),
- permissions: %i[readable writeable]
- )
- end
-
def empty_response(http, folder)
response = http.get(Util.join_uri_path(@uri, location_uri_path_for(folder) + FIELDS))
handle_response(response, :id).map do |parent_location_id|
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_file_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_file_link_query.rb
index 8409576c9ac..9f548d11fb9 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_file_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_file_link_query.rb
@@ -33,9 +33,6 @@ module Storages
module StorageInteraction
module OneDrive
class OpenFileLinkQuery
- using ::Storages::Peripherals::ServiceResultRefinements
- Auth = ::Storages::Peripherals::StorageInteraction::Authentication
-
def self.call(storage:, auth_strategy:, file_id:, open_location: false)
new(storage).call(auth_strategy:, file_id:, open_location:)
end
@@ -46,7 +43,7 @@ module Storages
end
def call(auth_strategy:, file_id:, open_location: false)
- Auth[auth_strategy].call(storage: @storage) do |http|
+ Authentication[auth_strategy].call(storage: @storage) do |http|
if open_location
request_parent_id(http, file_id).on_success { |parent_id| return request_web_url(http, parent_id.result) }
else
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_storage_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_storage_query.rb
index 8a7242e1da2..33ea6da2d93 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_storage_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/open_storage_query.rb
@@ -33,8 +33,6 @@ module Storages
module StorageInteraction
module OneDrive
class OpenStorageQuery
- Auth = ::Storages::Peripherals::StorageInteraction::Authentication
-
def self.call(storage:, auth_strategy:)
new(storage).call(auth_strategy:)
end
@@ -44,7 +42,7 @@ module Storages
end
def call(auth_strategy:)
- Auth[auth_strategy].call(storage: @storage) do |http|
+ Authentication[auth_strategy].call(storage: @storage) do |http|
request_drive(http).map(&web_url)
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/rename_file_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/rename_file_command.rb
index 5099b2b7251..e236ec5c904 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/rename_file_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/rename_file_command.rb
@@ -33,29 +33,44 @@ module Storages
module StorageInteraction
module OneDrive
class RenameFileCommand
- def self.call(storage:, source:, target:)
- new(storage).call(source:, target:)
+ def self.call(storage:, auth_strategy:, file_id:, name:)
+ new(storage).call(auth_strategy:, file_id:, name:)
end
def initialize(storage)
@storage = storage
- @uri = storage.uri
end
- def call(source:, target:)
- Util.using_admin_token(@storage) do |http|
- response = http.patch(uri_path(source), body: { name: target }.to_json)
+ def call(auth_strategy:, file_id:, name:)
+ validate_input_data(file_id:, name:).on_failure { |failure| return failure }
- handle_response(response)
+ Authentication[auth_strategy].call(storage: @storage, http_options: Util.json_content_type) do |http|
+ handle_response http.patch(uri_path(file_id), body: { name: }.to_json)
end
end
private
+ def validate_input_data(file_id:, name:)
+ if file_id.blank? || name.blank?
+ ServiceResult.failure(result: :error,
+ errors: StorageError.new(code: :error,
+ data: StorageErrorData.new(source: self.class),
+ log_message: "Invalid input data!"))
+ else
+ ServiceResult.success
+ end
+ end
+
+ def uri_path(source)
+ "#{@storage.uri}v1.0/drives/#{@storage.drive_id}/items/#{source}"
+ end
+
+ # rubocop:disable Metrics/AbcSize
def handle_response(response)
case response
in { status: 200..299 }
- ServiceResult.success(result: storage_file(response.json(symbolize_keys: true)))
+ ServiceResult.success(result: Util.storage_file_from_json(response.json(symbolize_keys: true)))
in { status: 401 }
ServiceResult.failure(result: :unauthorized,
errors: Util.storage_error(response:, code: :unauthorized, source: self.class))
@@ -74,24 +89,7 @@ module Storages
end
end
- def storage_file(json_file)
- StorageFile.new(
- id: json_file[:id],
- name: json_file[:name],
- size: json_file[:size],
- mime_type: Util.mime_type(json_file),
- created_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :createdDateTime)),
- last_modified_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :lastModifiedDateTime)),
- created_by_name: json_file.dig(:createdBy, :user, :displayName),
- last_modified_by_name: json_file.dig(:lastModifiedBy, :user, :displayName),
- location: Util.extract_location(json_file[:parentReference], json_file[:name]),
- permissions: %i[readable writeable]
- )
- end
-
- def uri_path(source)
- "/v1.0/drives/#{@storage.drive_id}/items/#{source}"
- end
+ # rubocop:enable Metrics/AbcSize
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
index f7666b8e78d..059d4891cc5 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
@@ -125,6 +125,21 @@ module Storages
appendix = file_name.blank? ? "" : "/#{file_name}"
location.empty? ? "/#{file_name}" : "#{location}#{appendix}"
end
+
+ def storage_file_from_json(json)
+ StorageFile.new(
+ id: json[:id],
+ name: json[:name],
+ size: json[:size],
+ mime_type: Util.mime_type(json),
+ created_at: Time.zone.parse(json.dig(:fileSystemInfo, :createdDateTime)),
+ last_modified_at: Time.zone.parse(json.dig(:fileSystemInfo, :lastModifiedDateTime)),
+ created_by_name: json.dig(:createdBy, :user, :displayName),
+ last_modified_by_name: json.dig(:lastModifiedBy, :user, :displayName),
+ location: Util.escape_path(Util.extract_location(json[:parentReference], json[:name])),
+ permissions: %i[readable writeable]
+ )
+ end
end
end
end
diff --git a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb
index db20f46f610..1a0d4ec4f38 100644
--- a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb
+++ b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb
@@ -187,10 +187,11 @@ module Storages
current_path = id_folder_map[project_storage.project_folder_id]
if current_path != project_storage.managed_project_folder_path
- rename_folder(project_storage, current_path).on_failure do |service_result|
+ target_folder_name = name_from_path(project_storage.managed_project_folder_path)
+ rename_folder(project_storage.project_folder_id, target_folder_name).on_failure do |service_result|
format_and_log_error(service_result.errors,
- source: current_path,
- target: project_storage.managed_project_folder_path)
+ folder_id: project_storage.project_folder_id,
+ folder_name: current_path)
# we need to stop as this would mess with the other processes
return service_result
@@ -202,10 +203,14 @@ module Storages
ServiceResult.success
end
- def rename_folder(project_storage, current_name)
+ def name_from_path(path)
+ path.split("/").last
+ end
+
+ def rename_folder(folder_id, folder_name)
Peripherals::Registry
.resolve("nextcloud.commands.rename_file")
- .call(storage: @storage, source: current_name, target: project_storage.managed_project_folder_path)
+ .call(storage: @storage, auth_strategy:, file_id: folder_id, name: folder_name)
end
def create_folder(project_storage)
@@ -289,7 +294,7 @@ module Storages
end
def auth_strategy
- Peripherals::StorageInteraction::AuthenticationStrategies::BasicAuth.strategy
+ Peripherals::Registry.resolve("nextcloud.authentication.userless").call
end
def admin_client_tokens_scope
diff --git a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
index e025c018a53..3a656d6f0c0 100644
--- a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
+++ b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
@@ -107,11 +107,11 @@ module Storages
end
end
- def rename_folder(source, target)
+ def rename_folder(folder_id, folder_name)
Peripherals::Registry
.resolve("one_drive.commands.rename_file")
- .call(storage: @storage, source:, target:)
- .result_or { |error| format_and_log_error(error, source:, target:) }
+ .call(storage: @storage, auth_strategy:, file_id: folder_id, name: folder_name)
+ .result_or { |error| format_and_log_error(error, folder_id:, folder_name:) }
end
# rubocop:disable Metrics/AbcSize
diff --git a/modules/storages/spec/common/storages/peripherals/registry_spec.rb b/modules/storages/spec/common/storages/peripherals/registry_spec.rb
index 1c88d9aa85f..340607402d3 100644
--- a/modules/storages/spec/common/storages/peripherals/registry_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/registry_spec.rb
@@ -508,26 +508,6 @@ RSpec.describe Storages::Peripherals::Registry, :webmock do
end
end
- describe "#rename_file_command" do
- before do
- stub_request(:move, "https://example.com/remote.php/dav/files/OpenProject/OpenProject/asd")
- .with(
- headers: {
- "Authorization" => "Basic T3BlblByb2plY3Q6T3BlblByb2plY3RTZWN1cmVQYXNzd29yZA==",
- "Destination" => "/remote.php/dav/files/OpenProject/OpenProject/qwe"
- }
- ).to_return(status: 201, body: "", headers: {})
- end
-
- describe "with Nextcloud storage type selected" do
- it "moves the file" do
- result = registry.resolve("nextcloud.commands.rename_file").call(storage:, source: "OpenProject/asd",
- target: "OpenProject/qwe")
- expect(result).to be_success
- end
- end
- end
-
describe "#delete_folder_command" do
let(:auth_strategy) { Storages::Peripherals::StorageInteraction::AuthenticationStrategies::BasicAuth.strategy }
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command_spec.rb
new file mode 100644
index 00000000000..ba39495963d
--- /dev/null
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command_spec.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+require_module_spec_helper
+
+RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::RenameFileCommand, :webmock do
+ let(:user) { create(:user) }
+ let(:storage) do
+ create(:nextcloud_storage_with_local_connection, :as_not_automatically_managed, oauth_client_token_user: user)
+ end
+ let(:auth_strategy) { Storages::Peripherals::Registry.resolve("nextcloud.authentication.userbound").call(user:) }
+
+ it_behaves_like "rename_file_command: basic command setup"
+
+ it_behaves_like "rename_file_command: validating input data"
+
+ context "when renaming a folder", vcr: "nextcloud/rename_file_success" do
+ let(:file_id) { "169" }
+ let(:name) { "I am the senat" }
+
+ it_behaves_like "rename_file_command: successful file renaming"
+ end
+
+ context "when renaming a file inside a subdirectory", vcr: "nextcloud/rename_file_with_location_success" do
+ let(:file_id) { "167" }
+ let(:name) { "I❤️you death star.md" }
+
+ it_behaves_like "rename_file_command: successful file renaming"
+ end
+
+ context "when trying to rename a not existent file", vcr: "nextcloud/rename_file_not_found" do
+ let(:file_id) { "sith_have_yellow_light_sabers" }
+ let(:name) { "this_will_not_happen.txt" }
+ let(:error_source) { Storages::Peripherals::StorageInteraction::Nextcloud::FileInfoQuery }
+
+ it_behaves_like "rename_file_command: not found"
+ end
+end
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb
index d96b8e27b2a..b145abf6d06 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::CreateFolder
context "when creating a folder in the root", vcr: "one_drive/create_folder_root" do
let(:folder_name) { "Földer CreatedBy Çommand" }
let(:parent_location) { Storages::Peripherals::ParentFolder.new("/") }
- let(:path) { "/#{folder_name}" }
+ let(:path) { "/F%C3%B6lder%20CreatedBy%20%C3%87ommand" }
it_behaves_like "create_folder_command: successful folder creation"
end
@@ -50,7 +50,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::CreateFolder
context "when creating a folder in a parent folder", vcr: "one_drive/create_folder_parent" do
let(:folder_name) { "Földer CreatedBy Çommand" }
let(:parent_location) { Storages::Peripherals::ParentFolder.new("01AZJL5PKU2WV3U3RKKFF2A7ZCWVBXRTEU") }
- let(:path) { "/Folder with spaces/#{folder_name}" }
+ let(:path) { "/Folder%20with%20spaces/F%C3%B6lder%20CreatedBy%20%C3%87ommand" }
it_behaves_like "create_folder_command: successful folder creation"
end
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/rename_file_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/rename_file_command_spec.rb
index 8552a2bbb68..1b498d4ea11 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/rename_file_command_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/rename_file_command_spec.rb
@@ -33,46 +33,31 @@ require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::RenameFileCommand, :webmock do
let(:storage) { create(:sharepoint_dev_drive_storage) }
- let(:userless_strategy) { Storages::Peripherals::Registry.resolve("one_drive.authentication.userless").call }
- let(:folder) do
- Storages::Peripherals::Registry
- .resolve("one_drive.commands.create_folder")
- .call(auth_strategy: userless_strategy, storage:, folder_name: "Wrong Name",
- parent_location: Storages::Peripherals::ParentFolder.new("/"))
- end
+ let(:auth_strategy) { Storages::Peripherals::Registry.resolve("one_drive.authentication.userless").call }
- subject(:command) { described_class.new(storage) }
+ it_behaves_like "rename_file_command: basic command setup"
- it "is registered as rename_file" do
- expect(Storages::Peripherals::Registry.resolve("one_drive.commands.rename_file")).to eq(described_class)
- end
+ it_behaves_like "rename_file_command: validating input data"
- it "responds to .call with correct parameters" do
- expect(described_class).to respond_to(:call)
+ context "when renaming a folder", vcr: "one_drive/rename_file_success" do
+ let(:file_id) { "01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR" }
+ let(:name) { "I am the senat" }
- method = described_class.method(:call)
- expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq source], %i[keyreq target])
+ it_behaves_like "rename_file_command: successful file renaming"
end
- it "renames a folder", vcr: "one_drive/rename_folder_success" do
- file_info = folder.result
-
- result = command.call(source: file_info.id, target: "My Project No. 1 (19)")
-
- expect(result).to be_success
- renamed_details = result.result
+ context "when renaming a file inside a subdirectory", vcr: "one_drive/rename_file_with_location_success" do
+ let(:file_id) { "01AZJL5PPMSBBO3R2BIZHJFCELSW3RP7GN" }
+ let(:name) { "I❤️you death star.png" }
- expect(renamed_details.name).to eq("My Project No. 1 (19)")
- expect(renamed_details.id).to eq(file_info.id)
- ensure
- delete_folder(folder.result.id)
+ it_behaves_like "rename_file_command: successful file renaming"
end
- private
+ context "when trying to rename a not existent file", vcr: "one_drive/rename_file_not_found" do
+ let(:file_id) { "sith_have_yellow_light_sabers" }
+ let(:name) { "this_will_not_happen.png" }
+ let(:error_source) { described_class }
- def delete_folder(folder_id)
- Storages::Peripherals::Registry
- .resolve("one_drive.commands.delete_folder")
- .call(auth_strategy: userless_strategy, storage:, location: folder_id)
+ it_behaves_like "rename_file_command: not found"
end
end
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_not_found.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_not_found.yml
new file mode 100644
index 00000000000..5166e1a939c
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_not_found.yml
@@ -0,0 +1,82 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: https://nextcloud.local/ocs/v1.php/apps/integration_openproject/fileinfo/sith_have_yellow_light_sabers
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Ocs-Apirequest:
+ - 'true'
+ Accept:
+ - application/json
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept-Encoding:
+ - gzip, deflate
+ 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, 24 Jun 2024 12:47:43 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.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=%2FdffEGtTYfogdGrFxXuCa6tHS0C5aJzklROR3cnYs4NDk%2Bji4cCdCTBvgE8Tke%2FumI3PnTJliuAO6h4yjL%2BHGpzr1ydwvQRdjCMx7vRj9tn7mX3JK%2B0PcTlCcfltUEzN;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ 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, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=b4791dd13f107ec63cbc8950b45bfe00;
+ 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.18
+ X-Request-Id:
+ - 3H4NykbTwSA0lfCgR1V6
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '115'
+ body:
+ encoding: UTF-8
+ string: '{"ocs":{"meta":{"status":"failure","statuscode":404,"message":"","totalitems":"","itemsperpage":""},"data":{"status":"Not
+ Found","statuscode":404}}}'
+ recorded_at: Mon, 24 Jun 2024 12:47:44 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_success.yml
new file mode 100644
index 00000000000..171b2895028
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_success.yml
@@ -0,0 +1,238 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: https://nextcloud.local/ocs/v1.php/apps/integration_openproject/fileinfo/169
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Ocs-Apirequest:
+ - 'true'
+ Accept:
+ - application/json
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept-Encoding:
+ - gzip, deflate
+ 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, 24 Jun 2024 12:47:43 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.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=SnqcEEH1biq%2FNMKJ7EcxDuhFcngpEBfV5QquyACM81e3l8yKW5e5tA7AcUwxkPF7V1lHoUuDGZhB8fvOntJDW%2Fj3nJHefyTWuTp0mIUgr3fzR5EzP5NVEUx5iyeq4iLt;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ 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, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=9549242a6c959c7a7d33cf2ba59948cf;
+ 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.18
+ X-Request-Id:
+ - Zg8w9hGnNaix1M0Yl0Hr
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '254'
+ body:
+ encoding: UTF-8
+ string: '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK","totalitems":"","itemsperpage":""},"data":{"status":"OK","statuscode":200,"id":169,"name":"Folder","mtime":1718624545,"ctime":0,"mimetype":"application\/x-op-directory","size":982733193,"owner_name":"admin","owner_id":"admin","modifier_name":null,"modifier_id":null,"dav_permissions":"RGDNVCK","path":"files\/Folder\/"}}}'
+ recorded_at: Mon, 24 Jun 2024 12:47:43 GMT
+- request:
+ method: move
+ uri: https://nextcloud.local/remote.php/dav/files/admin/Folder
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ Destination:
+ - https://nextcloud.local/remote.php/dav/files/admin/I%20am%20the%20senat
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ response:
+ status:
+ code: 201
+ message: Created
+ headers:
+ Cache-Control:
+ - no-store, no-cache, must-revalidate
+ Content-Security-Policy:
+ - default-src 'none';
+ Content-Type:
+ - text/html; charset=UTF-8
+ Date:
+ - Mon, 24 Jun 2024 12:47:43 GMT
+ Expires:
+ - Thu, 19 Nov 1981 08:52:00 GMT
+ Oc-Fileid:
+ - '00000169oc07ul6b4oaw'
+ Pragma:
+ - no-cache
+ Referrer-Policy:
+ - no-referrer
+ Server:
+ - Apache/2.4.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=AWx%2BB1wyQ4AIZRU7E%2BUlbQ3FjdBVzLPG0ECIy2tcc%2Fj9miXu9rdr5N%2Fs7C2XcqxsinTfK6E%2Fc%2BMZg2KeqduJd0YGVSZQFEevlYC52axc%2BH%2FeqTVmeAZhryuJcQGl6o%2F3;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ 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, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=1fd3cbed011e6e0451e2e37195dfb126;
+ path=/; secure; HttpOnly; SameSite=Lax
+ X-Content-Type-Options:
+ - nosniff
+ X-Debug-Token:
+ - S7YtnR4rwLvCzI4xY2Tc
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Permitted-Cross-Domain-Policies:
+ - none
+ X-Powered-By:
+ - PHP/8.2.18
+ X-Request-Id:
+ - S7YtnR4rwLvCzI4xY2Tc
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '0'
+ body:
+ encoding: UTF-8
+ string: ''
+ recorded_at: Mon, 24 Jun 2024 12:47:43 GMT
+- request:
+ method: get
+ uri: https://nextcloud.local/ocs/v1.php/apps/integration_openproject/fileinfo/169
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Ocs-Apirequest:
+ - 'true'
+ Accept:
+ - application/json
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept-Encoding:
+ - gzip, deflate
+ 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, 24 Jun 2024 12:47:43 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.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=pBVfixCW0LTylXE13Hp2p4Zd4P9SpWqpu7J2v9dol8cMWQQIqTrLrRhVgRshLwBJCzDTqD6xRLURz05smKCR4H9HuBnQWMqOy2J4GZm9Bx8Fo33v7MdYiivntbNDlwiB;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ 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, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=e924324c2778deea6e2d8fef29480bc2;
+ 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.18
+ X-Request-Id:
+ - zyYddsBGCp2PoFAtvHfu
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '262'
+ body:
+ encoding: UTF-8
+ string: '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK","totalitems":"","itemsperpage":""},"data":{"status":"OK","statuscode":200,"id":169,"name":"I
+ am the senat","mtime":1718624545,"ctime":0,"mimetype":"application\/x-op-directory","size":982733193,"owner_name":"admin","owner_id":"admin","modifier_name":null,"modifier_id":null,"dav_permissions":"RGDNVCK","path":"files\/I
+ am the senat\/"}}}'
+ recorded_at: Mon, 24 Jun 2024 12:47:43 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_with_location_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_with_location_success.yml
new file mode 100644
index 00000000000..66af7a90012
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/nextcloud/rename_file_with_location_success.yml
@@ -0,0 +1,243 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: https://nextcloud.local/ocs/v1.php/apps/integration_openproject/fileinfo/167
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Ocs-Apirequest:
+ - 'true'
+ Accept:
+ - application/json
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept-Encoding:
+ - gzip, deflate
+ 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, 24 Jun 2024 12:47:44 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.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=iMCcKhvw%2FOWQYaplVk42UJ1rXRafmGWYkl51rG%2FdbufkEkmafMHmURfSJsL6fGTLh4mBKKPQ0KSjmRhMJCfL2yWy5I36yHMsmXc4PckhStdLSrBQWGdZlXLeYUz0Neip;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ 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, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=abde6d1d4a1b1c4c840e8d23a169e2ab;
+ 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.18
+ X-Request-Id:
+ - 0g2PLntU1vmpu9XWTV2C
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '262'
+ body:
+ encoding: UTF-8
+ string: '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK","totalitems":"","itemsperpage":""},"data":{"status":"OK","statuscode":200,"id":167,"name":"request_001.md","mtime":1701268524,"ctime":0,"mimetype":"text\/markdown","size":48,"owner_name":"admin","owner_id":"admin","modifier_name":null,"modifier_id":null,"dav_permissions":"RGDNVW","path":"files\/Folder
+ with spaces\/New Requests\/request_001.md"}}}'
+ recorded_at: Mon, 24 Jun 2024 12:47:44 GMT
+- request:
+ method: move
+ uri: https://nextcloud.local/remote.php/dav/files/admin/Folder%20with%20spaces/New%20Requests/request_001.md
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ Destination:
+ - https://nextcloud.local/remote.php/dav/files/admin/Folder%20with%20spaces/New%20Requests/I%E2%9D%A4%EF%B8%8Fyou%20death%20star.md
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ response:
+ status:
+ code: 201
+ message: Created
+ headers:
+ Cache-Control:
+ - no-store, no-cache, must-revalidate
+ Content-Security-Policy:
+ - default-src 'none';
+ Content-Type:
+ - text/html; charset=UTF-8
+ Date:
+ - Mon, 24 Jun 2024 12:47:44 GMT
+ Etag:
+ - '"ef9970d784b65aac545b0e0cc5060536"'
+ Expires:
+ - Thu, 19 Nov 1981 08:52:00 GMT
+ Oc-Etag:
+ - '"ef9970d784b65aac545b0e0cc5060536"'
+ Oc-Fileid:
+ - 00000167oc07ul6b4oaw
+ Pragma:
+ - no-cache
+ Referrer-Policy:
+ - no-referrer
+ Server:
+ - Apache/2.4.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=hBRu%2FMnoJSkD%2FQZ94jyQkPXBKsVUeP2cuZXIbchQyd%2Bqn%2Fm4nWkdKSvF9sWkKiW3zc1KJ4T7x882HabOlQHvLCXqfthg9E1iBa8MptrT46S46AZUQPJaL8VR8UjwF%2FO3;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ 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, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=67763dcd669717ca18ad461ae3af289d;
+ path=/; secure; HttpOnly; SameSite=Lax
+ X-Content-Type-Options:
+ - nosniff
+ X-Debug-Token:
+ - 3yszavGzGnTgraffEGd2
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Permitted-Cross-Domain-Policies:
+ - none
+ X-Powered-By:
+ - PHP/8.2.18
+ X-Request-Id:
+ - 3yszavGzGnTgraffEGd2
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '0'
+ body:
+ encoding: UTF-8
+ string: ''
+ recorded_at: Mon, 24 Jun 2024 12:47:44 GMT
+- request:
+ method: get
+ uri: https://nextcloud.local/ocs/v1.php/apps/integration_openproject/fileinfo/167
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers:
+ Ocs-Apirequest:
+ - 'true'
+ Accept:
+ - application/json
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept-Encoding:
+ - gzip, deflate
+ 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, 24 Jun 2024 12:47:44 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.59 (Debian)
+ Set-Cookie:
+ - oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d; path=/; secure; HttpOnly; SameSite=Lax,
+ oc_sessionPassphrase=49eHjlMqrmvl2%2FTwHT9UzCdNHA8gJxMl4%2B8RlWVinAmbTLYxpcWnnJ0%2Fc34LMsiWAet3YP5Yx3MWoww%2FUejUGNPaYTyhJC5Pm8KPRiTA35sPW3hMV5UZ6GD%2FJJadis%2BZ;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ 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, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ path=/; secure; HttpOnly; SameSite=Lax, oc07ul6b4oaw=f1f030cd937c8ceddde96d1b57cec45d;
+ 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.18
+ X-Request-Id:
+ - iBuJ005jfGLn9Pj3qRff
+ X-Robots-Tag:
+ - noindex, nofollow
+ X-Xss-Protection:
+ - 1; mode=block
+ Content-Length:
+ - '277'
+ body:
+ encoding: UTF-8
+ string: '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK","totalitems":"","itemsperpage":""},"data":{"status":"OK","statuscode":200,"id":167,"name":"I\u2764\ufe0fyou
+ death star.md","mtime":1701268524,"ctime":0,"mimetype":"text\/markdown","size":48,"owner_name":"admin","owner_id":"admin","modifier_name":null,"modifier_id":null,"dav_permissions":"RGDNVW","path":"files\/Folder
+ with spaces\/New Requests\/I\u2764\ufe0fyou death star.md"}}}'
+ recorded_at: Mon, 24 Jun 2024 12:47:44 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_not_found.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_not_found.yml
new file mode 100644
index 00000000000..3360e69fcbc
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_not_found.yml
@@ -0,0 +1,106 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: https://login.microsoftonline.com/4d44bf36-9b56-45c0-8807-bbf386dd047f/oauth2/v2.0/token
+ body:
+ encoding: ASCII-8BIT
+ string: grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default+offline_access&client_id=4262df2b-77bb-49c2-a5df-28355da676d2&client_secret=Vwk8Q%7EJTuPh.pAjvPiWBQBdTFMDK%7EAIwxbj9_axB
+ headers:
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Content-Length:
+ - '201'
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Pragma:
+ - no-cache
+ Content-Type:
+ - application/json; charset=utf-8
+ Expires:
+ - "-1"
+ Strict-Transport-Security:
+ - max-age=31536000; includeSubDomains
+ X-Content-Type-Options:
+ - nosniff
+ P3p:
+ - CP="DSP CUR OTPi IND OTRi ONL FIN"
+ X-Ms-Request-Id:
+ - 8deae3a0-c4d2-41ea-8803-af5debd34e00
+ X-Ms-Ests-Server:
+ - 2.1.18298.5 - WEULR1 ProdSlices
+ X-Ms-Srs:
+ - 1.P
+ X-Xss-Protection:
+ - '0'
+ Set-Cookie:
+ - fpc=AmVwpcESbh5GrfFjS0tnz3ekbDoXAQAAAPBUC94OAAAA; expires=Wed, 24-Jul-2024
+ 11:52:17 GMT; path=/; secure; HttpOnly; SameSite=None, x-ms-gateway-slice=estsfd;
+ path=/; secure; samesite=none; httponly, stsservicecookie=estsfd; path=/;
+ secure; samesite=none; httponly
+ Date:
+ - Mon, 24 Jun 2024 11:52:17 GMT
+ Content-Length:
+ - '1759'
+ body:
+ encoding: UTF-8
+ string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"<ACCESS_TOKEN>"}'
+ recorded_at: Mon, 24 Jun 2024 11:52:17 GMT
+- request:
+ method: patch
+ uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/sith_have_yellow_light_sabers
+ body:
+ encoding: UTF-8
+ string: '{"name":"this_will_not_happen.png"}'
+ headers:
+ Content-Type:
+ - application/json
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Length:
+ - '35'
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ response:
+ status:
+ code: 404
+ message: Not Found
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Content-Type:
+ - application/json
+ Content-Encoding:
+ - gzip
+ Vary:
+ - Accept-Encoding
+ Strict-Transport-Security:
+ - max-age=31536000
+ Request-Id:
+ - e24dfe38-bac8-4f32-a8fc-6a79c0b20e92
+ Client-Request-Id:
+ - e24dfe38-bac8-4f32-a8fc-6a79c0b20e92
+ X-Ms-Ags-Diagnostic:
+ - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"004","RoleInstance":"FR2PEPF0000056F"}}'
+ Date:
+ - Mon, 24 Jun 2024 11:52:17 GMT
+ body:
+ encoding: UTF-8
+ string: '{"error":{"code":"itemNotFound","message":"Item not found","innerError":{"date":"2024-06-24T11:52:18","request-id":"e24dfe38-bac8-4f32-a8fc-6a79c0b20e92","client-request-id":"e24dfe38-bac8-4f32-a8fc-6a79c0b20e92"}}}'
+ recorded_at: Mon, 24 Jun 2024 11:52:18 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_success.yml
new file mode 100644
index 00000000000..2378f2a4df8
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_success.yml
@@ -0,0 +1,110 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: https://login.microsoftonline.com/4d44bf36-9b56-45c0-8807-bbf386dd047f/oauth2/v2.0/token
+ body:
+ encoding: ASCII-8BIT
+ string: grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default+offline_access&client_id=4262df2b-77bb-49c2-a5df-28355da676d2&client_secret=Vwk8Q%7EJTuPh.pAjvPiWBQBdTFMDK%7EAIwxbj9_axB
+ headers:
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Content-Length:
+ - '201'
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Pragma:
+ - no-cache
+ Content-Type:
+ - application/json; charset=utf-8
+ Expires:
+ - "-1"
+ Strict-Transport-Security:
+ - max-age=31536000; includeSubDomains
+ X-Content-Type-Options:
+ - nosniff
+ P3p:
+ - CP="DSP CUR OTPi IND OTRi ONL FIN"
+ X-Ms-Request-Id:
+ - 82fd081e-b88e-41ce-bf74-b01ddaee3c00
+ X-Ms-Ests-Server:
+ - 2.1.18298.5 - NEULR1 ProdSlices
+ X-Ms-Srs:
+ - 1.P
+ X-Xss-Protection:
+ - '0'
+ Set-Cookie:
+ - fpc=Am--ZGqggClMv2Xq9vAANLCkbDoXAQAAAJFTC94OAAAA; expires=Wed, 24-Jul-2024
+ 11:46:25 GMT; path=/; secure; HttpOnly; SameSite=None, x-ms-gateway-slice=estsfd;
+ path=/; secure; samesite=none; httponly, stsservicecookie=estsfd; path=/;
+ secure; samesite=none; httponly
+ Date:
+ - Mon, 24 Jun 2024 11:46:25 GMT
+ Content-Length:
+ - '1760'
+ body:
+ encoding: UTF-8
+ string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"<ACCESS_TOKEN>"}'
+ recorded_at: Mon, 24 Jun 2024 11:46:25 GMT
+- request:
+ method: patch
+ uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR
+ body:
+ encoding: UTF-8
+ string: '{"name":"I am the senat"}'
+ headers:
+ Content-Type:
+ - application/json
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Length:
+ - '25'
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Content-Type:
+ - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
+ Content-Encoding:
+ - gzip
+ Vary:
+ - Accept-Encoding
+ Strict-Transport-Security:
+ - max-age=31536000
+ Request-Id:
+ - fa6635a9-b6db-4f9b-af49-e12958e536b0
+ Client-Request-Id:
+ - fa6635a9-b6db-4f9b-af49-e12958e536b0
+ X-Ms-Ags-Diagnostic:
+ - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"002","RoleInstance":"FR3PEPF0000055B"}}'
+ Odata-Version:
+ - '4.0'
+ Date:
+ - Mon, 24 Jun 2024 11:46:26 GMT
+ body:
+ encoding: UTF-8
+ string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives(''b%21dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs'')/items/$entity","createdDateTime":"2023-09-26T14:38:50Z","eTag":"\"{6087B980-4C01-4020-BBF2-1E349BD0C831},2\"","id":"01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR","lastModifiedDateTime":"2024-06-24T11:46:27Z","name":"I
+ am the senat","webUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests/VCR/I%20am%20the%20senat","cTag":"\"c:{6087B980-4C01-4020-BBF2-1E349BD0C831},0\"","size":263282,"createdBy":{"user":{"email":"[email protected]","id":"0a0d38a9-a59b-4245-93fa-0d2cf727f17a","displayName":"Eric
+ Schubert"}},"lastModifiedBy":{"user":{"displayName":"SharePoint App"}},"parentReference":{"driveType":"documentLibrary","driveId":"b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs","id":"01AZJL5PN6Y2GOVW7725BZO354PWSELRRZ","name":"VCR","path":"/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/root:","siteId":"1b4b6576-906d-4d94-8f49-6d00a9507b50"},"fileSystemInfo":{"createdDateTime":"2023-09-26T14:38:50Z","lastModifiedDateTime":"2024-06-24T11:46:27Z"},"folder":{"childCount":5},"shared":{"scope":"users"}}'
+ recorded_at: Mon, 24 Jun 2024 11:46:26 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_with_location_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_with_location_success.yml
new file mode 100644
index 00000000000..295a2bf65f8
--- /dev/null
+++ b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_file_with_location_success.yml
@@ -0,0 +1,112 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: https://login.microsoftonline.com/4d44bf36-9b56-45c0-8807-bbf386dd047f/oauth2/v2.0/token
+ body:
+ encoding: ASCII-8BIT
+ string: grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default+offline_access&client_id=4262df2b-77bb-49c2-a5df-28355da676d2&client_secret=Vwk8Q%7EJTuPh.pAjvPiWBQBdTFMDK%7EAIwxbj9_axB
+ headers:
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Content-Length:
+ - '201'
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Pragma:
+ - no-cache
+ Content-Type:
+ - application/json; charset=utf-8
+ Expires:
+ - "-1"
+ Strict-Transport-Security:
+ - max-age=31536000; includeSubDomains
+ X-Content-Type-Options:
+ - nosniff
+ P3p:
+ - CP="DSP CUR OTPi IND OTRi ONL FIN"
+ X-Ms-Request-Id:
+ - ffa8f490-b965-4f8e-bc76-cadd36557600
+ X-Ms-Ests-Server:
+ - 2.1.18298.5 - FRC ProdSlices
+ X-Ms-Srs:
+ - 1.P
+ X-Xss-Protection:
+ - '0'
+ Set-Cookie:
+ - fpc=ArnOt0kiO4BGuweLgTpTFIykbDoXAQAAAGdUC94OAAAA; expires=Wed, 24-Jul-2024
+ 11:49:59 GMT; path=/; secure; HttpOnly; SameSite=None, x-ms-gateway-slice=estsfd;
+ path=/; secure; samesite=none; httponly, stsservicecookie=estsfd; path=/;
+ secure; samesite=none; httponly
+ Date:
+ - Mon, 24 Jun 2024 11:49:58 GMT
+ Content-Length:
+ - '1760'
+ body:
+ encoding: UTF-8
+ string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"<ACCESS_TOKEN>"}'
+ recorded_at: Mon, 24 Jun 2024 11:49:59 GMT
+- request:
+ method: patch
+ uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/01AZJL5PPMSBBO3R2BIZHJFCELSW3RP7GN
+ body:
+ encoding: UTF-8
+ string: '{"name":"I❤️you death star.png"}'
+ headers:
+ Content-Type:
+ - application/json
+ User-Agent:
+ - httpx.rb/1.2.6
+ Accept:
+ - "*/*"
+ Accept-Encoding:
+ - gzip, deflate
+ Content-Length:
+ - '37'
+ Authorization:
+ - Bearer <BEARER TOKEN>
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache
+ Content-Type:
+ - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
+ Content-Encoding:
+ - gzip
+ Vary:
+ - Accept-Encoding
+ Strict-Transport-Security:
+ - max-age=31536000
+ Request-Id:
+ - e3c6e74c-eccc-46f3-9a5a-95710b29e084
+ Client-Request-Id:
+ - e3c6e74c-eccc-46f3-9a5a-95710b29e084
+ X-Ms-Ags-Diagnostic:
+ - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"FR3PEPF000005F4"}}'
+ Odata-Version:
+ - '4.0'
+ Date:
+ - Mon, 24 Jun 2024 11:50:00 GMT
+ body:
+ encoding: UTF-8
+ string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives(''b%21dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs'')/items/$entity","@microsoft.graph.downloadUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests/_layouts/15/download.aspx?UniqueId=ed4290ec-41c7-4e46-9288-8b95b717fccd&Translate=false&tempauth=v1.eyJzaXRlaWQiOiIxYjRiNjU3Ni05MDZkLTRkOTQtOGY0OS02ZDAwYTk1MDdiNTAiLCJhcHBfZGlzcGxheW5hbWUiOiJPcGVuUHJvamVjdCBEZXYgQXBwIiwiYXVkIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL2Zpbm4uc2hhcmVwb2ludC5jb21ANGQ0NGJmMzYtOWI1Ni00NWMwLTg4MDctYmJmMzg2ZGQwNDdmIiwiZXhwIjoiMTcxOTIzMzQwMCJ9.EgsI4u6x9rmTij0QBRoNMjAuMTkwLjE5MC45OSosZ2VLeEg1cUh3Qi81RVJudlp1UC9xOUJYUlBoUkRoT0ZMWjByUXppS2FtTT0wlQE4AUIQoTXEG28gAJAeSuUTap6OE0oQaGFzaGVkcHJvb2Z0b2tlbnoBMboBK2FsbHNpdGVzLnJlYWQgYWxsc2l0ZXMud3JpdGUgYWxsZmlsZXMud3JpdGXCAUk0MjYyZGYyYi03N2JiLTQ5YzItYTVkZi0yODM1NWRhNjc2ZDJANGQ0NGJmMzYtOWI1Ni00NWMwLTg4MDctYmJmMzg2ZGQwNDdmyAEB.m_odT3aPits40RUzjqhPjF9Y-MvkduKxqPj5ihmoHDU&ApiVersion=2.0","createdDateTime":"2023-09-26T14:40:27Z","eTag":"\"{ED4290EC-41C7-4E46-9288-8B95B717FCCD},4\"","id":"01AZJL5PPMSBBO3R2BIZHJFCELSW3RP7GN","lastModifiedDateTime":"2024-06-24T11:50:00Z","name":"I\u2764\ufe0fyou
+ death star.png","webUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests/VCR/Folder%20with%20spaces/I%E2%9D%A4%EF%B8%8Fyou%20death%20start.png","cTag":"\"c:{ED4290EC-41C7-4E46-9288-8B95B717FCCD},3\"","size":9482,"createdBy":{"user":{"email":"[email protected]","id":"0a0d38a9-a59b-4245-93fa-0d2cf727f17a","displayName":"Eric
+ Schubert"}},"lastModifiedBy":{"user":{"displayName":"SharePoint App"}},"parentReference":{"driveType":"documentLibrary","driveId":"b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs","id":"01AZJL5PKU2WV3U3RKKFF2A7ZCWVBXRTEU","name":"Folder
+ with spaces","path":"/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/root:/Folder
+ with spaces","siteId":"1b4b6576-906d-4d94-8f49-6d00a9507b50"},"file":{"mimeType":"image/png","hashes":{"quickXorHash":"58goJ0v735ljlyoxrwUj5+78tHc="}},"fileSystemInfo":{"createdDateTime":"2023-09-26T14:40:27Z","lastModifiedDateTime":"2024-06-24T11:50:00Z"},"image":{"height":419,"width":347},"photo":{},"shared":{"scope":"users"}}'
+ recorded_at: Mon, 24 Jun 2024 11:50:00 GMT
+recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_folder_success.yml b/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_folder_success.yml
deleted file mode 100644
index 334975dfeab..00000000000
--- a/modules/storages/spec/support/fixtures/vcr_cassettes/one_drive/rename_folder_success.yml
+++ /dev/null
@@ -1,260 +0,0 @@
----
-http_interactions:
-- request:
- method: post
- uri: https://login.microsoftonline.com/4d44bf36-9b56-45c0-8807-bbf386dd047f/oauth2/v2.0/token
- body:
- encoding: ASCII-8BIT
- string: grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default+offline_access&client_id=4262df2b-77bb-49c2-a5df-28355da676d2&client_secret=Vwk8Q%7EJTuPh.pAjvPiWBQBdTFMDK%7EAIwxbj9_axB
- headers:
- User-Agent:
- - httpx.rb/1.2.5
- Accept:
- - "*/*"
- Accept-Encoding:
- - gzip, deflate
- Content-Type:
- - application/x-www-form-urlencoded
- Content-Length:
- - '201'
- response:
- status:
- code: 200
- message: OK
- headers:
- Cache-Control:
- - no-store, no-cache
- Pragma:
- - no-cache
- Content-Type:
- - application/json; charset=utf-8
- Expires:
- - "-1"
- Strict-Transport-Security:
- - max-age=31536000; includeSubDomains
- X-Content-Type-Options:
- - nosniff
- P3p:
- - CP="DSP CUR OTPi IND OTRi ONL FIN"
- X-Ms-Request-Id:
- - 5d94463c-89b2-4148-8afa-47d6d7686900
- X-Ms-Ests-Server:
- - 2.1.18216.5 - SEC ProdSlices
- X-Ms-Srs:
- - 1.P
- X-Xss-Protection:
- - '0'
- Set-Cookie:
- - fpc=ApsGOKKY9c5MtcLEnQSVmSqkbDoXAQAAAJkC-d0OAAAA; expires=Wed, 10-Jul-2024
- 14:20:10 GMT; path=/; secure; HttpOnly; SameSite=None, x-ms-gateway-slice=estsfd;
- path=/; secure; samesite=none; httponly, stsservicecookie=estsfd; path=/;
- secure; samesite=none; httponly
- Date:
- - Mon, 10 Jun 2024 14:20:09 GMT
- Content-Length:
- - '1735'
- body:
- encoding: UTF-8
- string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"<ACCESS_TOKEN>"}'
- recorded_at: Mon, 10 Jun 2024 14:20:10 GMT
-- request:
- method: post
- uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/root/children
- body:
- encoding: UTF-8
- string: '{"name":"Wrong Name","folder":{},"@microsoft.graph.conflictBehavior":"fail"}'
- headers:
- Content-Type:
- - application/json
- User-Agent:
- - httpx.rb/1.2.5
- Accept:
- - "*/*"
- Accept-Encoding:
- - gzip, deflate
- Content-Length:
- - '76'
- Authorization:
- - Bearer <BEARER TOKEN>
- response:
- status:
- code: 201
- message: Created
- headers:
- Cache-Control:
- - no-store, no-cache
- Content-Type:
- - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
- Content-Encoding:
- - gzip
- Etag:
- - '"{B880A739-43EF-4363-9134-BD49CFE7C910},1"'
- Location:
- - https://finn.sharepoint.com/_api/v2.0/drives('b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs')/items('root')/children('01AZJL5PJZU6ALR32DMNBZCNF5JHH6PSIQ')
- Vary:
- - Accept-Encoding
- Strict-Transport-Security:
- - max-age=31536000
- Request-Id:
- - cd98c895-8ec4-45b7-8f07-eca6799a38c2
- Client-Request-Id:
- - cd98c895-8ec4-45b7-8f07-eca6799a38c2
- X-Ms-Ags-Diagnostic:
- - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"FR3PEPF000005B8"}}'
- Odata-Version:
- - '4.0'
- Date:
- - Mon, 10 Jun 2024 14:20:10 GMT
- body:
- encoding: UTF-8
- string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives(''b%21dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs'')/root/children/$entity","@odata.etag":"\"{B880A739-43EF-4363-9134-BD49CFE7C910},1\"","createdDateTime":"2024-06-10T14:20:11Z","eTag":"\"{B880A739-43EF-4363-9134-BD49CFE7C910},1\"","id":"01AZJL5PJZU6ALR32DMNBZCNF5JHH6PSIQ","lastModifiedDateTime":"2024-06-10T14:20:11Z","name":"Wrong
- Name","size":0,"webUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests/VCR/Wrong%20Name","cTag":"\"c:{B880A739-43EF-4363-9134-BD49CFE7C910},0\"","commentSettings":{"commentingDisabled":{"isDisabled":false}},"createdBy":{"application":{"displayName":"OpenProject
- Dev App","id":"4262df2b-77bb-49c2-a5df-28355da676d2"},"user":{"displayName":"SharePoint
- App"}},"lastModifiedBy":{"application":{"displayName":"OpenProject Dev App","id":"4262df2b-77bb-49c2-a5df-28355da676d2"},"user":{"displayName":"SharePoint
- App"}},"parentReference":{"driveId":"b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs","driveType":"documentLibrary","id":"01AZJL5PN6Y2GOVW7725BZO354PWSELRRZ","path":"/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/root:","sharepointIds":{"listId":"f3baf95b-362b-4740-80d8-4f593d28f5ec","listItemUniqueId":"049e81d0-52fb-4624-af6d-96611c29a9cc","siteId":"1b4b6576-906d-4d94-8f49-6d00a9507b50","siteUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests","tenantId":"4d44bf36-9b56-45c0-8807-bbf386dd047f","webId":"7ef259e8-8eed-4645-920a-8b367bb0d8e0"}},"fileSystemInfo":{"createdDateTime":"2024-06-10T14:20:11Z","lastModifiedDateTime":"2024-06-10T14:20:11Z"},"folder":{"childCount":0},"shared":{"scope":"unknown"}}'
- recorded_at: Mon, 10 Jun 2024 14:20:11 GMT
-- request:
- method: post
- uri: https://login.microsoftonline.com/4d44bf36-9b56-45c0-8807-bbf386dd047f/oauth2/v2.0/token
- body:
- encoding: UTF-8
- string: grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
- headers:
- User-Agent:
- - Rack::OAuth2 (2.2.1)
- Authorization:
- - Basic <BASIC_AUTH>
- Content-Type:
- - application/x-www-form-urlencoded
- Accept-Encoding:
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
- Accept:
- - "*/*"
- response:
- status:
- code: 200
- message: OK
- headers:
- Cache-Control:
- - no-store, no-cache
- Pragma:
- - no-cache
- Content-Type:
- - application/json; charset=utf-8
- Expires:
- - "-1"
- Strict-Transport-Security:
- - max-age=31536000; includeSubDomains
- X-Content-Type-Options:
- - nosniff
- P3p:
- - CP="DSP CUR OTPi IND OTRi ONL FIN"
- X-Ms-Request-Id:
- - bb546166-785b-453c-81bc-cb8c93af6e00
- X-Ms-Ests-Server:
- - 2.1.18216.5 - SEC ProdSlices
- X-Ms-Srs:
- - 1.P
- X-Xss-Protection:
- - '0'
- Set-Cookie:
- - fpc=AhKGA6Jv29JLr32JHmFcFrukbDoXAQAAAJoC-d0OAAAA; expires=Wed, 10-Jul-2024
- 14:20:11 GMT; path=/; secure; HttpOnly; SameSite=None
- - stsservicecookie=estsfd; path=/; secure; samesite=none; httponly
- - x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly
- Date:
- - Mon, 10 Jun 2024 14:20:11 GMT
- Content-Length:
- - '1708'
- body:
- encoding: UTF-8
- string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"<ACCESS_TOKEN>"}'
- recorded_at: Mon, 10 Jun 2024 14:20:11 GMT
-- request:
- method: patch
- uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/01AZJL5PJZU6ALR32DMNBZCNF5JHH6PSIQ
- body:
- encoding: UTF-8
- string: '{"name":"My Project No. 1 (19)"}'
- headers:
- Authorization:
- - Bearer <BEARER TOKEN>
- Accept:
- - application/json
- Content-Type:
- - application/json
- User-Agent:
- - httpx.rb/1.2.5
- Accept-Encoding:
- - gzip, deflate
- Content-Length:
- - '32'
- response:
- status:
- code: 200
- message: OK
- headers:
- Cache-Control:
- - no-store, no-cache
- Content-Type:
- - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
- Content-Encoding:
- - gzip
- Vary:
- - Accept-Encoding
- Strict-Transport-Security:
- - max-age=31536000
- Request-Id:
- - 6ec63b53-7694-4127-91f2-6c9cc9741bd5
- Client-Request-Id:
- - 6ec63b53-7694-4127-91f2-6c9cc9741bd5
- X-Ms-Ags-Diagnostic:
- - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"FR3PEPF000002E4"}}'
- Odata-Version:
- - '4.0'
- Date:
- - Mon, 10 Jun 2024 14:20:11 GMT
- body:
- encoding: UTF-8
- string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives(''b%21dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs'')/items/$entity","createdDateTime":"2024-06-10T14:20:11Z","eTag":"\"{B880A739-43EF-4363-9134-BD49CFE7C910},3\"","id":"01AZJL5PJZU6ALR32DMNBZCNF5JHH6PSIQ","lastModifiedDateTime":"2024-06-10T14:20:12Z","name":"My
- Project No. 1 (19)","webUrl":"https://finn.sharepoint.com/sites/openprojectfilestoragetests/VCR/My%20Project%20No.%201%20(19)","cTag":"\"c:{B880A739-43EF-4363-9134-BD49CFE7C910},0\"","size":0,"createdBy":{"application":{"id":"4262df2b-77bb-49c2-a5df-28355da676d2","displayName":"OpenProject
- Dev App"},"user":{"displayName":"SharePoint App"}},"lastModifiedBy":{"application":{"id":"4262df2b-77bb-49c2-a5df-28355da676d2","displayName":"OpenProject
- Dev App"},"user":{"displayName":"SharePoint App"}},"parentReference":{"driveType":"documentLibrary","driveId":"b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs","id":"01AZJL5PN6Y2GOVW7725BZO354PWSELRRZ","name":"VCR","path":"/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/root:","siteId":"1b4b6576-906d-4d94-8f49-6d00a9507b50"},"fileSystemInfo":{"createdDateTime":"2024-06-10T14:20:11Z","lastModifiedDateTime":"2024-06-10T14:20:12Z"},"folder":{"childCount":0},"shared":{"scope":"users"}}'
- recorded_at: Mon, 10 Jun 2024 14:20:12 GMT
-- request:
- method: delete
- uri: https://graph.microsoft.com/v1.0/drives/b!dmVLG22QlE2PSW0AqVB7UOhZ8n7tjkVGkgqLNnuw2OBb-brzKzZAR4DYT1k9KPXs/items/01AZJL5PJZU6ALR32DMNBZCNF5JHH6PSIQ
- body:
- encoding: US-ASCII
- string: ''
- headers:
- Authorization:
- - Bearer <BEARER TOKEN>
- User-Agent:
- - httpx.rb/1.2.5
- Accept:
- - "*/*"
- Accept-Encoding:
- - gzip, deflate
- response:
- status:
- code: 204
- message: No Content
- headers:
- Cache-Control:
- - no-store, no-cache
- Strict-Transport-Security:
- - max-age=31536000
- Request-Id:
- - b6c9de3e-fb1a-428a-bac3-158a753dae5d
- Client-Request-Id:
- - b6c9de3e-fb1a-428a-bac3-158a753dae5d
- X-Ms-Ags-Diagnostic:
- - '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"FR3PEPF00000553"}}'
- Date:
- - Mon, 10 Jun 2024 14:20:11 GMT
- body:
- encoding: UTF-8
- string: ''
- recorded_at: Mon, 10 Jun 2024 14:20:12 GMT
-recorded_with: VCR 6.2.0
diff --git a/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb b/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb
new file mode 100644
index 00000000000..e22ea38bc77
--- /dev/null
+++ b/modules/storages/spec/support/shared_examples_for_adapters/rename_file_command_examples.rb
@@ -0,0 +1,101 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+RSpec.shared_examples_for "rename_file_command: basic command setup" do
+ it "is registered as commands.rename_file" do
+ expect(Storages::Peripherals::Registry
+ .resolve("#{storage.short_provider_type}.commands.rename_file")).to eq(described_class)
+ end
+
+ it "responds to #call with correct parameters" do
+ expect(described_class).to respond_to(:call)
+
+ method = described_class.method(:call)
+ expect(method.parameters).to contain_exactly(%i[keyreq storage],
+ %i[keyreq auth_strategy],
+ %i[keyreq file_id],
+ %i[keyreq name])
+ end
+end
+
+RSpec.shared_examples_for "rename_file_command: successful file renaming" do
+ it "returns success and the renamed file" do
+ result = described_class.call(storage:, auth_strategy:, file_id:, name:)
+
+ expect(result).to be_success
+
+ response = result.result
+ expect(response).to be_a(Storages::StorageFile)
+ expect(response.id).to eq(file_id)
+ expect(response.name).to eq(name)
+ end
+end
+
+RSpec.shared_examples_for "rename_file_command: not found" do
+ it "returns a failure" do
+ result = described_class.call(storage:, auth_strategy:, file_id:, name:)
+
+ expect(result).to be_failure
+
+ error = result.errors
+ expect(error.code).to eq(:not_found)
+ expect(error.data.source).to eq(error_source)
+ end
+end
+
+RSpec.shared_examples_for "rename_file_command: error" do
+ it "returns a failure" do
+ result = described_class.call(storage:, auth_strategy:, file_id:, name:)
+
+ expect(result).to be_failure
+
+ error = result.errors
+ expect(error.code).to eq(:error)
+ expect(error.data.source).to eq(error_source)
+ end
+end
+
+RSpec.shared_examples_for "rename_file_command: validating input data" do
+ let(:error_source) { described_class }
+ let(:file_id) { "my_file" }
+ let(:name) { "new_name" }
+
+ context "if file_id is empty" do
+ let(:file_id) { "" }
+
+ it_behaves_like "rename_file_command: error"
+ end
+
+ context "if name is empty" do
+ let(:name) { "" }
+
+ it_behaves_like "rename_file_command: error"
+ end
+end