diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/knife/ssh_spec.rb | 28 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index aea7585bb2..cfe28b862f 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -246,6 +246,34 @@ describe Chef::Knife::Ssh do end end + context "when knife[:ssh_gateway_identity] is set" do + before do + setup_knife(["*:*", "uptime"]) + Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname" + Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/aws-gateway.rsa" + end + + it "uses the ssh_gateway_identity file" do + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => "#{ENV['HOME']}/.ssh/aws-gateway.rsa", :keys_only => true }) + @knife.run + expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") + end + end + + context "when -ssh-gateway-identity is provided and knife[:ssh_gateway] is set" do + before do + setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"]) + Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname" + Chef::Config[:knife][:ssh_gateway_identity] = nil + end + + it "uses the ssh_gateway_identity file" do + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => "#{ENV['HOME']}/.ssh/aws-gateway.rsa", :keys_only => true }) + @knife.run + expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") + end + end + context "when the gateway requires a password" do before do setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"]) diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 9f944b82d9..c2f68277c5 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -649,6 +649,7 @@ describe Chef::Knife::Bootstrap do Chef::Config[:knife][:forward_agent] = true Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/you.rsa" Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl" + Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/gateway.rsa" Chef::Config[:knife][:host_key_verify] = true allow(knife).to receive(:render_template).and_return("") knife.config = {} @@ -676,6 +677,10 @@ describe Chef::Knife::Bootstrap do expect(knife_ssh.config[:ssh_gateway]).to eq("towel.blinkenlights.nl") end + it "configures the ssh gateway identity" do + expect(knife_ssh.config[:ssh_gateway_identity]).to eq("~/.ssh/gateway.rsa") + end + it "configures the host key verify mode" do expect(knife_ssh.config[:host_key_verify]).to eq(true) end |