Sha256: 8c82f1bef2a69d1e2f826d527e12647cff988a0c196698234e0df36c0575f3ea

Contents?: true

Size: 1.69 KB

Versions: 38

Compression:

Stored size: 1.69 KB

Contents

require 'al-test-utils'

class TestBind < Test::Unit::TestCase
  include AlTestUtils::Config

  def setup
    super
  end

  def teardown
    ActiveLdap::Base.clear_active_connections!
    super
  end

  def test_anonymous
    assert(!ActiveLdap::Base.connected?)
    assert_nothing_raised do
      config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
      config = ActiveLdap::Base.prepare_configuration(config)
      config.delete(:bind_dn)
      config[:allow_anonymous] = true
      connect(config)
    end
    assert(ActiveLdap::Base.connected?,
           "Checking is the connection was established.")
  end

  def test_bind
    assert(!ActiveLdap::Base.connected?)
    config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
    config = ActiveLdap::Base.prepare_configuration(config)
    if config[:bind_dn].nil? and !config[:try_sasl]
      omit("need user configuration")
    end
    assert_nothing_raised do
      config[:allow_anonymous] = false
      connect(config)
    end
    assert(ActiveLdap::Base.connected?,
           "Checking is the connection was established.")
    assert(ActiveLdap::Base.connection.bound?)
  end

  def test_failed_bind
    assert(!ActiveLdap::Base.connected?)
    assert_raises(ActiveLdap::AuthenticationError) do
      config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
      config = ActiveLdap::Base.prepare_configuration(config)
      config.delete(:bind_dn)
      config[:try_sasl] = false
      config[:allow_anonymous] = false
      connect(config)
    end
    assert(!ActiveLdap::Base.connection.bound?)
  end

  private
  def connect(config)
    ActiveLdap::Base.setup_connection(config)
    ActiveLdap::Base.connection.connect
  end
end

Version data entries

38 entries across 38 versions & 3 rubygems

Version Path
activeldap-7.2.1 test/test_bind.rb
activeldap-7.2.0 test/test_bind.rb
activeldap-7.0.0 test/test_bind.rb
activeldap-6.1.0 test/test_bind.rb
activeldap-6.0.4 test/test_bind.rb
activeldap-6.0.3 test/test_bind.rb
activeldap-6.0.2 test/test_bind.rb
activeldap-6.0.1 test/test_bind.rb
activeldap-6.0.0 test/test_bind.rb
activeldap-5.2.4 test/test_bind.rb
activeldap-5.2.3 test/test_bind.rb
activeldap-5.2.2 test/test_bind.rb
activeldap-5.2.1 test/test_bind.rb
activeldap-5.2.0 test/test_bind.rb
activeldap-5.1.1 test/test_bind.rb
activeldap-5.1.0 test/test_bind.rb
activeldap-3.2.3 test/test_bind.rb
powerhome-activeldap-3.2.3 test/test_bind.rb
activeldap-4.0.6 test/test_bind.rb
activeldap-4.0.5 test/test_bind.rb