net-ldap 0.11 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of net-ldap might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +471 -180
- data/.travis.yml +10 -5
- data/Contributors.rdoc +1 -0
- data/History.rdoc +60 -0
- data/README.rdoc +18 -11
- data/Rakefile +0 -1
- data/lib/net/ber/ber_parser.rb +4 -4
- data/lib/net/ber/core_ext/array.rb +1 -1
- data/lib/net/ber/core_ext/integer.rb +1 -1
- data/lib/net/ber/core_ext/string.rb +1 -1
- data/lib/net/ber.rb +37 -5
- data/lib/net/ldap/auth_adapter/gss_spnego.rb +41 -0
- data/lib/net/ldap/auth_adapter/sasl.rb +62 -0
- data/lib/net/ldap/auth_adapter/simple.rb +34 -0
- data/lib/net/ldap/auth_adapter.rb +29 -0
- data/lib/net/ldap/connection.rb +197 -187
- data/lib/net/ldap/dataset.rb +2 -2
- data/lib/net/ldap/dn.rb +4 -5
- data/lib/net/ldap/entry.rb +4 -5
- data/lib/net/ldap/error.rb +36 -1
- data/lib/net/ldap/filter.rb +6 -6
- data/lib/net/ldap/pdu.rb +26 -2
- data/lib/net/ldap/version.rb +1 -1
- data/lib/net/ldap.rb +189 -75
- data/lib/net/snmp.rb +18 -18
- data/net-ldap.gemspec +4 -2
- data/script/changelog +47 -0
- data/script/generate-fixture-ca +48 -0
- data/script/install-openldap +67 -44
- data/test/ber/core_ext/test_array.rb +1 -1
- data/test/ber/test_ber.rb +11 -3
- data/test/fixtures/ca/ca.info +4 -0
- data/test/fixtures/ca/cacert.pem +24 -0
- data/test/fixtures/ca/cakey.pem +190 -0
- data/test/fixtures/openldap/slapd.conf.ldif +1 -1
- data/test/integration/test_add.rb +1 -1
- data/test/integration/test_ber.rb +1 -1
- data/test/integration/test_bind.rb +220 -10
- data/test/integration/test_delete.rb +1 -1
- data/test/integration/test_open.rb +1 -1
- data/test/integration/test_password_modify.rb +80 -0
- data/test/integration/test_search.rb +1 -1
- data/test/support/vm/openldap/README.md +35 -3
- data/test/support/vm/openldap/Vagrantfile +1 -0
- data/test/test_auth_adapter.rb +15 -0
- data/test/test_dn.rb +3 -3
- data/test/test_filter.rb +4 -4
- data/test/test_filter_parser.rb +4 -0
- data/test/test_helper.rb +10 -2
- data/test/test_ldap.rb +64 -10
- data/test/test_ldap_connection.rb +115 -28
- data/test/test_ldif.rb +11 -11
- data/test/test_search.rb +2 -2
- data/test/test_snmp.rb +4 -4
- data/testserver/ldapserver.rb +11 -12
- metadata +50 -8
- data/test/fixtures/cacert.pem +0 -20
@@ -1,45 +1,132 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
class TestLDAPConnection < Test::Unit::TestCase
|
4
|
+
def capture_stderr
|
5
|
+
stderr, $stderr = $stderr, StringIO.new
|
6
|
+
yield
|
7
|
+
$stderr.string
|
8
|
+
ensure
|
9
|
+
$stderr = stderr
|
10
|
+
end
|
11
|
+
|
12
|
+
# Fake socket for testing
|
13
|
+
#
|
14
|
+
# FakeTCPSocket.new("success", 636)
|
15
|
+
# FakeTCPSocket.new("fail.SocketError", 636) # raises SocketError
|
16
|
+
class FakeTCPSocket
|
17
|
+
def initialize(host, port, socket_opts = {})
|
18
|
+
status, error = host.split(".")
|
19
|
+
raise Object.const_get(error) if status == "fail"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_list_of_hosts_with_first_host_successful
|
24
|
+
hosts = [
|
25
|
+
["success.host", 636],
|
26
|
+
["fail.SocketError", 636],
|
27
|
+
["fail.SocketError", 636],
|
28
|
+
]
|
29
|
+
|
30
|
+
connection = Net::LDAP::Connection.new(:hosts => hosts, :socket_class => FakeTCPSocket)
|
31
|
+
connection.socket
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_list_of_hosts_with_first_host_failure
|
35
|
+
hosts = [
|
36
|
+
["fail.SocketError", 636],
|
37
|
+
["success.host", 636],
|
38
|
+
["fail.SocketError", 636],
|
39
|
+
]
|
40
|
+
|
41
|
+
connection = Net::LDAP::Connection.new(:hosts => hosts, :socket_class => FakeTCPSocket)
|
42
|
+
connection.socket
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_list_of_hosts_with_all_hosts_failure
|
46
|
+
hosts = [
|
47
|
+
["fail.SocketError", 636],
|
48
|
+
["fail.SocketError", 636],
|
49
|
+
["fail.SocketError", 636],
|
50
|
+
]
|
51
|
+
|
52
|
+
connection = Net::LDAP::Connection.new(:hosts => hosts, :socket_class => FakeTCPSocket)
|
53
|
+
assert_raise Net::LDAP::ConnectionError do
|
54
|
+
connection.socket
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# This belongs in test_ldap, not test_ldap_connection
|
59
|
+
def test_result_for_connection_failed_is_set
|
60
|
+
flexmock(Socket).should_receive(:tcp).and_raise(Errno::ECONNREFUSED)
|
61
|
+
|
62
|
+
ldap_client = Net::LDAP.new(host: '127.0.0.1', port: 12345)
|
63
|
+
|
64
|
+
assert_raise Net::LDAP::ConnectionRefusedError do
|
65
|
+
ldap_client.bind(method: :simple, username: 'asdf', password: 'asdf')
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal(ldap_client.get_operation_result.code, 52)
|
69
|
+
assert_equal(ldap_client.get_operation_result.message, 'Unavailable')
|
70
|
+
end
|
71
|
+
|
4
72
|
def test_unresponsive_host
|
73
|
+
connection = Net::LDAP::Connection.new(:host => "fail.Errno::ETIMEDOUT", :port => 636, :socket_class => FakeTCPSocket)
|
5
74
|
assert_raise Net::LDAP::Error do
|
6
|
-
|
75
|
+
connection.socket
|
7
76
|
end
|
8
77
|
end
|
9
78
|
|
10
79
|
def test_blocked_port
|
11
|
-
|
80
|
+
connection = Net::LDAP::Connection.new(:host => "fail.SocketError", :port => 636, :socket_class => FakeTCPSocket)
|
12
81
|
assert_raise Net::LDAP::Error do
|
13
|
-
|
82
|
+
connection.socket
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_connection_refused
|
87
|
+
connection = Net::LDAP::Connection.new(:host => "fail.Errno::ECONNREFUSED", :port => 636, :socket_class => FakeTCPSocket)
|
88
|
+
stderr = capture_stderr do
|
89
|
+
assert_raise Net::LDAP::ConnectionRefusedError do
|
90
|
+
connection.socket
|
91
|
+
end
|
92
|
+
end
|
93
|
+
assert_equal("Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead.\n", stderr)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_connection_timeout
|
97
|
+
connection = Net::LDAP::Connection.new(:host => "fail.Errno::ETIMEDOUT", :port => 636, :socket_class => FakeTCPSocket)
|
98
|
+
stderr = capture_stderr do
|
99
|
+
assert_raise Net::LDAP::Error do
|
100
|
+
connection.socket
|
101
|
+
end
|
14
102
|
end
|
15
103
|
end
|
16
104
|
|
17
105
|
def test_raises_unknown_exceptions
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Net::LDAP::Connection.new(:host => 'test.mocked.com', :port => 636)
|
106
|
+
connection = Net::LDAP::Connection.new(:host => "fail.StandardError", :port => 636, :socket_class => FakeTCPSocket)
|
107
|
+
assert_raise StandardError do
|
108
|
+
connection.socket
|
22
109
|
end
|
23
110
|
end
|
24
111
|
|
25
112
|
def test_modify_ops_delete
|
26
|
-
args = { :operations => [
|
113
|
+
args = { :operations => [[:delete, "mail"]] }
|
27
114
|
result = Net::LDAP::Connection.modify_ops(args[:operations])
|
28
|
-
expected = [
|
115
|
+
expected = ["0\r\n\x01\x010\b\x04\x04mail1\x00"]
|
29
116
|
assert_equal(expected, result)
|
30
117
|
end
|
31
118
|
|
32
119
|
def test_modify_ops_add
|
33
|
-
args = { :operations => [
|
120
|
+
args = { :operations => [[:add, "mail", "testuser@example.com"]] }
|
34
121
|
result = Net::LDAP::Connection.modify_ops(args[:operations])
|
35
|
-
expected = [
|
122
|
+
expected = ["0#\n\x01\x000\x1E\x04\x04mail1\x16\x04\x14testuser@example.com"]
|
36
123
|
assert_equal(expected, result)
|
37
124
|
end
|
38
125
|
|
39
126
|
def test_modify_ops_replace
|
40
|
-
args = { :operations =>[
|
127
|
+
args = { :operations =>[[:replace, "mail", "testuser@example.com"]] }
|
41
128
|
result = Net::LDAP::Connection.modify_ops(args[:operations])
|
42
|
-
expected = [
|
129
|
+
expected = ["0#\n\x01\x020\x1E\x04\x04mail1\x16\x04\x14testuser@example.com"]
|
43
130
|
assert_equal(expected, result)
|
44
131
|
end
|
45
132
|
|
@@ -73,7 +160,7 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
73
160
|
app_tag: Net::LDAP::PDU::SearchResult,
|
74
161
|
code: Net::LDAP::ResultCodeSuccess,
|
75
162
|
matched_dn: "",
|
76
|
-
error_message: ""
|
163
|
+
error_message: "",
|
77
164
|
}.merge(options)
|
78
165
|
result = Net::BER::BerIdentifiedArray.new([options[:code], options[:matched_dn], options[:error_message]])
|
79
166
|
result.ber_identifier = options[:app_tag]
|
@@ -168,7 +255,7 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
168
255
|
|
169
256
|
assert result = conn.rename(
|
170
257
|
olddn: "uid=renamable-user1,ou=People,dc=rubyldap,dc=com",
|
171
|
-
newrdn: "uid=renamed-user1"
|
258
|
+
newrdn: "uid=renamed-user1",
|
172
259
|
)
|
173
260
|
assert result.success?
|
174
261
|
assert_equal 2, result.message_id
|
@@ -202,7 +289,7 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
202
289
|
and_return(result2)
|
203
290
|
mock.should_receive(:write)
|
204
291
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
205
|
-
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}).
|
292
|
+
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil).
|
206
293
|
and_return(mock)
|
207
294
|
|
208
295
|
conn.next_msgid # simulates ongoing query
|
@@ -259,7 +346,7 @@ class TestLDAPConnectionErrors < Test::Unit::TestCase
|
|
259
346
|
def setup
|
260
347
|
@tcp_socket = flexmock(:connection)
|
261
348
|
@tcp_socket.should_receive(:write)
|
262
|
-
flexmock(
|
349
|
+
flexmock(Socket).should_receive(:tcp).and_return(@tcp_socket)
|
263
350
|
@connection = Net::LDAP::Connection.new(:host => 'test.mocked.com', :port => 636)
|
264
351
|
end
|
265
352
|
|
@@ -288,7 +375,7 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
288
375
|
def setup
|
289
376
|
@tcp_socket = flexmock(:connection)
|
290
377
|
@tcp_socket.should_receive(:write)
|
291
|
-
flexmock(
|
378
|
+
flexmock(Socket).should_receive(:tcp).and_return(@tcp_socket)
|
292
379
|
|
293
380
|
@service = MockInstrumentationService.new
|
294
381
|
@connection = Net::LDAP::Connection.new \
|
@@ -310,8 +397,8 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
310
397
|
|
311
398
|
# a write event
|
312
399
|
payload, result = events.pop
|
313
|
-
assert payload.
|
314
|
-
assert payload.
|
400
|
+
assert payload.key?(:result)
|
401
|
+
assert payload.key?(:content_length)
|
315
402
|
end
|
316
403
|
|
317
404
|
def test_read_net_ldap_connection_event
|
@@ -327,7 +414,7 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
327
414
|
|
328
415
|
# a read event
|
329
416
|
payload, result = events.pop
|
330
|
-
assert payload.
|
417
|
+
assert payload.key?(:result)
|
331
418
|
assert_equal read_result, result
|
332
419
|
end
|
333
420
|
|
@@ -344,9 +431,9 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
344
431
|
|
345
432
|
# a parse_pdu event
|
346
433
|
payload, result = events.pop
|
347
|
-
assert payload.
|
348
|
-
assert payload.
|
349
|
-
assert payload.
|
434
|
+
assert payload.key?(:pdu)
|
435
|
+
assert payload.key?(:app_tag)
|
436
|
+
assert payload.key?(:message_id)
|
350
437
|
assert_equal Net::LDAP::PDU::BindResult, payload[:app_tag]
|
351
438
|
assert_equal 1, payload[:message_id]
|
352
439
|
pdu = payload[:pdu]
|
@@ -366,7 +453,7 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
366
453
|
|
367
454
|
# a read event
|
368
455
|
payload, result = events.pop
|
369
|
-
assert payload.
|
456
|
+
assert payload.key?(:result)
|
370
457
|
assert result.success?, "should be success"
|
371
458
|
end
|
372
459
|
|
@@ -374,7 +461,7 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
374
461
|
# search data
|
375
462
|
search_data_ber = Net::BER::BerIdentifiedArray.new([1, [
|
376
463
|
"uid=user1,ou=People,dc=rubyldap,dc=com",
|
377
|
-
[
|
464
|
+
[["uid", ["user1"]]],
|
378
465
|
]])
|
379
466
|
search_data_ber.ber_identifier = Net::LDAP::PDU::SearchReturnedData
|
380
467
|
search_data = [1, search_data_ber]
|
@@ -393,8 +480,8 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
393
480
|
|
394
481
|
# a search event
|
395
482
|
payload, result = events.pop
|
396
|
-
assert payload.
|
397
|
-
assert payload.
|
483
|
+
assert payload.key?(:result)
|
484
|
+
assert payload.key?(:filter)
|
398
485
|
assert_equal "(uid=user1)", payload[:filter].to_s
|
399
486
|
assert result
|
400
487
|
|
data/test/test_ldif.rb
CHANGED
@@ -38,45 +38,45 @@ class TestLdif < Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
def test_ldif_with_continuation_lines
|
40
40
|
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
41
|
-
assert_equal(true, ds.
|
41
|
+
assert_equal(true, ds.key?("abcdefghijklmn"))
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_ldif_with_continuation_lines_and_extra_whitespace
|
45
45
|
ds1 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
46
|
-
assert_equal(true, ds1.
|
46
|
+
assert_equal(true, ds1.key?("abcdefg hijklmn"))
|
47
47
|
ds2 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n"))
|
48
|
-
assert_equal(true, ds2.
|
48
|
+
assert_equal(true, ds2.key?("abcdefghij klmn"))
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_ldif_tab_is_not_continuation
|
52
52
|
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: key\r\n\tnotcontinued\r\n\r\n"))
|
53
|
-
assert_equal(true, ds.
|
53
|
+
assert_equal(true, ds.key?("key"))
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_ldif_with_base64_dn
|
57
57
|
str = "dn:: Q049QmFzZTY0IGRuIHRlc3QsT1U9VGVzdCxPVT1Vbml0cyxEQz1leGFtcGxlLERDPWNvbQ==\r\n\r\n"
|
58
58
|
ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
|
59
|
-
assert_equal(true, ds.
|
59
|
+
assert_equal(true, ds.key?("CN=Base64 dn test,OU=Test,OU=Units,DC=example,DC=com"))
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_ldif_with_base64_dn_and_continuation_lines
|
63
63
|
str = "dn:: Q049QmFzZTY0IGRuIHRlc3Qgd2l0aCBjb250aW51YXRpb24gbGluZSxPVT1UZXN0LE9VPVVua\r\n XRzLERDPWV4YW1wbGUsREM9Y29t\r\n\r\n"
|
64
64
|
ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
|
65
|
-
assert_equal(true, ds.
|
65
|
+
assert_equal(true, ds.key?("CN=Base64 dn test with continuation line,OU=Test,OU=Units,DC=example,DC=com"))
|
66
66
|
end
|
67
67
|
|
68
68
|
# TODO, INADEQUATE. We need some more tests
|
69
69
|
# to verify the content.
|
70
70
|
def test_ldif
|
71
|
-
File.open(TestLdifFilename, "r")
|
71
|
+
File.open(TestLdifFilename, "r") do |f|
|
72
72
|
ds = Net::LDAP::Dataset::read_ldif(f)
|
73
73
|
assert_equal(13, ds.length)
|
74
|
-
|
74
|
+
end
|
75
75
|
end
|
76
76
|
|
77
77
|
# Must test folded lines and base64-encoded lines as well as normal ones.
|
78
78
|
def test_to_ldif
|
79
|
-
data = File.open(TestLdifFilename, "rb"
|
79
|
+
data = File.open(TestLdifFilename, "rb", &:read)
|
80
80
|
io = StringIO.new(data)
|
81
81
|
|
82
82
|
# added .lines to turn to array because 1.9 doesn't have
|
@@ -84,13 +84,13 @@ class TestLdif < Test::Unit::TestCase
|
|
84
84
|
entries = data.lines.grep(/^dn:\s*/) { $'.chomp }
|
85
85
|
dn_entries = entries.dup
|
86
86
|
|
87
|
-
ds = Net::LDAP::Dataset::read_ldif(io)
|
87
|
+
ds = Net::LDAP::Dataset::read_ldif(io) do |type, value|
|
88
88
|
case type
|
89
89
|
when :dn
|
90
90
|
assert_equal(dn_entries.first, value)
|
91
91
|
dn_entries.shift
|
92
92
|
end
|
93
|
-
|
93
|
+
end
|
94
94
|
assert_equal(entries.size, ds.size)
|
95
95
|
assert_equal(entries.sort, ds.to_ldif.grep(/^dn:\s*/) { $'.chomp })
|
96
96
|
end
|
data/test/test_search.rb
CHANGED
@@ -32,8 +32,8 @@ class TestSearch < Test::Unit::TestCase
|
|
32
32
|
@connection.search(:filter => "test")
|
33
33
|
|
34
34
|
payload, result = events.pop
|
35
|
-
assert payload.
|
36
|
-
assert payload.
|
35
|
+
assert payload.key?(:result)
|
36
|
+
assert payload.key?(:filter)
|
37
37
|
assert_equal "test", payload[:filter]
|
38
38
|
end
|
39
39
|
end
|
data/test/test_snmp.rb
CHANGED
@@ -16,9 +16,9 @@ class TestSnmp < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
def test_invalid_packet
|
18
18
|
data = "xxxx"
|
19
|
-
assert_raise(Net::BER::BerError)
|
19
|
+
assert_raise(Net::BER::BerError) do
|
20
20
|
ary = data.read_ber(Net::SNMP::AsnSyntax)
|
21
|
-
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
24
|
# The method String#read_ber! added by Net::BER consumes a well-formed BER
|
@@ -40,9 +40,9 @@ ary = data.read_ber(Net::SNMP::AsnSyntax)
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_weird_packet
|
43
|
-
assert_raise(Net::SnmpPdu::Error)
|
43
|
+
assert_raise(Net::SnmpPdu::Error) do
|
44
44
|
Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
45
|
-
|
45
|
+
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_get_request
|
data/testserver/ldapserver.rb
CHANGED
@@ -24,7 +24,7 @@ module LdapServer
|
|
24
24
|
},
|
25
25
|
:primitive => {
|
26
26
|
2 => :string, # ldapsearch sends this to unbind
|
27
|
-
}
|
27
|
+
},
|
28
28
|
},
|
29
29
|
:context_specific => {
|
30
30
|
:primitive => {
|
@@ -34,7 +34,7 @@ module LdapServer
|
|
34
34
|
:constructed => {
|
35
35
|
3 => :array # equality filter
|
36
36
|
},
|
37
|
-
}
|
37
|
+
},
|
38
38
|
}
|
39
39
|
|
40
40
|
def post_init
|
@@ -119,7 +119,7 @@ module LdapServer
|
|
119
119
|
# pdu[1][7] is the list of requested attributes.
|
120
120
|
# If it's an empty array, that means that *all* attributes were requested.
|
121
121
|
requested_attrs = if pdu[1][7].length > 0
|
122
|
-
pdu[1][7].map
|
122
|
+
pdu[1][7].map(&:downcase)
|
123
123
|
else
|
124
124
|
:all
|
125
125
|
end
|
@@ -133,21 +133,21 @@ module LdapServer
|
|
133
133
|
# TODO, what if this returns nil?
|
134
134
|
filter = Net::LDAP::Filter.parse_ldap_filter( filters )
|
135
135
|
|
136
|
-
$ldif.each
|
136
|
+
$ldif.each do |dn, entry|
|
137
137
|
if filter.match( entry )
|
138
138
|
attrs = []
|
139
|
-
entry.each
|
139
|
+
entry.each do |k, v|
|
140
140
|
if requested_attrs == :all or requested_attrs.include?(k.downcase)
|
141
|
-
attrvals = v.map
|
141
|
+
attrvals = v.map(&:to_ber).to_ber_set
|
142
142
|
attrs << [k.to_ber, attrvals].to_ber_sequence
|
143
143
|
end
|
144
|
-
|
144
|
+
end
|
145
145
|
|
146
146
|
appseq = [dn.to_ber, attrs.to_ber_sequence].to_ber_appsequence(4)
|
147
147
|
pkt = [msgid.to_ber, appseq].to_ber_sequence
|
148
148
|
send_data pkt
|
149
149
|
end
|
150
|
-
|
150
|
+
end
|
151
151
|
|
152
152
|
|
153
153
|
send_ldap_response 5, pdu[0].to_i, 0, "", "Was that what you wanted?"
|
@@ -156,7 +156,7 @@ module LdapServer
|
|
156
156
|
|
157
157
|
|
158
158
|
def send_ldap_response pkt_tag, msgid, code, dn, text
|
159
|
-
send_data( [msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)
|
159
|
+
send_data( [msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)].to_ber )
|
160
160
|
end
|
161
161
|
|
162
162
|
end
|
@@ -201,10 +201,9 @@ if __FILE__ == $0
|
|
201
201
|
|
202
202
|
require 'net/ldap'
|
203
203
|
|
204
|
-
EventMachine.run
|
204
|
+
EventMachine.run do
|
205
205
|
$logger.info "starting LDAP server on 127.0.0.1 port 3890"
|
206
206
|
EventMachine.start_server "127.0.0.1", 3890, LdapServer
|
207
207
|
EventMachine.add_periodic_timer 60, proc {$logger.info "heartbeat"}
|
208
|
-
|
208
|
+
end
|
209
209
|
end
|
210
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Cianfrocca
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: flexmock
|
@@ -49,14 +49,42 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.
|
52
|
+
version: 0.42.0
|
53
53
|
type: :development
|
54
54
|
prerelease: false
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
59
|
+
version: 0.42.0
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: test-unit
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: byebug
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
60
88
|
description: |-
|
61
89
|
Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
62
90
|
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
|
@@ -106,6 +134,10 @@ files:
|
|
106
134
|
- lib/net/ber/core_ext/string.rb
|
107
135
|
- lib/net/ber/core_ext/true_class.rb
|
108
136
|
- lib/net/ldap.rb
|
137
|
+
- lib/net/ldap/auth_adapter.rb
|
138
|
+
- lib/net/ldap/auth_adapter/gss_spnego.rb
|
139
|
+
- lib/net/ldap/auth_adapter/sasl.rb
|
140
|
+
- lib/net/ldap/auth_adapter/simple.rb
|
109
141
|
- lib/net/ldap/connection.rb
|
110
142
|
- lib/net/ldap/dataset.rb
|
111
143
|
- lib/net/ldap/dn.rb
|
@@ -118,13 +150,17 @@ files:
|
|
118
150
|
- lib/net/ldap/version.rb
|
119
151
|
- lib/net/snmp.rb
|
120
152
|
- net-ldap.gemspec
|
153
|
+
- script/changelog
|
154
|
+
- script/generate-fixture-ca
|
121
155
|
- script/install-openldap
|
122
156
|
- script/package
|
123
157
|
- script/release
|
124
158
|
- test/ber/core_ext/test_array.rb
|
125
159
|
- test/ber/core_ext/test_string.rb
|
126
160
|
- test/ber/test_ber.rb
|
127
|
-
- test/fixtures/
|
161
|
+
- test/fixtures/ca/ca.info
|
162
|
+
- test/fixtures/ca/cacert.pem
|
163
|
+
- test/fixtures/ca/cakey.pem
|
128
164
|
- test/fixtures/openldap/memberof.ldif
|
129
165
|
- test/fixtures/openldap/retcode.ldif
|
130
166
|
- test/fixtures/openldap/slapd.conf.ldif
|
@@ -134,11 +170,13 @@ files:
|
|
134
170
|
- test/integration/test_bind.rb
|
135
171
|
- test/integration/test_delete.rb
|
136
172
|
- test/integration/test_open.rb
|
173
|
+
- test/integration/test_password_modify.rb
|
137
174
|
- test/integration/test_return_codes.rb
|
138
175
|
- test/integration/test_search.rb
|
139
176
|
- test/support/vm/openldap/.gitignore
|
140
177
|
- test/support/vm/openldap/README.md
|
141
178
|
- test/support/vm/openldap/Vagrantfile
|
179
|
+
- test/test_auth_adapter.rb
|
142
180
|
- test/test_dn.rb
|
143
181
|
- test/test_entry.rb
|
144
182
|
- test/test_filter.rb
|
@@ -169,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
207
|
requirements:
|
170
208
|
- - ">="
|
171
209
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
210
|
+
version: 2.0.0
|
173
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
212
|
requirements:
|
175
213
|
- - ">="
|
@@ -177,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
215
|
version: '0'
|
178
216
|
requirements: []
|
179
217
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.5.2
|
181
219
|
signing_key:
|
182
220
|
specification_version: 4
|
183
221
|
summary: Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
@@ -187,7 +225,9 @@ test_files:
|
|
187
225
|
- test/ber/core_ext/test_array.rb
|
188
226
|
- test/ber/core_ext/test_string.rb
|
189
227
|
- test/ber/test_ber.rb
|
190
|
-
- test/fixtures/
|
228
|
+
- test/fixtures/ca/ca.info
|
229
|
+
- test/fixtures/ca/cacert.pem
|
230
|
+
- test/fixtures/ca/cakey.pem
|
191
231
|
- test/fixtures/openldap/memberof.ldif
|
192
232
|
- test/fixtures/openldap/retcode.ldif
|
193
233
|
- test/fixtures/openldap/slapd.conf.ldif
|
@@ -197,11 +237,13 @@ test_files:
|
|
197
237
|
- test/integration/test_bind.rb
|
198
238
|
- test/integration/test_delete.rb
|
199
239
|
- test/integration/test_open.rb
|
240
|
+
- test/integration/test_password_modify.rb
|
200
241
|
- test/integration/test_return_codes.rb
|
201
242
|
- test/integration/test_search.rb
|
202
243
|
- test/support/vm/openldap/.gitignore
|
203
244
|
- test/support/vm/openldap/README.md
|
204
245
|
- test/support/vm/openldap/Vagrantfile
|
246
|
+
- test/test_auth_adapter.rb
|
205
247
|
- test/test_dn.rb
|
206
248
|
- test/test_entry.rb
|
207
249
|
- test/test_filter.rb
|
data/test/fixtures/cacert.pem
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIDRzCCAf+gAwIBAgIEVHpbmjANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDEwhy
|
3
|
-
dWJ5bGRhcDAeFw0xNDExMjkyMzQ5NDZaFw0xNTExMjkyMzQ5NDZaMBMxETAPBgNV
|
4
|
-
BAMTCHJ1YnlsZGFwMIIBUjANBgkqhkiG9w0BAQEFAAOCAT8AMIIBOgKCATEA4pKe
|
5
|
-
cDCNuL53fkpO/WSAS+gmMTsOs+oOK71kZlk2QT/MBz8TxC6m358qCADjnXcMVVxa
|
6
|
-
ySQbQlVKZMkIvLNciZbiLDgC5II0NbHACNa8rqenoKRjS4J9W3OhA8EmnXn/Me+8
|
7
|
-
uMCI9tfnKNRZYdkQZlra4I+Idn+xYfl/5q5b/7ZjPS2zY/585hFEYE+5vfOZVBSU
|
8
|
-
3HMNSeuJvTehLv7dD7aQfXNM4cRgHXequkJQ/HLLFAO4AgJ+LJrFWpj7GWz3crgr
|
9
|
-
9G5px4T78wJH3NQiOsG6UBXPw8c4T+Z6GAWX2l1zs1gZsaiCVbAraqK3404lL7yp
|
10
|
-
+ThbsW3ifzgNPhmjScXBLdbEDrrAKosW7kkTOGzxiMCBmNlj2SKhcztoduAtfF1f
|
11
|
-
Fs2Jk8MRTHwO8ThD7wIDAQABo0MwQTAPBgNVHRMBAf8EBTADAQH/MA8GA1UdDwEB
|
12
|
-
/wQFAwMHBAAwHQYDVR0OBBYEFJDm67ekyFu4/Z7VcO6Vk/5pinGcMA0GCSqGSIb3
|
13
|
-
DQEBCwUAA4IBMQDHeEPzfYRtjynpUKyrtxx/6ZVOfCLuz4eHkBZggz/pJacDCv/a
|
14
|
-
I//W03XCk8RWq/fWVVUzvxXgPwnYcw992PLM7XW81zp6ruRUDWooYnjHZZz3bRhe
|
15
|
-
kC4QvM2mZhcsMVmhmWWKZn81qXgVdUY1XNRhk87cuXjF/UTpEieFvWAsCUkFZkqB
|
16
|
-
AmySCuI/FuPaauT1YAltkIlYAEIGNJGZDMf2BTVUQpXhTXeS9/AZWLNDBwiq+fwo
|
17
|
-
YYnsr9MnBXCEmg1gVSR/Ay2AZmbYfiYtb5kU8uq2lSWAUb4LX6HZl82wo3OilrJ2
|
18
|
-
WXl6Qf+Fcy4qqkRt4AKHjtzizpEDCOVYuuG0Zoy+QnxNXRsEzpb8ymnJFrcgYfk/
|
19
|
-
6Lv2gWAFl5FqCZp7gBWg55eL2coT4C+mbNTF
|
20
|
-
-----END CERTIFICATE-----
|