From a394d80254a67230b60a5947e33b86b2686b9887 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Sun, 4 May 2014 21:25:43 +0200 Subject: [PATCH] provisioners/ansible: minor change in unit tests --- .../provisioners/ansible/provisioner_test.rb | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb index 72879f455..8f0bf59ff 100644 --- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb +++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb @@ -143,7 +143,7 @@ VF end def self.it_should_use_transport_mode(transport_mode) - it "it enables '#{transport_mode}' transport mode" do + it "enables '#{transport_mode}' transport mode" do expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args| index = args.rindex("--connection=#{transport_mode}") expect(index).to be > 0 @@ -394,7 +394,7 @@ VF describe "with raw_ssh_args" do before do - config.raw_ssh_args = ['-o ControlMaster=no'] + config.raw_ssh_args = ['-o ControlMaster=no', '-o ForwardAgent=no'] end it_should_set_arguments_and_environment_variables 6, 4 @@ -405,12 +405,25 @@ VF cmd_opts = args.last raw_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=no") default_opt_index = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ControlMaster=auto") - expect(raw_opt_index).not_to be_nil - expect(default_opt_index).not_to be_nil expect(raw_opt_index).to be < default_opt_index } end + describe "and with ssh forwarding enabled" do + before do + ssh_info[:forward_agent] = true + end + + it "sets '-o ForwardAgent=yes' via ANSIBLE_SSH_ARGS with higher priority than raw_ssh_args values" do + expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args| + cmd_opts = args.last + forwardAgentYes = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=yes") + forwardAgentNo = cmd_opts[:env]['ANSIBLE_SSH_ARGS'].index("-o ForwardAgent=no") + expect(forwardAgentYes).to be < forwardAgentNo + } + end + end + end describe "with multiple SSH identities" do