File: test_user_nil.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 (27 lines) | stat: -rw-r--r-- 918 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
require 'common'
require 'net/ssh'

module NetSSH
  class TestStartUserNil < NetSSHTest
    def setup
      @authentication_session = mock('authentication_session')
      Net::SSH::Authentication::Session.stubs(:new).returns(@authentication_session)
      Net::SSH::Transport::Session.stubs(:new).returns(mock('transport_session'))
      Net::SSH::Connection::Session.stubs(:new).returns(mock('connection_session'))
    end

    def test_start_should_accept_nil_user
      @authentication_session.stubs(:authenticate).returns(true)
      assert_nothing_raised do
        Net::SSH.start('localhost')
      end
    end

    def test_start_should_use_default_user_when_nil
      @authentication_session.stubs(:authenticate).with { |_next_service, user, _password| user == Etc.getpwuid.name }.returns(true)
      assert_nothing_raised do
        Net::SSH.start('localhost', nil, config: false)
      end
    end
  end
end