Sha256: f511fa064fadd4a22d379af0ebdde64d6b254c9a52b2630169228db8f7689044

Contents?: true

Size: 1.76 KB

Versions: 32

Compression:

Stored size: 1.76 KB

Contents

require 'al-test-utils'

class TestBasePerInstance < Test::Unit::TestCase
  include AlTestUtils

  def setup
    super
    ou_class("ou=Users").new("Sub").save!
  end

  priority :must
  def test_set_base
    guest = @user_class.new("guest")
    guest.base = "ou=Sub"
    assert_equal("uid=guest,ou=Sub,#{@user_class.base}", guest.dn)
  end

  priority :normal
  def test_dn_is_base
    entry_class = Class.new(ActiveLdap::Base)
    entry_class.ldap_mapping :prefix => "",
                             :classes => ["top"],
                             :scope => :sub
    entry_class.dn_attribute = nil

    entry = entry_class.root
    assert_equal(entry_class.base, entry.dn)
    assert_equal(entry_class.base, entry.base)
  end

  def test_loose_dn
    user = @user_class.new("test-user , ou = Sub")
    assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)

    user = @user_class.new("test-user , ou = Sub, #{@user_class.base}")
    assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
  end

  def test_exists?
    make_temporary_user(:uid => "test-user,ou=Sub") do |user, password|
      assert(@user_class.exists?(user.uid))
      assert(@user_class.exists?("uid=#{user.uid}"))
      assert(@user_class.exists?(user.dn))

      assert(@user_class.exists?("test-user,ou=Sub"))
      assert(@user_class.exists?("uid=test-user,ou=Sub"))
    end
  end

  def test_add
    make_temporary_user(:uid => "test-user,ou=Sub") do |user, password|
      assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
      assert_equal("test-user", user.uid)
    end

    make_temporary_user(:uid => "uid=test-user,ou=Sub") do |user, password|
      assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
      assert_equal("test-user", user.uid)
    end
  end
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
activeldap-6.0.2 test/test_base_per_instance.rb
activeldap-6.0.1 test/test_base_per_instance.rb
activeldap-6.0.0 test/test_base_per_instance.rb
activeldap-5.2.4 test/test_base_per_instance.rb
activeldap-5.2.3 test/test_base_per_instance.rb
activeldap-5.2.2 test/test_base_per_instance.rb
activeldap-5.2.1 test/test_base_per_instance.rb
activeldap-5.2.0 test/test_base_per_instance.rb
activeldap-5.1.1 test/test_base_per_instance.rb
activeldap-5.1.0 test/test_base_per_instance.rb
activeldap-3.2.3 test/test_base_per_instance.rb
powerhome-activeldap-3.2.3 test/test_base_per_instance.rb
activeldap-4.0.6 test/test_base_per_instance.rb
activeldap-4.0.5 test/test_base_per_instance.rb
activeldap-4.0.4 test/test_base_per_instance.rb
activeldap-4.0.3 test/test_base_per_instance.rb
activeldap-4.0.2 test/test_base_per_instance.rb
activeldap-4.0.1 test/test_base_per_instance.rb
activeldap-4.0.0 test/test_base_per_instance.rb
activeldap-3.2.2 test/test_base_per_instance.rb