deveo-ruby-ldapserver 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +3 -0
 - data/COPYING +27 -0
 - data/ChangeLog +83 -0
 - data/Gemfile +4 -0
 - data/README +222 -0
 - data/Rakefile +1 -0
 - data/examples/README +89 -0
 - data/examples/mkcert.rb +31 -0
 - data/examples/rbslapd1.rb +111 -0
 - data/examples/rbslapd2.rb +161 -0
 - data/examples/rbslapd2.sql +11 -0
 - data/examples/rbslapd3.rb +172 -0
 - data/examples/speedtest.rb +37 -0
 - data/lib/ldap/server.rb +4 -0
 - data/lib/ldap/server/connection.rb +251 -0
 - data/lib/ldap/server/filter.rb +223 -0
 - data/lib/ldap/server/match.rb +283 -0
 - data/lib/ldap/server/operation.rb +492 -0
 - data/lib/ldap/server/preforkserver.rb +92 -0
 - data/lib/ldap/server/result.rb +71 -0
 - data/lib/ldap/server/schema.rb +592 -0
 - data/lib/ldap/server/server.rb +104 -0
 - data/lib/ldap/server/syntax.rb +235 -0
 - data/lib/ldap/server/tcpserver.rb +89 -0
 - data/lib/ldap/server/util.rb +88 -0
 - data/lib/ldap/server/version.rb +5 -0
 - data/ruby-ldapserver.gemspec +22 -0
 - data/test/core.schema +582 -0
 - data/test/encoding_test.rb +323 -0
 - data/test/filter_test.rb +107 -0
 - data/test/match_test.rb +59 -0
 - data/test/schema_test.rb +113 -0
 - data/test/syntax_test.rb +40 -0
 - data/test/test_helper.rb +2 -0
 - data/test/util_test.rb +47 -0
 - metadata +117 -0
 
| 
         @@ -0,0 +1,323 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Thread.abort_on_exception = true
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # This test suite requires the ruby-ldap client library to be installed.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # Unfortunately, this library is not ruby thread-safe (it blocks until
         
     | 
| 
      
 8 
     | 
    
         
            +
            # it gets a response). Hence we have to fork a child to perform the actual
         
     | 
| 
      
 9 
     | 
    
         
            +
            # LDAP requests, which is nasty. However, it does give us a completely
         
     | 
| 
      
 10 
     | 
    
         
            +
            # independent source of LDAP packets to try.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            require 'ldap/server/operation'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'ldap/server/server'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            require 'ldap'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # We subclass the Operation class, overriding the methods to do what we need
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            class MockOperation < LDAP::Server::Operation
         
     | 
| 
      
 20 
     | 
    
         
            +
              def initialize(connection, messageId)
         
     | 
| 
      
 21 
     | 
    
         
            +
                super(connection, messageId)
         
     | 
| 
      
 22 
     | 
    
         
            +
                @@lastop = [:connect]
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              def simple_bind(version, user, pass)
         
     | 
| 
      
 26 
     | 
    
         
            +
                @@lastop = [:simple_bind, version, user, pass]
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def search(basedn, scope, deref, filter)
         
     | 
| 
      
 30 
     | 
    
         
            +
                @@lastop = [:search, basedn, scope, deref, filter, @attributes]
         
     | 
| 
      
 31 
     | 
    
         
            +
                send_SearchResultEntry("cn=foo", {"a"=>["1","2"], "b"=>"boing"})
         
     | 
| 
      
 32 
     | 
    
         
            +
                send_SearchResultEntry("cn=bar", {"a"=>["3","4","5"], "b"=>"wibble"})
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def add(dn, av)
         
     | 
| 
      
 36 
     | 
    
         
            +
                @@lastop = [:add, dn, av]
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def del(dn)
         
     | 
| 
      
 40 
     | 
    
         
            +
                @@lastop = [:del, dn]
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def modify(dn, ops)
         
     | 
| 
      
 44 
     | 
    
         
            +
                @@lastop = [:modify, dn, ops]
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              def modifydn(dn, newrdn, deleteoldrdn, newSuperior)
         
     | 
| 
      
 48 
     | 
    
         
            +
                @@lastop = [:modifydn, dn, newrdn, deleteoldrdn, newSuperior]
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def compare(dn, attr, val)
         
     | 
| 
      
 52 
     | 
    
         
            +
                @@lastop = [:compare, dn, attr, val]
         
     | 
| 
      
 53 
     | 
    
         
            +
                return val != "false"
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def self.lastop
         
     | 
| 
      
 57 
     | 
    
         
            +
                @@lastop
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            class TestLdap < Test::Unit::TestCase
         
     | 
| 
      
 62 
     | 
    
         
            +
              HOST = '127.0.0.1'
         
     | 
| 
      
 63 
     | 
    
         
            +
              PORT = 1389
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 66 
     | 
    
         
            +
                @ppid = $$
         
     | 
| 
      
 67 
     | 
    
         
            +
                @io = IO.popen("-","w+") # this is a fork()
         
     | 
| 
      
 68 
     | 
    
         
            +
                unless @io
         
     | 
| 
      
 69 
     | 
    
         
            +
                  do_child
         
     | 
| 
      
 70 
     | 
    
         
            +
                  exit!
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                # back to a single process (the parent). Now we start our
         
     | 
| 
      
 74 
     | 
    
         
            +
                # listener thread
         
     | 
| 
      
 75 
     | 
    
         
            +
                @serv = LDAP::Server.new(
         
     | 
| 
      
 76 
     | 
    
         
            +
                	:bindaddr		=> '127.0.0.1',
         
     | 
| 
      
 77 
     | 
    
         
            +
                	:port			=> PORT,
         
     | 
| 
      
 78 
     | 
    
         
            +
                	:nodelay		=> true,
         
     | 
| 
      
 79 
     | 
    
         
            +
                	:operation_class	=> MockOperation
         
     | 
| 
      
 80 
     | 
    
         
            +
                )
         
     | 
| 
      
 81 
     | 
    
         
            +
                @serv.run_tcpserver
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 85 
     | 
    
         
            +
                if @serv
         
     | 
| 
      
 86 
     | 
    
         
            +
                  @serv.stop
         
     | 
| 
      
 87 
     | 
    
         
            +
                  @serv = nil
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
                if @io
         
     | 
| 
      
 90 
     | 
    
         
            +
                  @io.puts "quit"
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @io.gets
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @io.close
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @io = nil
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              # Process commands on stdin in child
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              def do_child
         
     | 
| 
      
 100 
     | 
    
         
            +
                while true
         
     | 
| 
      
 101 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 102 
     | 
    
         
            +
                    a = gets.chomp
         
     | 
| 
      
 103 
     | 
    
         
            +
                    conn ||= LDAP::Conn.new(HOST,PORT)
         
     | 
| 
      
 104 
     | 
    
         
            +
                    case a
         
     | 
| 
      
 105 
     | 
    
         
            +
                    when "bind2"
         
     | 
| 
      
 106 
     | 
    
         
            +
                      conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 2)
         
     | 
| 
      
 107 
     | 
    
         
            +
                      conn.bind("foo","bar")
         
     | 
| 
      
 108 
     | 
    
         
            +
                    when "bind3"
         
     | 
| 
      
 109 
     | 
    
         
            +
                      conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
         
     | 
| 
      
 110 
     | 
    
         
            +
                      conn.bind("foo","bar")
         
     | 
| 
      
 111 
     | 
    
         
            +
                    # these examples taken from the ruby-ldap examples
         
     | 
| 
      
 112 
     | 
    
         
            +
                    when "add1"
         
     | 
| 
      
 113 
     | 
    
         
            +
                      entry1 = [
         
     | 
| 
      
 114 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'objectclass', ['top', 'domain']),
         
     | 
| 
      
 115 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'o', ['TTSKY.NET']),
         
     | 
| 
      
 116 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'dc', ['localhost']),
         
     | 
| 
      
 117 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 118 
     | 
    
         
            +
                      conn.add("dc=localhost, dc=domain", entry1)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    when "add2"
         
     | 
| 
      
 120 
     | 
    
         
            +
                      entry2 = [
         
     | 
| 
      
 121 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'objectclass', ['top', 'person']),
         
     | 
| 
      
 122 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'cn', ['Takaaki Tateishi']),
         
     | 
| 
      
 123 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD | LDAP::LDAP_MOD_BVALUES, 'sn', ['ttate','Tateishi', "zero\000zero"]),
         
     | 
| 
      
 124 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 125 
     | 
    
         
            +
                      conn.add("cn=Takaaki Tateishi, dc=localhost, dc=localdomain", entry2)
         
     | 
| 
      
 126 
     | 
    
         
            +
                    when "del"
         
     | 
| 
      
 127 
     | 
    
         
            +
                      conn.delete("cn=Takaaki-Tateishi, dc=localhost, dc=localdomain")
         
     | 
| 
      
 128 
     | 
    
         
            +
                    when /^compare (.*)/
         
     | 
| 
      
 129 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 130 
     | 
    
         
            +
                        case conn.compare("cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
         
     | 
| 
      
 131 
     | 
    
         
            +
                                     "cn", $1)
         
     | 
| 
      
 132 
     | 
    
         
            +
                        when true; puts "OK true"; next
         
     | 
| 
      
 133 
     | 
    
         
            +
                        when false; puts "OK false"; next
         
     | 
| 
      
 134 
     | 
    
         
            +
                        end
         
     | 
| 
      
 135 
     | 
    
         
            +
                      rescue LDAP::ResultError => e
         
     | 
| 
      
 136 
     | 
    
         
            +
                        # For older versions of ruby-ldap
         
     | 
| 
      
 137 
     | 
    
         
            +
                        case e.message
         
     | 
| 
      
 138 
     | 
    
         
            +
                        when /Compare True/i; puts "OK true"; next
         
     | 
| 
      
 139 
     | 
    
         
            +
                        when /Compare False/i; puts "OK false"; next
         
     | 
| 
      
 140 
     | 
    
         
            +
                        end
         
     | 
| 
      
 141 
     | 
    
         
            +
                        raise
         
     | 
| 
      
 142 
     | 
    
         
            +
                      end
         
     | 
| 
      
 143 
     | 
    
         
            +
                    when "modrdn"
         
     | 
| 
      
 144 
     | 
    
         
            +
                      conn.modrdn("cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
         
     | 
| 
      
 145 
     | 
    
         
            +
                                  "cn=Takaaki-Tateishi",
         
     | 
| 
      
 146 
     | 
    
         
            +
                                  true)
         
     | 
| 
      
 147 
     | 
    
         
            +
                    when "modify"
         
     | 
| 
      
 148 
     | 
    
         
            +
                      entry = [
         
     | 
| 
      
 149 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_ADD, 'objectclass', ['top', 'domain']),
         
     | 
| 
      
 150 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_DELETE, 'o', []),
         
     | 
| 
      
 151 
     | 
    
         
            +
                        LDAP.mod(LDAP::LDAP_MOD_REPLACE, 'dc', ['localhost']),
         
     | 
| 
      
 152 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 153 
     | 
    
         
            +
                      conn.modify("dc=localhost, dc=domain", entry)
         
     | 
| 
      
 154 
     | 
    
         
            +
                    when "search"
         
     | 
| 
      
 155 
     | 
    
         
            +
                      res = {}
         
     | 
| 
      
 156 
     | 
    
         
            +
                      conn.search("dc=localhost, dc=localdomain",
         
     | 
| 
      
 157 
     | 
    
         
            +
                                  LDAP::LDAP_SCOPE_SUBTREE,
         
     | 
| 
      
 158 
     | 
    
         
            +
                                  "(objectclass=*)") do |e|
         
     | 
| 
      
 159 
     | 
    
         
            +
                        entry = e.to_hash
         
     | 
| 
      
 160 
     | 
    
         
            +
                        dn = entry.delete("dn").first
         
     | 
| 
      
 161 
     | 
    
         
            +
                        res[dn] = entry
         
     | 
| 
      
 162 
     | 
    
         
            +
                      end
         
     | 
| 
      
 163 
     | 
    
         
            +
                      exp = {
         
     | 
| 
      
 164 
     | 
    
         
            +
                        "cn=foo" => {"a"=>["1","2"], "b"=>["boing"]},
         
     | 
| 
      
 165 
     | 
    
         
            +
                        "cn=bar" => {"a"=>["3","4","5"], "b"=>["wibble"]},
         
     | 
| 
      
 166 
     | 
    
         
            +
                      }
         
     | 
| 
      
 167 
     | 
    
         
            +
                      if res != exp
         
     | 
| 
      
 168 
     | 
    
         
            +
                        raise "Bad Search Result, expected\n#{exp.inspect}\ngot\n#{res.inspect}"
         
     | 
| 
      
 169 
     | 
    
         
            +
                      end
         
     | 
| 
      
 170 
     | 
    
         
            +
                    when "search2"
         
     | 
| 
      
 171 
     | 
    
         
            +
                      # FIXME: ruby-ldap doesn't seem to allow DEREF options to be set
         
     | 
| 
      
 172 
     | 
    
         
            +
                      conn.search("dc=localhost, dc=localdomain",
         
     | 
| 
      
 173 
     | 
    
         
            +
                                  LDAP::LDAP_SCOPE_BASE,
         
     | 
| 
      
 174 
     | 
    
         
            +
                                  "(&(cn=foo)(objectclass=*)(|(!(sn=*))(ou>=baz)(o<=z)(cn~=brian)(cn=*and*er)))",
         
     | 
| 
      
 175 
     | 
    
         
            +
                                  ["a","b"]) do |e|
         
     | 
| 
      
 176 
     | 
    
         
            +
                        entry = e.to_hash
         
     | 
| 
      
 177 
     | 
    
         
            +
                        dn = entry.delete("dn").first
         
     | 
| 
      
 178 
     | 
    
         
            +
                        res[dn] = entry
         
     | 
| 
      
 179 
     | 
    
         
            +
                      end
         
     | 
| 
      
 180 
     | 
    
         
            +
                    when "search_retrieve_attrs"
         
     | 
| 
      
 181 
     | 
    
         
            +
                      res = {}
         
     | 
| 
      
 182 
     | 
    
         
            +
                      conn.search("dc=localhost, dc=localdomain",
         
     | 
| 
      
 183 
     | 
    
         
            +
                                  LDAP::LDAP_SCOPE_SUBTREE,
         
     | 
| 
      
 184 
     | 
    
         
            +
                                  "(objectclass=*)",
         
     | 
| 
      
 185 
     | 
    
         
            +
                                  ["B"]) do |e|
         
     | 
| 
      
 186 
     | 
    
         
            +
                        entry = e.to_hash
         
     | 
| 
      
 187 
     | 
    
         
            +
                        dn = entry.delete("dn").first
         
     | 
| 
      
 188 
     | 
    
         
            +
                        res[dn] = entry
         
     | 
| 
      
 189 
     | 
    
         
            +
                      end
         
     | 
| 
      
 190 
     | 
    
         
            +
                      exp = {
         
     | 
| 
      
 191 
     | 
    
         
            +
                        "cn=foo" => {"b"=>["boing"]},
         
     | 
| 
      
 192 
     | 
    
         
            +
                        "cn=bar" => {"b"=>["wibble"]},
         
     | 
| 
      
 193 
     | 
    
         
            +
                      }
         
     | 
| 
      
 194 
     | 
    
         
            +
                      if res != exp
         
     | 
| 
      
 195 
     | 
    
         
            +
                        raise "Bad Search Result, expected\n#{exp.inspect}\ngot\n#{res.inspect}"
         
     | 
| 
      
 196 
     | 
    
         
            +
                      end
         
     | 
| 
      
 197 
     | 
    
         
            +
                    when "search_timeout"
         
     | 
| 
      
 198 
     | 
    
         
            +
                      res = {}
         
     | 
| 
      
 199 
     | 
    
         
            +
                      conn.set_option(LDAP::LDAP_OPT_TIMELIMIT, 2)
         
     | 
| 
      
 200 
     | 
    
         
            +
                      conn.search("dc=localhost, dc=localdomain",
         
     | 
| 
      
 201 
     | 
    
         
            +
                                  LDAP::LDAP_SCOPE_SUBTREE,
         
     | 
| 
      
 202 
     | 
    
         
            +
                                  "(objectclass=*)") do |e|
         
     | 
| 
      
 203 
     | 
    
         
            +
                        entry = e.to_hash
         
     | 
| 
      
 204 
     | 
    
         
            +
                        dn = entry.delete("dn").first
         
     | 
| 
      
 205 
     | 
    
         
            +
                        res[dn] = entry
         
     | 
| 
      
 206 
     | 
    
         
            +
                      end
         
     | 
| 
      
 207 
     | 
    
         
            +
                    when "quit"
         
     | 
| 
      
 208 
     | 
    
         
            +
                      puts "OK"
         
     | 
| 
      
 209 
     | 
    
         
            +
                      break
         
     | 
| 
      
 210 
     | 
    
         
            +
                    else
         
     | 
| 
      
 211 
     | 
    
         
            +
                      raise "Bad command! #{a.inspect}"
         
     | 
| 
      
 212 
     | 
    
         
            +
                    end
         
     | 
| 
      
 213 
     | 
    
         
            +
                    puts "OK"
         
     | 
| 
      
 214 
     | 
    
         
            +
                  rescue Exception => e
         
     | 
| 
      
 215 
     | 
    
         
            +
                    $stderr.puts "Child exception: #{e}\n\t#{e.backtrace.join("\n\t")}"
         
     | 
| 
      
 216 
     | 
    
         
            +
                    puts "ERR #{e}"
         
     | 
| 
      
 217 
     | 
    
         
            +
                  end
         
     | 
| 
      
 218 
     | 
    
         
            +
                end
         
     | 
| 
      
 219 
     | 
    
         
            +
              end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
              def req(cmd)
         
     | 
| 
      
 222 
     | 
    
         
            +
                @io.puts cmd
         
     | 
| 
      
 223 
     | 
    
         
            +
                res = @io.gets.chomp
         
     | 
| 
      
 224 
     | 
    
         
            +
                assert_match(/^OK/, res)
         
     | 
| 
      
 225 
     | 
    
         
            +
                res
         
     | 
| 
      
 226 
     | 
    
         
            +
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              def test_bind2
         
     | 
| 
      
 229 
     | 
    
         
            +
                req("bind2")
         
     | 
| 
      
 230 
     | 
    
         
            +
                assert_equal([:simple_bind, 2, "foo", "bar"], MockOperation.lastop)
         
     | 
| 
      
 231 
     | 
    
         
            +
                # cannot bind any more; ldap client library says "already binded." (sic)
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
              def test_bind3
         
     | 
| 
      
 235 
     | 
    
         
            +
                req("bind3")
         
     | 
| 
      
 236 
     | 
    
         
            +
                assert_equal([:simple_bind, 3, "foo", "bar"], MockOperation.lastop)
         
     | 
| 
      
 237 
     | 
    
         
            +
                # cannot bind any more; ldap client library says "already binded." (sic)
         
     | 
| 
      
 238 
     | 
    
         
            +
              end
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
              def test_add
         
     | 
| 
      
 241 
     | 
    
         
            +
                req("add1")
         
     | 
| 
      
 242 
     | 
    
         
            +
                assert_equal([:add, "dc=localhost, dc=domain", {
         
     | 
| 
      
 243 
     | 
    
         
            +
                  'objectclass'=>['top', 'domain'],
         
     | 
| 
      
 244 
     | 
    
         
            +
                  'o'=>['TTSKY.NET'],
         
     | 
| 
      
 245 
     | 
    
         
            +
                  'dc'=>['localhost'],
         
     | 
| 
      
 246 
     | 
    
         
            +
                }], MockOperation.lastop)
         
     | 
| 
      
 247 
     | 
    
         
            +
                req("add2")
         
     | 
| 
      
 248 
     | 
    
         
            +
                assert_equal([:add, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain", {
         
     | 
| 
      
 249 
     | 
    
         
            +
                  'objectclass'=>['top', 'person'],
         
     | 
| 
      
 250 
     | 
    
         
            +
                  'cn'=>['Takaaki Tateishi'],
         
     | 
| 
      
 251 
     | 
    
         
            +
                  'sn'=>['ttate','Tateishi',"zero\000zero"],
         
     | 
| 
      
 252 
     | 
    
         
            +
                }], MockOperation.lastop)
         
     | 
| 
      
 253 
     | 
    
         
            +
              end
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
              def test_del
         
     | 
| 
      
 256 
     | 
    
         
            +
                req("del")
         
     | 
| 
      
 257 
     | 
    
         
            +
                assert_equal([:del, "cn=Takaaki-Tateishi, dc=localhost, dc=localdomain"], MockOperation.lastop)
         
     | 
| 
      
 258 
     | 
    
         
            +
              end
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
              def test_compare
         
     | 
| 
      
 261 
     | 
    
         
            +
                r = req("compare Takaaki Tateishi")
         
     | 
| 
      
 262 
     | 
    
         
            +
                assert_match(/OK true/, r)
         
     | 
| 
      
 263 
     | 
    
         
            +
                assert_equal([:compare, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
         
     | 
| 
      
 264 
     | 
    
         
            +
                  "cn", "Takaaki Tateishi"], MockOperation.lastop)
         
     | 
| 
      
 265 
     | 
    
         
            +
                r = req("compare false")
         
     | 
| 
      
 266 
     | 
    
         
            +
                assert_match(/OK false/, r)
         
     | 
| 
      
 267 
     | 
    
         
            +
                assert_equal([:compare, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
         
     | 
| 
      
 268 
     | 
    
         
            +
                  "cn", "false"], MockOperation.lastop)
         
     | 
| 
      
 269 
     | 
    
         
            +
              end
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
              def test_modrdn
         
     | 
| 
      
 272 
     | 
    
         
            +
                req("modrdn")
         
     | 
| 
      
 273 
     | 
    
         
            +
                assert_equal([:modifydn, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
         
     | 
| 
      
 274 
     | 
    
         
            +
                  "cn=Takaaki-Tateishi", true, nil], MockOperation.lastop)
         
     | 
| 
      
 275 
     | 
    
         
            +
                # FIXME: ruby-ldap doesn't support the four-argument form
         
     | 
| 
      
 276 
     | 
    
         
            +
              end
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
              def test_modify
         
     | 
| 
      
 279 
     | 
    
         
            +
                req("modify")
         
     | 
| 
      
 280 
     | 
    
         
            +
                assert_equal([:modify, "dc=localhost, dc=domain", {
         
     | 
| 
      
 281 
     | 
    
         
            +
                    'objectclass' => [:add, 'top', 'domain'],
         
     | 
| 
      
 282 
     | 
    
         
            +
                    'o' => [:delete],
         
     | 
| 
      
 283 
     | 
    
         
            +
                    'dc' => [:replace, 'localhost'],
         
     | 
| 
      
 284 
     | 
    
         
            +
                }], MockOperation.lastop)
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
              def test_search
         
     | 
| 
      
 288 
     | 
    
         
            +
                req("search")
         
     | 
| 
      
 289 
     | 
    
         
            +
                assert_equal([:search, "dc=localhost, dc=localdomain",
         
     | 
| 
      
 290 
     | 
    
         
            +
                  LDAP::Server::WholeSubtree,
         
     | 
| 
      
 291 
     | 
    
         
            +
                  LDAP::Server::NeverDerefAliases,
         
     | 
| 
      
 292 
     | 
    
         
            +
                  [:true], []], MockOperation.lastop)
         
     | 
| 
      
 293 
     | 
    
         
            +
                req("search2")
         
     | 
| 
      
 294 
     | 
    
         
            +
                assert_equal([:search, "dc=localhost, dc=localdomain",
         
     | 
| 
      
 295 
     | 
    
         
            +
                  LDAP::Server::BaseObject,
         
     | 
| 
      
 296 
     | 
    
         
            +
                  LDAP::Server::NeverDerefAliases,
         
     | 
| 
      
 297 
     | 
    
         
            +
                  [:and, [:eq, "cn", nil, "foo"],
         
     | 
| 
      
 298 
     | 
    
         
            +
                         [:or,  [:not, [:present, "sn"]],
         
     | 
| 
      
 299 
     | 
    
         
            +
                                [:ge, "ou", nil, "baz"],
         
     | 
| 
      
 300 
     | 
    
         
            +
                                [:le, "o", nil, "z"],
         
     | 
| 
      
 301 
     | 
    
         
            +
                                [:approx, "cn", nil, "brian"],
         
     | 
| 
      
 302 
     | 
    
         
            +
                                [:substrings, "cn", nil, nil, "and", "er"],
         
     | 
| 
      
 303 
     | 
    
         
            +
                         ],
         
     | 
| 
      
 304 
     | 
    
         
            +
                  ], ["a","b"]], MockOperation.lastop)
         
     | 
| 
      
 305 
     | 
    
         
            +
              end
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
              def test_retrieve_attributes_case_insensitive
         
     | 
| 
      
 308 
     | 
    
         
            +
                req("search_retrieve_attrs")
         
     | 
| 
      
 309 
     | 
    
         
            +
                assert_equal([:search, "dc=localhost, dc=localdomain",
         
     | 
| 
      
 310 
     | 
    
         
            +
                  LDAP::Server::WholeSubtree,
         
     | 
| 
      
 311 
     | 
    
         
            +
                  LDAP::Server::NeverDerefAliases,
         
     | 
| 
      
 312 
     | 
    
         
            +
                  [:true], ["B"]], MockOperation.lastop)
         
     | 
| 
      
 313 
     | 
    
         
            +
              end
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
              def test_search_client_timeout
         
     | 
| 
      
 316 
     | 
    
         
            +
                # Should not raise errors
         
     | 
| 
      
 317 
     | 
    
         
            +
                req("search_timeout")
         
     | 
| 
      
 318 
     | 
    
         
            +
                assert_equal([:search, "dc=localhost, dc=localdomain",
         
     | 
| 
      
 319 
     | 
    
         
            +
                  LDAP::Server::WholeSubtree,
         
     | 
| 
      
 320 
     | 
    
         
            +
                  LDAP::Server::NeverDerefAliases,
         
     | 
| 
      
 321 
     | 
    
         
            +
                  [:true], []], MockOperation.lastop)
         
     | 
| 
      
 322 
     | 
    
         
            +
              end
         
     | 
| 
      
 323 
     | 
    
         
            +
            end
         
     | 
    
        data/test/filter_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,107 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ldap/server/filter'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class FilterTest < Test::Unit::TestCase
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              AV1 = {
         
     | 
| 
      
 7 
     | 
    
         
            +
                "foo" => ["abc","def"],
         
     | 
| 
      
 8 
     | 
    
         
            +
                "bar" => ["wibblespong"],
         
     | 
| 
      
 9 
     | 
    
         
            +
              }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              def test_bad
         
     | 
| 
      
 12 
     | 
    
         
            +
                assert_raises(LDAP::ResultError::OperationsError) {
         
     | 
| 
      
 13 
     | 
    
         
            +
                  LDAP::Server::Filter.run([:wibbly], AV1)
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def test_const
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:true], AV1))
         
     | 
| 
      
 19 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:false], AV1))
         
     | 
| 
      
 20 
     | 
    
         
            +
                assert_equal(nil, LDAP::Server::Filter.run([:undef], AV1))
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def test_present
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:present,"foo"], AV1))
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:present,"zog"], AV1))
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def test_eq
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:eq,"foo",nil,"abc"], AV1))
         
     | 
| 
      
 30 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:eq,"foo",nil,"def"], AV1))
         
     | 
| 
      
 31 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:eq,"foo",nil,"ghi"], AV1))
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:eq,"xyz",nil,"abc"], AV1))
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def test_eq_case
         
     | 
| 
      
 36 
     | 
    
         
            +
                c = LDAP::Server::MatchingRule.find('2.5.13.2')
         
     | 
| 
      
 37 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:eq,"foo",c,"ABC"], AV1))
         
     | 
| 
      
 38 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:eq,"foo",c,"DeF"], AV1))
         
     | 
| 
      
 39 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:eq,"foo",c,"ghi"], AV1))
         
     | 
| 
      
 40 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:eq,"xyz",c,"abc"], AV1))
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def test_not
         
     | 
| 
      
 44 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:not,[:eq,"foo",nil,"abc"]], AV1))
         
     | 
| 
      
 45 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:not,[:eq,"foo",nil,"def"]], AV1))
         
     | 
| 
      
 46 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:not,[:eq,"foo",nil,"ghi"]], AV1))
         
     | 
| 
      
 47 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:not,[:eq,"xyz",nil,"abc"]], AV1))
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              def test_ge
         
     | 
| 
      
 51 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:ge,"foo",nil,"ccc"], AV1))
         
     | 
| 
      
 52 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:ge,"foo",nil,"def"], AV1))
         
     | 
| 
      
 53 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:ge,"foo",nil,"deg"], AV1))
         
     | 
| 
      
 54 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:ge,"xyz",nil,"abc"], AV1))
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def test_le
         
     | 
| 
      
 58 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:le,"foo",nil,"ccc"], AV1))
         
     | 
| 
      
 59 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:le,"foo",nil,"abc"], AV1))
         
     | 
| 
      
 60 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:le,"foo",nil,"abb"], AV1))
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:le,"xyz",nil,"abc"], AV1))
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              def test_substrings
         
     | 
| 
      
 65 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,"a",nil], AV1))
         
     | 
| 
      
 66 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,"def",nil], AV1))
         
     | 
| 
      
 67 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,"bc",nil], AV1))
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,"az",nil], AV1))
         
     | 
| 
      
 69 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,"",nil], AV1))
         
     | 
| 
      
 70 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"zzz",nil,"",nil], AV1))
         
     | 
| 
      
 71 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"a",nil], AV1))
         
     | 
| 
      
 72 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"e",nil], AV1))
         
     | 
| 
      
 73 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"ba",nil], AV1))
         
     | 
| 
      
 74 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"az",nil], AV1))
         
     | 
| 
      
 75 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"c"], AV1))
         
     | 
| 
      
 76 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"ef"], AV1))
         
     | 
| 
      
 77 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"ab"], AV1))
         
     | 
| 
      
 78 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"foo",nil,nil,"e"], AV1))
         
     | 
| 
      
 79 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"bar",nil,"wib","ong"], AV1))
         
     | 
| 
      
 80 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"bar",nil,"",""], AV1))
         
     | 
| 
      
 81 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"bar",nil,"wib","ble"], AV1))
         
     | 
| 
      
 82 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"bar",nil,"sp","ong"], AV1))
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def test_substr_case
         
     | 
| 
      
 86 
     | 
    
         
            +
                c = LDAP::Server::MatchingRule.find('1.3.6.1.4.1.1466.109.114.3')
         
     | 
| 
      
 87 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"bar",c,"WIB",nil], AV1))
         
     | 
| 
      
 88 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:substrings,"bar",c,"WIB","lES","ong"], AV1))
         
     | 
| 
      
 89 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"bar",c,"SPONG",nil], AV1))
         
     | 
| 
      
 90 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:substrings,"xyz",c,"wib",nil], AV1))
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              def test_and
         
     | 
| 
      
 94 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:and,[:true],[:true]], AV1))
         
     | 
| 
      
 95 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:and,[:false],[:true]], AV1))
         
     | 
| 
      
 96 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:and,[:true],[:false]], AV1))
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:and,[:false],[:false]], AV1))
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              def test_or
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:or,[:true],[:true]], AV1))
         
     | 
| 
      
 102 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:or,[:false],[:true]], AV1))
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert_equal(true, LDAP::Server::Filter.run([:or,[:true],[:false]], AV1))
         
     | 
| 
      
 104 
     | 
    
         
            +
                assert_equal(false, LDAP::Server::Filter.run([:or,[:false],[:false]], AV1))
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            end
         
     | 
    
        data/test/match_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ldap/server/match'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class MatchTest < Test::Unit::TestCase
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def test_caseIgnoreOrderingMatch
         
     | 
| 
      
 7 
     | 
    
         
            +
                s = LDAP::Server::MatchingRule.find("2.5.13.3")
         
     | 
| 
      
 8 
     | 
    
         
            +
                assert_equal(LDAP::Server::MatchingRule, s.class)
         
     | 
| 
      
 9 
     | 
    
         
            +
                assert_equal("caseIgnoreOrderingMatch", s.name)
         
     | 
| 
      
 10 
     | 
    
         
            +
                assert_equal("( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", s.to_def)
         
     | 
| 
      
 11 
     | 
    
         
            +
                assert_equal(true, s.le(["foobar","wibble"], "ghi"))
         
     | 
| 
      
 12 
     | 
    
         
            +
                assert_equal(true, s.le(["FOOBAR","WIBBLE"], "ghi"))
         
     | 
| 
      
 13 
     | 
    
         
            +
                assert_equal(true, s.le(["foobar","wibble"], "GHI"))
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_equal(true, s.le(["FOOBAR","WIBBLE"], "GHI"))
         
     | 
| 
      
 15 
     | 
    
         
            +
                assert_equal(false, s.le(["foobar","wibble"], "fab"))
         
     | 
| 
      
 16 
     | 
    
         
            +
                assert_equal(false, s.le(["FOOBAR","WIBBLE"], "fab"))
         
     | 
| 
      
 17 
     | 
    
         
            +
                assert_equal(false, s.le(["foobar","wibble"], "FAB"))
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal(false, s.le(["FOOBAR","WIBBLE"], "FAB"))
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def test_caseIgnoreSubstringsMatch
         
     | 
| 
      
 22 
     | 
    
         
            +
                s = LDAP::Server::MatchingRule.find("2.5.13.4")
         
     | 
| 
      
 23 
     | 
    
         
            +
                assert_equal(LDAP::Server::MatchingRule, s.class)
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert_equal("caseIgnoreSubstringsMatch", s.name)
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], nil, "oob", nil))
         
     | 
| 
      
 26 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], nil, "foo", nil))
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], nil, "bar", nil))
         
     | 
| 
      
 28 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], "wib", nil))
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], nil, "ar"))
         
     | 
| 
      
 30 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], "wib", "ble"))
         
     | 
| 
      
 31 
     | 
    
         
            +
                assert_equal(true, s.substrings(["foobar","wibble"], nil, "oo", "bar"))
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], nil, "ooz", nil))
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], nil, "foz", nil))
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], nil, "zar", nil))
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], "bar", nil))
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], nil, "oob"))
         
     | 
| 
      
 37 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], "foo", "ble"))
         
     | 
| 
      
 38 
     | 
    
         
            +
                assert_equal(false, s.substrings(["foobar","wibble"], "foo", "obar"))
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              def test_unknown
         
     | 
| 
      
 42 
     | 
    
         
            +
                s = LDAP::Server::MatchingRule.find("1.4.7.1")
         
     | 
| 
      
 43 
     | 
    
         
            +
                assert_equal(nil, s)  ## this may change to generate a default object
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def test_nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                s = LDAP::Server::MatchingRule.find(nil)
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert_equal(nil, s)
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def test_from_def
         
     | 
| 
      
 52 
     | 
    
         
            +
                s = LDAP::Server::MatchingRule.from_def("( 1.2.3 NAME ( 'wibble' 'bibble' ) DESC 'foobar' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )")
         
     | 
| 
      
 53 
     | 
    
         
            +
                assert_equal("1.2.3", s.oid)
         
     | 
| 
      
 54 
     | 
    
         
            +
                assert_equal(['wibble','bibble'], s.names)
         
     | 
| 
      
 55 
     | 
    
         
            +
                assert_equal('wibble', s.to_s)
         
     | 
| 
      
 56 
     | 
    
         
            +
                assert_equal("foobar", s.desc)
         
     | 
| 
      
 57 
     | 
    
         
            +
                assert_equal("IA5 String", s.syntax.desc)
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     |