Signed-off-by: Brice Figureau <[email protected]>
---
 lib/puppet/util/network_device/transport/ssh.rb    |    4 ++++
 .../unit/util/network_device/transport/ssh_spec.rb |    8 ++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/util/network_device/transport/ssh.rb 
b/lib/puppet/util/network_device/transport/ssh.rb
index b3cf51b..bf0e719 100644
--- a/lib/puppet/util/network_device/transport/ssh.rb
+++ b/lib/puppet/util/network_device/transport/ssh.rb
@@ -31,6 +31,10 @@ class Puppet::Util::NetworkDevice::Transport::Ssh < 
Puppet::Util::NetworkDevice:
       @ssh = Net::SSH.start(host, user, :port => port, :password => password, 
:timeout => timeout)
     rescue TimeoutError
       raise TimeoutError, "timed out while opening an ssh connection to the 
host"
+    rescue Net::SSH::AuthenticationFailed
+      raise Puppet::Error, "SSH authentication failure connecting to #{host} 
as #{user}"
+    rescue Net::SSH::Exception => detail
+      raise Puppet::Error, "SSH connection failure to #{host}"
     end
 
     @buf = ""
diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb 
b/spec/unit/util/network_device/transport/ssh_spec.rb
index 0e91ed9..18d22a9 100755
--- a/spec/unit/util/network_device/transport/ssh_spec.rb
+++ b/spec/unit/util/network_device/transport/ssh_spec.rb
@@ -30,6 +30,14 @@ describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => 
Puppet.features.ssh
     @transport.connect
   end
 
+  it "should raise a Puppet::Error when encountering an authentication 
failure" do
+    Net::SSH.expects(:start).raises Net::SSH::AuthenticationFailed
+    @transport.host = "localhost"
+    @transport.user = "user"
+
+    lambda { @transport.connect }.should raise_error Puppet::Error
+  end
+
   describe "when connected" do
     before(:each) do
       @ssh = stub_everything 'ssh'
-- 
1.7.2.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to