Sha256: af2dc8391ab2a30d8afc9de1ce90045f6049c1ffb04526511522e4f5026d0757

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'al-test-utils'

class TestConnection < Test::Unit::TestCase
  include AlTestUtils::Config
  include AlTestUtils::MockLogger

  def setup
    super
  end

  def teardown
    ActiveLdap::Base.clear_active_connections!
    super
  end

  priority :must

  priority :normal
  def test_bind_format_check
    connector = Class.new(ActiveLdap::Base)
    assert(!connector.connected?)
    exception = nil
    assert_raises(ArgumentError) do
      begin
        connector.establish_connection(:adapter => adapter,
                                       :bind_format => "uid=%s,dc=test",
                                       :allow_anonymous => false)
        connector.connection.connect
      rescue Exception
        exception = $!
        raise
      end
    end
    assert_equal("Unknown key(s): bind_format", exception.message)
  end

  def test_can_reconnect?
    assert(!ActiveLdap::Base.connected?)

    config = current_configuration.merge("retry_limit" => 10)
    ActiveLdap::Base.establish_connection(config)
    connection = ActiveLdap::Base.connection
    assert(!connection.send(:can_reconnect?, :reconnect_attempts => 10))

    config = current_configuration.merge("retry_limit" => 10)
    ActiveLdap::Base.establish_connection(config)
    connection = ActiveLdap::Base.connection
    assert(!connection.send(:can_reconnect?, :reconnect_attempts => 9))

    config = current_configuration.merge("retry_limit" => 10)
    ActiveLdap::Base.establish_connection(config)
    connection = ActiveLdap::Base.connection
    assert(connection.send(:can_reconnect?, :reconnect_attempts => 8))

    config = current_configuration.merge("retry_limit" => -1)
    ActiveLdap::Base.establish_connection(config)
    connection = ActiveLdap::Base.connection
    assert(connection.send(:can_reconnect?, :reconnect_attempts => -10))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeldap-0.10.0 test/test_connection.rb
activeldap-1.0.0 test/test_connection.rb
activeldap-1.0.1 test/test_connection.rb
activeldap-1.0.2 test/test_connection.rb