Sha256: 49517b043bab04a0b1d3c061356882520692642d16176809ceb590f1098c07de

Contents?: true

Size: 1.57 KB

Versions: 143

Compression:

Stored size: 1.57 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_when_password_is_unacceptible_should_return_false
      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 !subject.authenticate("ssh-connection", "jamis", "the-password")
    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

143 entries across 113 versions & 11 rubygems

Version Path
auser-poolparty-1.3.10 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.11 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.12 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.13 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.14 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.15 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.16 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.17 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.5 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.6 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.7 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
auser-poolparty-1.3.8 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
ddollar-net-ssh-2.0.1 test/authentication/methods/test_password.rb
fairchild-poolparty-1.3.17 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
fairchild-poolparty-1.3.5 vendor/gems/net-ssh/test/authentication/methods/test_password.rb
jayniz-net-ssh-2.0.15 test/authentication/methods/test_password.rb
kjvarga-net-ssh-2.0.12 test/authentication/methods/test_password.rb
net-ssh-net-ssh-2.0.12 test/authentication/methods/test_password.rb
net-ssh-net-ssh-2.0.13 test/authentication/methods/test_password.rb
net-ssh-net-ssh-2.0.14 test/authentication/methods/test_password.rb