fakeldap 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +7 -1
- data/lib/fakeldap.rb +133 -10
- data/lib/fakeldap/version.rb +1 -1
- metadata +50 -191
- data/vendor/ruby-ldapserver/COPYING +0 -27
- data/vendor/ruby-ldapserver/ChangeLog +0 -83
- data/vendor/ruby-ldapserver/Manifest.txt +0 -32
- data/vendor/ruby-ldapserver/README +0 -222
- data/vendor/ruby-ldapserver/Rakefile +0 -22
- data/vendor/ruby-ldapserver/doc/LDAP.html +0 -104
- data/vendor/ruby-ldapserver/doc/LDAP/Abandon.html +0 -112
- data/vendor/ruby-ldapserver/doc/LDAP/Error.html +0 -115
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError.html +0 -241
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AdminLimitExceeded.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AffectsMultipleDSAs.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AliasDereferencingProblem.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AliasProblem.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AttributeOrValueExists.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/AuthMethodNotSupported.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/Busy.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/CompareFalse.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/CompareTrue.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/ConfidentialityRequired.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/ConstraintViolation.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/EntryAlreadyExists.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InappropriateAuthentication.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InappropriateMatching.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InsufficientAccessRights.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InvalidAttributeSyntax.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InvalidCredentials.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/InvalidDNSyntax.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/IsLeaf.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/LoopDetect.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/NamingViolation.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/NoSuchAttribute.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/NoSuchObject.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/NotAllowedOnNonLeaf.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/NotAllowedOnRDN.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/ObjectClassModsProhibited.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/ObjectClassViolation.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/OperationsError.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/Other.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/ProtocolError.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/Referral.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/SaslBindInProgress.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/SizeLimitExceeded.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/StrongAuthRequired.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/Success.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/TimeLimitExceeded.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/Unavailable.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/UnavailableCriticalExtension.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/UndefinedAttributeType.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/ResultError/UnwillingToPerform.html +0 -158
- data/vendor/ruby-ldapserver/doc/LDAP/Server.html +0 -1056
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Connection.html +0 -1353
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Filter.html +0 -634
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule.html +0 -1132
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/DefaultMatchingClass.html +0 -219
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/Equality.html +0 -170
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/IA5Downcase.html +0 -143
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/IA5Trim.html +0 -155
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/Integer.html +0 -143
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/Ordering.html +0 -212
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/StringDowncase.html +0 -143
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/StringTrim.html +0 -154
- data/vendor/ruby-ldapserver/doc/LDAP/Server/MatchingRule/Substrings.html +0 -177
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Operation.html +0 -2994
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Schema.html +0 -2024
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Schema/AttributeType.html +0 -1462
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Schema/ObjectClass.html +0 -1097
- data/vendor/ruby-ldapserver/doc/LDAP/Server/Syntax.html +0 -1254
- data/vendor/ruby-ldapserver/doc/LDAP/Server/VERSION.html +0 -134
- data/vendor/ruby-ldapserver/doc/_index.html +0 -662
- data/vendor/ruby-ldapserver/doc/class_list.html +0 -36
- data/vendor/ruby-ldapserver/doc/css/common.css +0 -1
- data/vendor/ruby-ldapserver/doc/css/full_list.css +0 -50
- data/vendor/ruby-ldapserver/doc/css/style.css +0 -303
- data/vendor/ruby-ldapserver/doc/file.README.html +0 -399
- data/vendor/ruby-ldapserver/doc/file_list.html +0 -38
- data/vendor/ruby-ldapserver/doc/frames.html +0 -13
- data/vendor/ruby-ldapserver/doc/index.html +0 -399
- data/vendor/ruby-ldapserver/doc/js/app.js +0 -204
- data/vendor/ruby-ldapserver/doc/js/full_list.js +0 -112
- data/vendor/ruby-ldapserver/doc/js/jquery.js +0 -154
- data/vendor/ruby-ldapserver/doc/method_list.html +0 -1571
- data/vendor/ruby-ldapserver/doc/top-level-namespace.html +0 -88
- data/vendor/ruby-ldapserver/examples/README +0 -89
- data/vendor/ruby-ldapserver/examples/mkcert.rb +0 -31
- data/vendor/ruby-ldapserver/examples/rbslapd1.rb +0 -111
- data/vendor/ruby-ldapserver/examples/rbslapd2.rb +0 -161
- data/vendor/ruby-ldapserver/examples/rbslapd3.rb +0 -172
- data/vendor/ruby-ldapserver/examples/speedtest.rb +0 -37
- data/vendor/ruby-ldapserver/lib/ldap/server.rb +0 -4
- data/vendor/ruby-ldapserver/lib/ldap/server/connection.rb +0 -276
- data/vendor/ruby-ldapserver/lib/ldap/server/filter.rb +0 -223
- data/vendor/ruby-ldapserver/lib/ldap/server/match.rb +0 -283
- data/vendor/ruby-ldapserver/lib/ldap/server/operation.rb +0 -487
- data/vendor/ruby-ldapserver/lib/ldap/server/preforkserver.rb +0 -93
- data/vendor/ruby-ldapserver/lib/ldap/server/result.rb +0 -71
- data/vendor/ruby-ldapserver/lib/ldap/server/schema.rb +0 -592
- data/vendor/ruby-ldapserver/lib/ldap/server/server.rb +0 -89
- data/vendor/ruby-ldapserver/lib/ldap/server/syntax.rb +0 -235
- data/vendor/ruby-ldapserver/lib/ldap/server/tcpserver.rb +0 -91
- data/vendor/ruby-ldapserver/lib/ldap/server/util.rb +0 -88
- data/vendor/ruby-ldapserver/lib/ldap/server/version.rb +0 -11
- data/vendor/ruby-ldapserver/test/core.schema +0 -582
- data/vendor/ruby-ldapserver/test/encoding_test.rb +0 -279
- data/vendor/ruby-ldapserver/test/filter_test.rb +0 -107
- data/vendor/ruby-ldapserver/test/match_test.rb +0 -59
- data/vendor/ruby-ldapserver/test/schema_test.rb +0 -113
- data/vendor/ruby-ldapserver/test/syntax_test.rb +0 -40
- data/vendor/ruby-ldapserver/test/test_helper.rb +0 -2
- data/vendor/ruby-ldapserver/test/util_test.rb +0 -51
@@ -1,279 +0,0 @@
|
|
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 "quit"
|
181
|
-
puts "OK"
|
182
|
-
break
|
183
|
-
else
|
184
|
-
raise "Bad command! #{a.inspect}"
|
185
|
-
end
|
186
|
-
puts "OK"
|
187
|
-
rescue Exception => e
|
188
|
-
$stderr.puts "Child exception: #{e}\n\t#{e.backtrace.join("\n\t")}"
|
189
|
-
puts "ERR #{e}"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def req(cmd)
|
195
|
-
@io.puts cmd
|
196
|
-
res = @io.gets.chomp
|
197
|
-
assert_match(/^OK/, res)
|
198
|
-
res
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_bind2
|
202
|
-
req("bind2")
|
203
|
-
assert_equal([:simple_bind, 2, "foo", "bar"], MockOperation.lastop)
|
204
|
-
# cannot bind any more; ldap client library says "already binded." (sic)
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_bind3
|
208
|
-
req("bind3")
|
209
|
-
assert_equal([:simple_bind, 3, "foo", "bar"], MockOperation.lastop)
|
210
|
-
# cannot bind any more; ldap client library says "already binded." (sic)
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_add
|
214
|
-
req("add1")
|
215
|
-
assert_equal([:add, "dc=localhost, dc=domain", {
|
216
|
-
'objectclass'=>['top', 'domain'],
|
217
|
-
'o'=>['TTSKY.NET'],
|
218
|
-
'dc'=>['localhost'],
|
219
|
-
}], MockOperation.lastop)
|
220
|
-
req("add2")
|
221
|
-
assert_equal([:add, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain", {
|
222
|
-
'objectclass'=>['top', 'person'],
|
223
|
-
'cn'=>['Takaaki Tateishi'],
|
224
|
-
'sn'=>['ttate','Tateishi',"zero\000zero"],
|
225
|
-
}], MockOperation.lastop)
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_del
|
229
|
-
req("del")
|
230
|
-
assert_equal([:del, "cn=Takaaki-Tateishi, dc=localhost, dc=localdomain"], MockOperation.lastop)
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_compare
|
234
|
-
r = req("compare Takaaki Tateishi")
|
235
|
-
assert_match(/OK true/, r)
|
236
|
-
assert_equal([:compare, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
|
237
|
-
"cn", "Takaaki Tateishi"], MockOperation.lastop)
|
238
|
-
r = req("compare false")
|
239
|
-
assert_match(/OK false/, r)
|
240
|
-
assert_equal([:compare, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
|
241
|
-
"cn", "false"], MockOperation.lastop)
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_modrdn
|
245
|
-
req("modrdn")
|
246
|
-
assert_equal([:modifydn, "cn=Takaaki Tateishi, dc=localhost, dc=localdomain",
|
247
|
-
"cn=Takaaki-Tateishi", true, nil], MockOperation.lastop)
|
248
|
-
# FIXME: ruby-ldap doesn't support the four-argument form
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_modify
|
252
|
-
req("modify")
|
253
|
-
assert_equal([:modify, "dc=localhost, dc=domain", {
|
254
|
-
'objectclass' => [:add, 'top', 'domain'],
|
255
|
-
'o' => [:delete],
|
256
|
-
'dc' => [:replace, 'localhost'],
|
257
|
-
}], MockOperation.lastop)
|
258
|
-
end
|
259
|
-
|
260
|
-
def test_search
|
261
|
-
req("search")
|
262
|
-
assert_equal([:search, "dc=localhost, dc=localdomain",
|
263
|
-
LDAP::Server::WholeSubtree,
|
264
|
-
LDAP::Server::NeverDerefAliases,
|
265
|
-
[:true], []], MockOperation.lastop)
|
266
|
-
req("search2")
|
267
|
-
assert_equal([:search, "dc=localhost, dc=localdomain",
|
268
|
-
LDAP::Server::BaseObject,
|
269
|
-
LDAP::Server::NeverDerefAliases,
|
270
|
-
[:and, [:eq, "cn", nil, "foo"],
|
271
|
-
[:or, [:not, [:present, "sn"]],
|
272
|
-
[:ge, "ou", nil, "baz"],
|
273
|
-
[:le, "o", nil, "z"],
|
274
|
-
[:approx, "cn", nil, "brian"],
|
275
|
-
[:substrings, "cn", nil, nil, "and", "er"],
|
276
|
-
],
|
277
|
-
], ["a","b"]], MockOperation.lastop)
|
278
|
-
end
|
279
|
-
end
|
@@ -1,107 +0,0 @@
|
|
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
|
@@ -1,59 +0,0 @@
|
|
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
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
require 'ldap/server/schema'
|
3
|
-
require 'ldap/server/match'
|
4
|
-
|
5
|
-
class SchemaTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_parse_attr
|
8
|
-
attr = <<ATTR
|
9
|
-
( 2.5.4.3 NAME 'cn' OBSOLETE EQUALITY 1.2.3 ORDERING 4.5.678 SUBSTR 9.1.1 SYNTAX 4.3.2{58} SINGLE-VALUE COLLECTIVE NO-USER-MODIFICATION USAGE userApplications )
|
10
|
-
ATTR
|
11
|
-
a = LDAP::Server::Schema::AttributeType.new(attr)
|
12
|
-
assert_equal("2.5.4.3", a.oid)
|
13
|
-
assert_equal("cn", a.name)
|
14
|
-
assert_equal(["cn"], a.names)
|
15
|
-
assert(a.obsolete)
|
16
|
-
assert_equal("1.2.3", a.equality)
|
17
|
-
assert_equal("4.5.678", a.ordering)
|
18
|
-
assert_equal("9.1.1", a.substr)
|
19
|
-
assert_equal("4.3.2", a.syntax)
|
20
|
-
assert_equal(58, a.maxlen)
|
21
|
-
assert(a.singlevalue)
|
22
|
-
assert(a.collective)
|
23
|
-
assert(a.nousermod)
|
24
|
-
assert_equal(:userApplications, a.usage)
|
25
|
-
assert_equal(attr.chomp, a.to_def)
|
26
|
-
|
27
|
-
attr = <<ATTR
|
28
|
-
( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by' SUP name )
|
29
|
-
ATTR
|
30
|
-
a = LDAP::Server::Schema::AttributeType.new(attr)
|
31
|
-
assert_equal("2.5.4.3", a.oid)
|
32
|
-
assert_equal("cn", a.name)
|
33
|
-
assert_equal(["cn", "commonName"], a.names)
|
34
|
-
assert_equal("RFC2256: common name(s) for which the entity is known by", a.desc)
|
35
|
-
assert(! a.obsolete)
|
36
|
-
assert_equal("name", a.sup)
|
37
|
-
assert(! a.singlevalue)
|
38
|
-
assert(! a.collective)
|
39
|
-
assert(! a.nousermod)
|
40
|
-
assert_equal(attr.chomp, a.to_def)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_parse_objectclass
|
44
|
-
oc = <<OC
|
45
|
-
( 0.9.2342.19200300.100.4.19 NAME 'simpleSecurityObject' DESC 'RFC1274: simple security object' SUP top AUXILIARY MUST userPassword )
|
46
|
-
OC
|
47
|
-
a = LDAP::Server::Schema::ObjectClass.new(oc)
|
48
|
-
assert_equal("0.9.2342.19200300.100.4.19", a.oid)
|
49
|
-
assert_equal("simpleSecurityObject", a.name)
|
50
|
-
assert_equal(["simpleSecurityObject"], a.names)
|
51
|
-
assert(! a.obsolete)
|
52
|
-
assert_equal("RFC1274: simple security object", a.desc)
|
53
|
-
assert_equal(["top"], a.sup)
|
54
|
-
assert_equal(:auxiliary, a.struct)
|
55
|
-
assert_equal(["userPassword"], a.must)
|
56
|
-
assert_equal([], a.may)
|
57
|
-
assert_equal(oc.chomp, a.to_def)
|
58
|
-
|
59
|
-
oc = <<OC
|
60
|
-
( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )
|
61
|
-
OC
|
62
|
-
a = LDAP::Server::Schema::ObjectClass.new(oc)
|
63
|
-
assert_equal("2.5.6.6", a.oid)
|
64
|
-
assert_equal("person", a.name)
|
65
|
-
assert_equal(["person"], a.names)
|
66
|
-
assert(! a.obsolete)
|
67
|
-
assert_equal("RFC2256: a person", a.desc)
|
68
|
-
assert_equal(["top"], a.sup)
|
69
|
-
assert_equal(:structural, a.struct)
|
70
|
-
assert_equal(["sn", "cn"], a.must)
|
71
|
-
assert_equal(["userPassword","telephoneNumber","seeAlso","description"], a.may)
|
72
|
-
assert_equal(oc.chomp, a.to_def)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_loadschema
|
76
|
-
s = LDAP::Server::Schema.new
|
77
|
-
s.load_system
|
78
|
-
s.load_file(File.dirname(__FILE__) + "/core.schema")
|
79
|
-
s.resolve_oids
|
80
|
-
a = s.find_attrtype("objectclass")
|
81
|
-
assert_equal("objectClass", a.name)
|
82
|
-
a = s.find_attrtype("COMMONNAME")
|
83
|
-
assert_equal(LDAP::Server::Schema::AttributeType, a.class)
|
84
|
-
assert_equal("caseIgnoreMatch", a.equality.to_s)
|
85
|
-
assert_equal(LDAP::Server::MatchingRule, a.equality.class)
|
86
|
-
assert_equal("caseIgnoreSubstringsMatch", a.substr.to_s)
|
87
|
-
assert_equal(LDAP::Server::MatchingRule, a.substr.class)
|
88
|
-
assert_equal("1.3.6.1.4.1.1466.115.121.1.15", a.syntax.to_s)
|
89
|
-
assert_equal(LDAP::Server::Syntax, a.syntax.class)
|
90
|
-
assert_equal("cn", a.name)
|
91
|
-
a = s.find_attrtype("COUNTRYname")
|
92
|
-
assert_equal("c", a.name)
|
93
|
-
# I modified core.schema so that countryName has the appropriate syntax
|
94
|
-
assert(a.syntax.match("GB"))
|
95
|
-
assert(!a.syntax.match("ABC"))
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_backwards_api
|
99
|
-
s = LDAP::Server::Schema.new
|
100
|
-
s.load_system
|
101
|
-
assert_equal(['subschema','OpenLDAProotDSE','referral','alias','extensibleObject','top'].sort,
|
102
|
-
s.names('objectClasses').sort)
|
103
|
-
assert_equal(['dITStructureRules','nameForms','ditContentRules','objectClasses','attributeTypes','matchingRules','matchingRuleUse'],
|
104
|
-
s.attr('subschema', 'may'))
|
105
|
-
assert_equal([], s.attr('subschema', 'must'))
|
106
|
-
assert_equal(nil, s.attr('foo', 'must'))
|
107
|
-
assert_equal(['top'], s.sup('extensibleObject'))
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_validate
|
111
|
-
# FIXME
|
112
|
-
end
|
113
|
-
end
|