File: test_configuration.rb

package info (click to toggle)
ruby-activeldap 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,588 kB
  • sloc: ruby: 18,143; sh: 12; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'al-test-utils'

class TestConfiguration < Test::Unit::TestCase
  priority :must

  priority :normal
  def test_prepare_configuration_with_silent_uri
    configuration = {
      :base => "dc=example,dc=com",
      :password => "secret",
      :uri => "ldap://example.com/dc=ignore,dc=me"
    }
    prepared_configuration =
      ActiveLdap::Base.prepare_configuration(configuration)
    assert_equal({
                   :host => "example.com",
                   :port => 389,
                   :base => "dc=example,dc=com",
                   :password => "secret",
                 },
                 prepared_configuration)
  end

  def test_prepare_configuration_with_detailed_uri
    bind_dn = "cn=admin,dc=example,dc=com"
    configuration = {
      :host => "example.net",
      :uri => "ldaps://example.com/dc=example,dc=com??sub??!bindname=#{CGI.escape(bind_dn)}"
    }
    prepared_configuration =
      ActiveLdap::Base.prepare_configuration(configuration)
    assert_equal({
                   :host => "example.net",
                   :port => 636,
                   :method => :ssl,
                   :base => "dc=example,dc=com",
                   :scope => "sub",
                   :bind_dn => "cn=admin,dc=example,dc=com",
                   :allow_anonymous => false,
                 },
                 prepared_configuration)
  end
end