From f15f5615249c59c826ea05d26707f062c88db32a Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Thu, 27 Feb 2014 15:19:14 +0400 Subject: [PATCH] Escape credentials for cirros image upload Special characters could cause cirros image upload to fail. Shellquote.escape will ensure the password passed is valid. Also fixes typo in cirros image upload failure Change-Id: I3773385d05e91c87ddf56c251203f6a2068b1c16 Closes-Bug: #1285318 --- lib/astute/orchestrator.rb | 8 ++++---- spec/unit/orchestrator_spec.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/astute/orchestrator.rb b/lib/astute/orchestrator.rb index ac00759b..8170f622 100644 --- a/lib/astute/orchestrator.rb +++ b/lib/astute/orchestrator.rb @@ -325,9 +325,9 @@ module Astute end os = { - 'os_tenant_name' => controller['access']['tenant'], - 'os_username' => controller['access']['user'], - 'os_password' => controller['access']['password'], + 'os_tenant_name' => Shellwords.escape("#{controller['access']['tenant']}"), + 'os_username' => Shellwords.escape("#{controller['access']['user']}"), + 'os_password' => Shellwords.escape("#{controller['access']['password']}"), 'os_auth_url' => "http://#{controller['management_vip'] || '127.0.0.1'}:5000/v2.0/", 'disk_format' => 'qcow2', 'container_format' => 'bare', @@ -344,7 +344,7 @@ module Astute when 'ubuntu_1204_x86_64' '/usr/share/cirros-testvm/cirros-x86_64-disk.img' else - raise CirrosError, "Unknow system #{controller['cobbler']['profile']}" + raise CirrosError, "Unknown system #{controller['cobbler']['profile']}" end auth_params = "-N #{os['os_auth_url']} \ -T #{os['os_tenant_name']} \ diff --git a/spec/unit/orchestrator_spec.rb b/spec/unit/orchestrator_spec.rb index baa951cb..05b6380e 100644 --- a/spec/unit/orchestrator_spec.rb +++ b/spec/unit/orchestrator_spec.rb @@ -259,7 +259,7 @@ describe Astute::Orchestrator do nodes_data.first['cobbler']['profile'] = 'unknown' ctx.expects(:status).returns(1 => 'success', 2 => 'success') Astute::DeploymentEngine::NailyFact.any_instance.stubs(:deploy).with(nodes_data) - expect {@orchestrator.send(:upload_cirros_image, nodes_data, ctx)}.to raise_error(Astute::CirrosError, /Unknow system/) + expect {@orchestrator.send(:upload_cirros_image, nodes_data, ctx)}.to raise_error(Astute::CirrosError, /Unknown system/) end it 'should not add new image if it already added' do