Add a proxy command option to SSH commands

Now with more tests! Kinda.

Closes #207
This commit is contained in:
R. Tyler Croy 2014-05-30 09:03:56 -07:00
parent 33ac3fd574
commit 740f73eb64
4 changed files with 43 additions and 1 deletions

1
.rspec Normal file
View File

@ -0,0 +1 @@
--format doc --order random --color --fail-fast

View File

@ -86,7 +86,7 @@ module VagrantPlugins
"rsync", "--verbose", "--archive", "-z",
*excludes.map{|e|['--exclude', e]}.flatten,
"-e", "ssh -p #{ssh_info[:port]} #{ssh_key_options(ssh_info)} " +
ssh_options.map { |ssh_option| "-o '#{ssh_option}' " }.join,
ssh_options_to_args(ssh_options).join(' '),
hostpath,
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
@ -106,6 +106,18 @@ module VagrantPlugins
end
end
# Generate a ssh(1) command line list of options
#
# @param [Array] options An array of ssh options. E.g.
# `StrictHostKeyChecking=no` see ssh_config(5) for more
# @return [Array] Computed list of command line arguments
def ssh_options_to_args(options)
# Bail early if we get something that is not an array of options
return [] unless options
return options.map { |o| "-o '#{o}'" }
end
private
def ssh_key_options(ssh_info)

1
spec/spec_helper.rb Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,28 @@
require 'spec_helper'
require 'vagrant-aws/action/sync_folders'
describe VagrantPlugins::AWS::Action::SyncFolders do
let(:app) { nil }
let(:env) { {} }
subject(:action) { described_class.new(app, env) }
describe '#ssh_options_to_args' do
subject(:args) { action.ssh_options_to_args(options) }
context 'with no ssh options' do
let(:options) { [] }
it { should eql [] }
end
context 'with one option' do
let(:options) { ['StrictHostKeyChecking=no'] }
it { should eql ["-o 'StrictHostKeyChecking=no'"] }
end
context 'with multiple options' do
let(:options) { ['SHKC=no', 'Port=222'] }
it { should eql ["-o 'SHKC=no'", "-o 'Port=222'"] }
end
end
end