1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
require 'common'
require 'net/ssh'
module NetSSH
class TestStart < NetSSHTest
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
|