File: test_ber.rb

package info (click to toggle)
ruby-net-ldap 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: ruby: 4,583; sh: 53; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require_relative '../test_helper'

class TestBERIntegration < LDAPIntegrationTestCase
  # Test whether the TRUE boolean value is encoded correctly by performing a
  # search operation.
  def test_true_ber_encoding
    # request these attrs to simplify test; use symbols to match Entry#attribute_names
    attrs = [:dn, :uid, :cn, :mail]

    assert types_entry = @ldap.search(
      base: "dc=example,dc=org",
      filter: "(uid=user1)",
      size: 1,
      attributes: attrs,
      attributes_only: true,
    ).first

    # matches attributes we requested
    assert_equal attrs, types_entry.attribute_names

    # assert values are empty
    types_entry.each do |name, values|
      next if name == :dn
      assert values.empty?
    end

    assert_includes Net::LDAP::ResultCodesSearchSuccess,
                    @ldap.get_operation_result.code, "should be a successful search operation"
  end
end