From 9a39485f28f35aea45ccc5dd77181bb53fd52c3b Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Fri, 15 Feb 2019 17:40:53 +0100 Subject: [PATCH] Move escape inside 'path' and add specs --- app/models/service_template_transformation_plan_task.rb | 7 ++++++- .../service_template_transformation_plan_task_spec.rb | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index dfb393520f1..0ba16161851 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -284,7 +284,12 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) def conversion_options_source_provider_vmwarews_ssh(storage) { - :vm_name => URI::Generic.build(:scheme => 'ssh', :userinfo => 'root', :host => source.host.ipaddress, :path => "/vmfs/volumes").to_s + "/#{CGI.escape(storage.name)}/#{CGI.escape(source.location)}", + :vm_name => URI::Generic.build( + :scheme => 'ssh', + :userinfo => 'root', + :host => source.host.ipaddress, + :path => "/vmfs/volumes/#{URI.escape(storage.name)}/#{URI.escape(source.location)}" + ).to_s, :transport_method => 'ssh' } end diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index f9e5c6bbd65..120291a273e 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -289,7 +289,7 @@ context 'source is vmwarews' do let(:src_ems) { FactoryBot.create(:ems_vmware, :zone => FactoryBot.create(:zone)) } let(:src_host) { FactoryBot.create(:host, :ext_management_system => src_ems, :ipaddress => '10.0.0.1') } - let(:src_storage) { FactoryBot.create(:storage, :ext_management_system => src_ems) } + let(:src_storage) { FactoryBot.create(:storage, :ext_management_system => src_ems, name: 'stockage récent') } let(:src_lan_1) { FactoryBot.create(:lan) } let(:src_lan_2) { FactoryBot.create(:lan) } @@ -497,7 +497,7 @@ it "generates conversion options hash" do expect(task_1.conversion_options).to eq( - :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/#{src_storage.name}/#{src_vm_1.location}", + :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :transport_method => 'ssh', :rhv_url => "https://#{dst_ems.hostname}/ovirt-engine/api", :rhv_cluster => dst_cluster.name, @@ -606,7 +606,7 @@ it "generates conversion options hash" do expect(task_1.conversion_options).to eq( - :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/#{src_storage.name}/#{src_vm_1.location}", + :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :transport_method => 'ssh', :osp_environment => { :os_auth_url => URI::Generic.build(