Sha256: ef3429083541ad639ae2a4ca95e3b6d3bc2cbc88ceb35b8a311f718d6bf777c4

Contents?: true

Size: 1.63 KB

Versions: 42

Compression:

Stored size: 1.63 KB

Contents

require 'common'
require 'net/ssh/authentication/methods/password'
require 'authentication/methods/common'

module Authentication; module Methods

  class TestPassword < Test::Unit::TestCase
    include Common

    def test_authenticate_should_raise_if_password_disallowed
      transport.expect do |t,packet|
        assert_equal USERAUTH_REQUEST, packet.type
        assert_equal "jamis", packet.read_string
        assert_equal "ssh-connection", packet.read_string
        assert_equal "password", packet.read_string
        assert_equal false, packet.read_bool
        assert_equal "the-password", packet.read_string

        t.return(USERAUTH_FAILURE, :string, "publickey")
      end

      assert_raises Net::SSH::Authentication::DisallowedMethod do
        subject.authenticate("ssh-connection", "jamis", "the-password")
      end
    end

    def test_authenticate_when_password_is_acceptible_should_return_true
      transport.expect do |t,packet|
        assert_equal USERAUTH_REQUEST, packet.type
        t.return(USERAUTH_SUCCESS)
      end

      assert subject.authenticate("ssh-connection", "jamis", "the-password")
    end

    def test_authenticate_should_return_false_if_password_change_request_is_received
      transport.expect do |t,packet|
        assert_equal USERAUTH_REQUEST, packet.type
        t.return(USERAUTH_PASSWD_CHANGEREQ, :string, "Change your password:", :string, "")
      end

      assert !subject.authenticate("ssh-connection", "jamis", "the-password")
    end

    private

      def subject(options={})
        @subject ||= Net::SSH::Authentication::Methods::Password.new(session(options), options)
      end
  end

end; end

Version data entries

42 entries across 40 versions & 13 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/net-ssh-2.4.0/test/authentication/methods/test_password.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/net-ssh-2.9.1/test/authentication/methods/test_password.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/net-ssh-2.9.1/test/authentication/methods/test_password.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/net-ssh-2.9.1/test/authentication/methods/test_password.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/net-ssh-2.9.1/test/authentication/methods/test_password.rb
net-ssh-2.9.1 test/authentication/methods/test_password.rb
net-ssh-2.9.0 test/authentication/methods/test_password.rb
net-ssh-2.8.0 test/authentication/methods/test_password.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/test/authentication/methods/test_password.rb
net-ssh-2.7.0 test/authentication/methods/test_password.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/test/authentication/methods/test_password.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/test/authentication/methods/test_password.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/test/authentication/methods/test_password.rb
net-ssh-2.6.8 test/authentication/methods/test_password.rb
minmb-net-ssh-2.5.1 test/authentication/methods/test_password.rb
vagrant-shell-0.2.6 vendor/bundle/gems/net-ssh-2.6.7/test/authentication/methods/test_password.rb
vagrant-shell-0.2.5 vendor/bundle/gems/net-ssh-2.6.7/test/authentication/methods/test_password.rb
net-ssh-2.6.7 test/authentication/methods/test_password.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/net-ssh-2.2.2/test/authentication/methods/test_password.rb
net-ssh-2.6.6 test/authentication/methods/test_password.rb