Sha256: fb2e521ffc5e429f9dab3297b1dd6c9e786c00577107128fdf48831aff7182ff

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require_relative 'test_helper'

class TestEntry < Test::Unit::TestCase
  def setup
    @entry = Net::LDAP::Entry.new 'cn=Barbara,o=corp'
  end

  def test_dn
    assert_equal 'cn=Barbara,o=corp', @entry.dn
  end

  def test_empty_array_when_accessing_nonexistent_attribute
    assert_equal [], @entry['sn']
  end

  def test_attribute_assignment
    @entry['sn'] = 'Jensen'
    assert_equal ['Jensen'], @entry['sn']
    assert_equal ['Jensen'], @entry.sn
    assert_equal ['Jensen'], @entry[:sn]

    @entry[:sn] = 'Jensen'
    assert_equal ['Jensen'], @entry['sn']
    assert_equal ['Jensen'], @entry.sn
    assert_equal ['Jensen'], @entry[:sn]

    @entry.sn = 'Jensen'
    assert_equal ['Jensen'], @entry['sn']
    assert_equal ['Jensen'], @entry.sn
    assert_equal ['Jensen'], @entry[:sn]
  end

  def test_case_insensitive_attribute_names
    @entry['sn'] = 'Jensen'
    assert_equal ['Jensen'], @entry.sn
    assert_equal ['Jensen'], @entry.Sn
    assert_equal ['Jensen'], @entry.SN
    assert_equal ['Jensen'], @entry['sn']
    assert_equal ['Jensen'], @entry['Sn']
    assert_equal ['Jensen'], @entry['SN']
  end
end

class TestEntryLDIF < Test::Unit::TestCase
  def setup
    @entry = Net::LDAP::Entry.from_single_ldif_string(
      %Q{dn: something
foo: foo
barAttribute: bar
      })
  end

  def test_attribute
    assert_equal ['foo'], @entry.foo
    assert_equal ['foo'], @entry.Foo
  end

  def test_modify_attribute
    @entry.foo = 'bar'
    assert_equal ['bar'], @entry.foo

    @entry.fOo= 'baz'
    assert_equal ['baz'], @entry.foo
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
net-ldap-0.16.2 test/test_entry.rb
net-ldap-0.16.1 test/test_entry.rb
net-ldap-0.16.0 test/test_entry.rb
net-ldap-0.15.0 test/test_entry.rb
net-ldap-0.14.0 test/test_entry.rb
net-ldap-0.13.0 test/test_entry.rb
net-ldap-0.12.1 test/test_entry.rb
net-ldap-0.12.0 test/test_entry.rb
net-ldap-0.11 test/test_entry.rb
net-ldap-0.10.1 test/test_entry.rb
net-ldap-0.10.0 test/test_entry.rb
net-ldap-0.9.0 test/test_entry.rb