net-ldap 0.16.2 → 0.16.3
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 +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +216 -246
- data/.travis.yml +4 -2
- data/CONTRIBUTING.md +1 -1
- data/README.rdoc +2 -2
- data/Rakefile +1 -1
- data/lib/net-ldap.rb +1 -1
- data/lib/net/ber.rb +2 -2
- data/lib/net/ber/core_ext.rb +6 -6
- data/lib/net/ldap.rb +13 -13
- data/lib/net/ldap/auth_adapter/gss_spnego.rb +2 -2
- data/lib/net/ldap/auth_adapter/sasl.rb +1 -1
- data/lib/net/ldap/auth_adapter/simple.rb +1 -1
- data/lib/net/ldap/connection.rb +4 -4
- data/lib/net/ldap/dataset.rb +2 -2
- data/lib/net/ldap/dn.rb +10 -10
- data/lib/net/ldap/entry.rb +1 -1
- data/lib/net/ldap/error.rb +1 -0
- data/lib/net/ldap/filter.rb +3 -3
- data/lib/net/ldap/instrumentation.rb +2 -2
- data/lib/net/ldap/password.rb +3 -5
- data/lib/net/ldap/pdu.rb +1 -1
- data/lib/net/ldap/version.rb +1 -1
- data/lib/net/snmp.rb +1 -1
- data/net-ldap.gemspec +4 -4
- data/test/ber/test_ber.rb +1 -1
- data/test/integration/test_ber.rb +1 -1
- data/test/integration/test_bind.rb +1 -2
- data/test/integration/test_password_modify.rb +10 -10
- data/test/test_dn.rb +2 -3
- data/test/test_entry.rb +3 -2
- data/test/test_filter_parser.rb +5 -0
- data/test/test_helper.rb +1 -1
- data/test/test_ldap.rb +5 -5
- data/test/test_ldap_connection.rb +46 -32
- data/test/test_ldif.rb +12 -12
- data/test/test_password.rb +2 -2
- data/test/test_snmp.rb +4 -5
- data/test/test_ssl_ber.rb +7 -3
- data/testserver/ldapserver.rb +13 -22
- metadata +10 -10
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
class TestBindIntegration < LDAPIntegrationTestCase
|
4
|
-
|
5
4
|
INTEGRATION_HOSTNAME = 'ldap.example.org'.freeze
|
6
5
|
|
7
6
|
def test_bind_success
|
@@ -28,7 +27,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
28
27
|
assert_equal Net::LDAP::ResultCodeUnwillingToPerform, result.code
|
29
28
|
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeUnwillingToPerform], result.message
|
30
29
|
assert_equal "unauthenticated bind (DN with no password) disallowed",
|
31
|
-
|
30
|
+
result.error_message
|
32
31
|
assert_equal "", result.matched_dn
|
33
32
|
end
|
34
33
|
|
@@ -3,7 +3,7 @@ require_relative '../test_helper'
|
|
3
3
|
class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
@admin_account = {dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple}
|
6
|
+
@admin_account = { dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple }
|
7
7
|
@ldap.authenticate @admin_account[:dn], @admin_account[:password]
|
8
8
|
|
9
9
|
@dn = 'uid=modify-password-user1,ou=People,dc=example,dc=org'
|
@@ -35,13 +35,13 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
35
35
|
new_password: 'passworD2')
|
36
36
|
|
37
37
|
assert @ldap.get_operation_result.extended_response.nil?,
|
38
|
-
|
38
|
+
'Should not have generated a new password'
|
39
39
|
|
40
40
|
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
41
|
-
|
41
|
+
'Old password should no longer be valid'
|
42
42
|
|
43
43
|
assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple),
|
44
|
-
|
44
|
+
'New password should be valid'
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_password_modify_generate
|
@@ -54,10 +54,10 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
54
54
|
assert generated_password, 'Should have generated a password'
|
55
55
|
|
56
56
|
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
57
|
-
|
57
|
+
'Old password should no longer be valid'
|
58
58
|
|
59
59
|
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
|
60
|
-
|
60
|
+
'New password should be valid'
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_password_modify_generate_no_old_password
|
@@ -69,10 +69,10 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
69
69
|
assert generated_password, 'Should have generated a password'
|
70
70
|
|
71
71
|
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
72
|
-
|
72
|
+
'Old password should no longer be valid'
|
73
73
|
|
74
74
|
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
|
75
|
-
|
75
|
+
'New password should be valid'
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_password_modify_overwrite_old_password
|
@@ -81,10 +81,10 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
81
81
|
new_password: 'passworD3')
|
82
82
|
|
83
83
|
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
84
|
-
|
84
|
+
'Old password should no longer be valid'
|
85
85
|
|
86
86
|
assert @ldap.bind(username: @dn, password: 'passworD3', method: :simple),
|
87
|
-
|
87
|
+
'New password should be valid'
|
88
88
|
end
|
89
89
|
|
90
90
|
def teardown
|
data/test/test_dn.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
|
-
|
2
|
+
require_relative '../lib/net/ldap/dn'
|
3
3
|
|
4
4
|
class TestDN < Test::Unit::TestCase
|
5
5
|
def test_escape
|
@@ -26,7 +26,6 @@ class TestDN < Test::Unit::TestCase
|
|
26
26
|
assert_equal ['1.23.4', '#A3B4D5', 'ou', 'Company'], dn.to_a
|
27
27
|
end
|
28
28
|
|
29
|
-
# TODO: raise a more specific exception than RuntimeError
|
30
29
|
def test_bad_input_raises_error
|
31
30
|
[
|
32
31
|
'cn=James,',
|
@@ -38,7 +37,7 @@ class TestDN < Test::Unit::TestCase
|
|
38
37
|
'd1.2=Value',
|
39
38
|
].each do |input|
|
40
39
|
dn = Net::LDAP::DN.new(input)
|
41
|
-
assert_raises(
|
40
|
+
assert_raises(Net::LDAP::InvalidDNError) { dn.to_a }
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/test/test_entry.rb
CHANGED
@@ -47,7 +47,8 @@ class TestEntryLDIF < Test::Unit::TestCase
|
|
47
47
|
%Q{dn: something
|
48
48
|
foo: foo
|
49
49
|
barAttribute: bar
|
50
|
-
}
|
50
|
+
},
|
51
|
+
)
|
51
52
|
end
|
52
53
|
|
53
54
|
def test_attribute
|
@@ -59,7 +60,7 @@ barAttribute: bar
|
|
59
60
|
@entry.foo = 'bar'
|
60
61
|
assert_equal ['bar'], @entry.foo
|
61
62
|
|
62
|
-
@entry.fOo= 'baz'
|
63
|
+
@entry.fOo = 'baz'
|
63
64
|
assert_equal ['baz'], @entry.foo
|
64
65
|
end
|
65
66
|
end
|
data/test/test_filter_parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require_relative 'test_helper'
|
3
4
|
|
4
5
|
class TestFilterParser < Test::Unit::TestCase
|
@@ -21,4 +22,8 @@ class TestFilterParser < Test::Unit::TestCase
|
|
21
22
|
def test_colons
|
22
23
|
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(ismemberof=cn=edu:berkeley:app:calmessages:deans,ou=campus groups,dc=berkeley,dc=edu)")
|
23
24
|
end
|
25
|
+
|
26
|
+
def test_attr_tag
|
27
|
+
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;primary=jane@example.org)")
|
28
|
+
end
|
24
29
|
end
|
data/test/test_helper.rb
CHANGED
data/test/test_ldap.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'test_helper'
|
2
2
|
|
3
3
|
class TestLDAPInstrumentation < Test::Unit::TestCase
|
4
4
|
# Fake Net::LDAP::Connection for testing
|
@@ -94,7 +94,7 @@ class TestLDAPInstrumentation < Test::Unit::TestCase
|
|
94
94
|
|
95
95
|
def test_normalize_encryption_symbol
|
96
96
|
enc = @subject.send(:normalize_encryption, :start_tls)
|
97
|
-
assert_equal enc,
|
97
|
+
assert_equal enc, :method => :start_tls, :tls_options => {}
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_normalize_encryption_nil
|
@@ -104,11 +104,11 @@ class TestLDAPInstrumentation < Test::Unit::TestCase
|
|
104
104
|
|
105
105
|
def test_normalize_encryption_string
|
106
106
|
enc = @subject.send(:normalize_encryption, 'start_tls')
|
107
|
-
assert_equal enc,
|
107
|
+
assert_equal enc, :method => :start_tls, :tls_options => {}
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_normalize_encryption_hash
|
111
|
-
enc = @subject.send(:normalize_encryption,
|
112
|
-
assert_equal enc,
|
111
|
+
enc = @subject.send(:normalize_encryption, :method => :start_tls, :tls_options => { :foo => :bar })
|
112
|
+
assert_equal enc, :method => :start_tls, :tls_options => { :foo => :bar }
|
113
113
|
end
|
114
114
|
end
|
@@ -95,7 +95,7 @@ class TestLDAPConnection < Test::Unit::TestCase
|
|
95
95
|
|
96
96
|
def test_connection_timeout
|
97
97
|
connection = Net::LDAP::Connection.new(:host => "fail.Errno::ETIMEDOUT", :port => 636, :socket_class => FakeTCPSocket)
|
98
|
-
|
98
|
+
capture_stderr do
|
99
99
|
assert_raise Net::LDAP::Error do
|
100
100
|
connection.socket
|
101
101
|
end
|
@@ -124,7 +124,7 @@ class TestLDAPConnection < Test::Unit::TestCase
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_modify_ops_replace
|
127
|
-
args = { :operations =>[[:replace, "mail", "testuser@example.com"]] }
|
127
|
+
args = { :operations => [[:replace, "mail", "testuser@example.com"]] }
|
128
128
|
result = Net::LDAP::Connection.modify_ops(args[:operations])
|
129
129
|
expected = ["0#\n\x01\x020\x1E\x04\x04mail1\x16\x04\x14testuser@example.com"]
|
130
130
|
assert_equal(expected, result)
|
@@ -191,9 +191,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
191
191
|
result2 = make_message(2)
|
192
192
|
|
193
193
|
mock = flexmock("socket")
|
194
|
-
mock.should_receive(:read_ber)
|
195
|
-
|
196
|
-
|
194
|
+
mock.should_receive(:read_ber)
|
195
|
+
.and_return(result1)
|
196
|
+
.and_return(result2)
|
197
197
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
198
198
|
|
199
199
|
assert result = conn.queued_read(2)
|
@@ -206,9 +206,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
206
206
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::ModifyResponse)
|
207
207
|
|
208
208
|
mock = flexmock("socket")
|
209
|
-
mock.should_receive(:read_ber)
|
210
|
-
|
211
|
-
|
209
|
+
mock.should_receive(:read_ber)
|
210
|
+
.and_return(result1)
|
211
|
+
.and_return(result2)
|
212
212
|
mock.should_receive(:write)
|
213
213
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
214
214
|
|
@@ -227,9 +227,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
227
227
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::AddResponse)
|
228
228
|
|
229
229
|
mock = flexmock("socket")
|
230
|
-
mock.should_receive(:read_ber)
|
231
|
-
|
232
|
-
|
230
|
+
mock.should_receive(:read_ber)
|
231
|
+
.and_return(result1)
|
232
|
+
.and_return(result2)
|
233
233
|
mock.should_receive(:write)
|
234
234
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
235
235
|
|
@@ -245,9 +245,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
245
245
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::ModifyRDNResponse)
|
246
246
|
|
247
247
|
mock = flexmock("socket")
|
248
|
-
mock.should_receive(:read_ber)
|
249
|
-
|
250
|
-
|
248
|
+
mock.should_receive(:read_ber)
|
249
|
+
.and_return(result1)
|
250
|
+
.and_return(result2)
|
251
251
|
mock.should_receive(:write)
|
252
252
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
253
253
|
|
@@ -266,9 +266,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
266
266
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::DeleteResponse)
|
267
267
|
|
268
268
|
mock = flexmock("socket")
|
269
|
-
mock.should_receive(:read_ber)
|
270
|
-
|
271
|
-
|
269
|
+
mock.should_receive(:read_ber)
|
270
|
+
.and_return(result1)
|
271
|
+
.and_return(result2)
|
272
272
|
mock.should_receive(:write)
|
273
273
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
274
274
|
|
@@ -284,13 +284,13 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
284
284
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::ExtendedResponse)
|
285
285
|
|
286
286
|
mock = flexmock("socket")
|
287
|
-
mock.should_receive(:read_ber)
|
288
|
-
|
289
|
-
|
287
|
+
mock.should_receive(:read_ber)
|
288
|
+
.and_return(result1)
|
289
|
+
.and_return(result2)
|
290
290
|
mock.should_receive(:write)
|
291
291
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
292
|
-
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil)
|
293
|
-
|
292
|
+
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil)
|
293
|
+
.and_return(mock)
|
294
294
|
|
295
295
|
conn.next_msgid # simulates ongoing query
|
296
296
|
|
@@ -303,9 +303,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
303
303
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::BindResult)
|
304
304
|
|
305
305
|
mock = flexmock("socket")
|
306
|
-
mock.should_receive(:read_ber)
|
307
|
-
|
308
|
-
|
306
|
+
mock.should_receive(:read_ber)
|
307
|
+
.and_return(result1)
|
308
|
+
.and_return(result2)
|
309
309
|
mock.should_receive(:write)
|
310
310
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
311
311
|
|
@@ -314,7 +314,8 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
314
314
|
assert result = conn.bind(
|
315
315
|
method: :simple,
|
316
316
|
username: "uid=user1,ou=People,dc=rubyldap,dc=com",
|
317
|
-
password: "passworD1"
|
317
|
+
password: "passworD1",
|
318
|
+
)
|
318
319
|
assert result.success?
|
319
320
|
assert_equal 2, result.message_id
|
320
321
|
end
|
@@ -324,9 +325,9 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
324
325
|
result2 = make_message(2, app_tag: Net::LDAP::PDU::BindResult)
|
325
326
|
|
326
327
|
mock = flexmock("socket")
|
327
|
-
mock.should_receive(:read_ber)
|
328
|
-
|
329
|
-
|
328
|
+
mock.should_receive(:read_ber)
|
329
|
+
.and_return(result1)
|
330
|
+
.and_return(result2)
|
330
331
|
mock.should_receive(:write)
|
331
332
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
332
333
|
|
@@ -336,10 +337,23 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
336
337
|
method: :sasl,
|
337
338
|
mechanism: "fake",
|
338
339
|
initial_credential: "passworD1",
|
339
|
-
challenge_response: flexmock("challenge proc")
|
340
|
+
challenge_response: flexmock("challenge proc"),
|
341
|
+
)
|
340
342
|
assert result.success?
|
341
343
|
assert_equal 2, result.message_id
|
342
344
|
end
|
345
|
+
|
346
|
+
def test_invalid_pdu_type
|
347
|
+
options = {
|
348
|
+
code: Net::LDAP::ResultCodeSuccess,
|
349
|
+
matched_dn: "",
|
350
|
+
error_message: "",
|
351
|
+
}
|
352
|
+
ber = Net::BER::BerIdentifiedArray.new([options[:code], options[:matched_dn], options[:error_message]])
|
353
|
+
assert_raise Net::LDAP::PDU::Error do
|
354
|
+
Net::LDAP::PDU.new([0, ber])
|
355
|
+
end
|
356
|
+
end
|
343
357
|
end
|
344
358
|
|
345
359
|
class TestLDAPConnectionErrors < Test::Unit::TestCase
|
@@ -469,8 +483,8 @@ class TestLDAPConnectionInstrumentation < Test::Unit::TestCase
|
|
469
483
|
search_result_ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""])
|
470
484
|
search_result_ber.ber_identifier = Net::LDAP::PDU::SearchResult
|
471
485
|
search_result = [1, search_result_ber]
|
472
|
-
@tcp_socket.should_receive(:read_ber).and_return(search_data)
|
473
|
-
|
486
|
+
@tcp_socket.should_receive(:read_ber).and_return(search_data)
|
487
|
+
.and_return(search_result)
|
474
488
|
|
475
489
|
events = @service.subscribe "search.net_ldap_connection"
|
476
490
|
unread = @service.subscribe "search_messages_unread.net_ldap_connection"
|
data/test/test_ldif.rb
CHANGED
@@ -22,46 +22,46 @@ class TestLdif < Test::Unit::TestCase
|
|
22
22
|
def test_ldif_with_comments
|
23
23
|
str = ["# Hello from LDIF-land", "# This is an unterminated comment"]
|
24
24
|
io = StringIO.new(str[0] + "\r\n" + str[1])
|
25
|
-
ds = Net::LDAP::Dataset
|
25
|
+
ds = Net::LDAP::Dataset.read_ldif(io)
|
26
26
|
assert_equal(str, ds.comments)
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_ldif_with_password
|
30
30
|
psw = "goldbricks"
|
31
|
-
hashed_psw = "{SHA}" + Base64
|
31
|
+
hashed_psw = "{SHA}" + Base64.encode64(Digest::SHA1.digest(psw)).chomp
|
32
32
|
|
33
|
-
ldif_encoded = Base64
|
34
|
-
ds = Net::LDAP::Dataset
|
33
|
+
ldif_encoded = Base64.encode64(hashed_psw).chomp
|
34
|
+
ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n"))
|
35
35
|
recovered_psw = ds["Goldbrick"][:userpassword].shift
|
36
36
|
assert_equal(hashed_psw, recovered_psw)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_ldif_with_continuation_lines
|
40
|
-
ds = Net::LDAP::Dataset
|
40
|
+
ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
41
41
|
assert_equal(true, ds.key?("abcdefghijklmn"))
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_ldif_with_continuation_lines_and_extra_whitespace
|
45
|
-
ds1 = Net::LDAP::Dataset
|
45
|
+
ds1 = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
46
46
|
assert_equal(true, ds1.key?("abcdefg hijklmn"))
|
47
|
-
ds2 = Net::LDAP::Dataset
|
47
|
+
ds2 = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n"))
|
48
48
|
assert_equal(true, ds2.key?("abcdefghij klmn"))
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_ldif_tab_is_not_continuation
|
52
|
-
ds = Net::LDAP::Dataset
|
52
|
+
ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: key\r\n\tnotcontinued\r\n\r\n"))
|
53
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
|
-
ds = Net::LDAP::Dataset
|
58
|
+
ds = Net::LDAP::Dataset.read_ldif(StringIO.new(str))
|
59
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
|
-
ds = Net::LDAP::Dataset
|
64
|
+
ds = Net::LDAP::Dataset.read_ldif(StringIO.new(str))
|
65
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
|
|
@@ -69,7 +69,7 @@ class TestLdif < Test::Unit::TestCase
|
|
69
69
|
# to verify the content.
|
70
70
|
def test_ldif
|
71
71
|
File.open(TestLdifFilename, "r") do |f|
|
72
|
-
ds = Net::LDAP::Dataset
|
72
|
+
ds = Net::LDAP::Dataset.read_ldif(f)
|
73
73
|
assert_equal(13, ds.length)
|
74
74
|
end
|
75
75
|
end
|
@@ -84,7 +84,7 @@ 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
|
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)
|
data/test/test_password.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'test_helper'
|
|
4
4
|
|
5
5
|
class TestPassword < Test::Unit::TestCase
|
6
6
|
def test_psw
|
7
|
-
assert_equal("{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate(
|
8
|
-
assert_equal("{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate(
|
7
|
+
assert_equal("{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate(:md5, "cashflow"))
|
8
|
+
assert_equal("{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate(:sha, "cashflow"))
|
9
9
|
end
|
10
10
|
end
|
data/test/test_snmp.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# $Id: testsnmp.rb 231 2006-12-21 15:09:29Z blackhedd $
|
2
2
|
|
3
3
|
require_relative 'test_helper'
|
4
|
-
|
4
|
+
require_relative '../lib/net/snmp'
|
5
5
|
|
6
6
|
class TestSnmp < Test::Unit::TestCase
|
7
7
|
def self.raw_string(s)
|
@@ -17,7 +17,7 @@ class TestSnmp < Test::Unit::TestCase
|
|
17
17
|
def test_invalid_packet
|
18
18
|
data = "xxxx"
|
19
19
|
assert_raise(Net::BER::BerError) do
|
20
|
-
|
20
|
+
data.read_ber(Net::SNMP::AsnSyntax)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -41,7 +41,7 @@ ary = data.read_ber(Net::SNMP::AsnSyntax)
|
|
41
41
|
|
42
42
|
def test_weird_packet
|
43
43
|
assert_raise(Net::SnmpPdu::Error) do
|
44
|
-
Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
44
|
+
Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -93,7 +93,7 @@ Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
|
93
93
|
|
94
94
|
def test_make_bad_response
|
95
95
|
pdu = Net::SnmpPdu.new
|
96
|
-
assert_raise(Net::SnmpPdu::Error) {pdu.to_ber_string}
|
96
|
+
assert_raise(Net::SnmpPdu::Error) { pdu.to_ber_string }
|
97
97
|
pdu.pdu_type = :get_response
|
98
98
|
pdu.request_id = 999
|
99
99
|
pdu.to_ber_string
|
@@ -115,5 +115,4 @@ Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
|
115
115
|
pdu = Net::SnmpPdu.parse(ary)
|
116
116
|
assert_equal("xxxxxx", pdu.community)
|
117
117
|
end
|
118
|
-
|
119
118
|
end
|