diff options
author | Patrick Marchi <patrick.marchi@geo.uzh.ch> | 2011-03-14 15:04:42 +0100 |
---|---|---|
committer | Patrick Marchi <patrick.marchi@geo.uzh.ch> | 2011-03-14 15:04:42 +0100 |
commit | 83d868ba35b8f41824b9906b064271e5df06a64d (patch) | |
tree | 6aa86b70405818592513d9e04816abfda5f4e1c1 | |
parent | 07df0ed759fbf41b5cefb1c4fc24cbad08899040 (diff) | |
download | net-ssh-83d868ba35b8f41824b9906b064271e5df06a64d.tar.gz |
Test case for transport.close after auth failure
The code was totally untested.
-rw-r--r-- | test/start/test_transport.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/start/test_transport.rb b/test/start/test_transport.rb new file mode 100644 index 0000000..41fc8a9 --- /dev/null +++ b/test/start/test_transport.rb @@ -0,0 +1,28 @@ +require 'common' +require 'net/ssh' + +module NetSSH + class TestStart < Test::Unit::TestCase + attr_reader :transport_session + attr_reader :authentication_session + + def setup + @transport_session = mock('transport_session') + @authentication_session = mock('authentication_session') + Net::SSH::Transport::Session.expects(:new => transport_session) + Net::SSH::Authentication::Session.expects(:new => authentication_session) + end + + def test_close_transport_when_authentication_fails + authentication_session.expects(:authenticate => false) + + transport_session.expects(:close).at_least_once + + begin + Net::SSH.start('localhost', 'testuser') {} + rescue Net::SSH::AuthenticationFailed + # Authentication should fail, as it is part of the context + end + end + end +end
\ No newline at end of file |