File: test_transport.rb

package info (click to toggle)
ruby-net-ssh 1%3A7.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,804 kB
  • sloc: ruby: 16,999; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (2)
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