net-ldap 0.8.0 → 0.9.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.

Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.travis.yml +19 -1
  4. data/CONTRIBUTING.md +54 -0
  5. data/Hacking.rdoc +2 -4
  6. data/History.rdoc +37 -0
  7. data/Manifest.txt +0 -4
  8. data/README.rdoc +8 -0
  9. data/Rakefile +1 -3
  10. data/lib/net/ber/core_ext.rb +5 -5
  11. data/lib/net/ber/core_ext/string.rb +7 -7
  12. data/lib/net/ber/core_ext/true_class.rb +2 -3
  13. data/lib/net/ldap.rb +134 -620
  14. data/lib/net/ldap/connection.rb +692 -0
  15. data/lib/net/ldap/dataset.rb +18 -4
  16. data/lib/net/ldap/entry.rb +1 -1
  17. data/lib/net/ldap/filter.rb +7 -7
  18. data/lib/net/ldap/password.rb +11 -11
  19. data/lib/net/ldap/pdu.rb +28 -4
  20. data/lib/net/ldap/version.rb +1 -1
  21. data/lib/net/snmp.rb +235 -241
  22. data/net-ldap.gemspec +7 -33
  23. data/script/install-openldap +47 -0
  24. data/script/package +7 -0
  25. data/script/release +16 -0
  26. data/test/ber/core_ext/test_array.rb +22 -0
  27. data/test/ber/core_ext/test_string.rb +25 -0
  28. data/test/ber/test_ber.rb +126 -0
  29. data/test/fixtures/openldap/memberof.ldif +33 -0
  30. data/test/fixtures/openldap/retcode.ldif +76 -0
  31. data/test/fixtures/openldap/slapd.conf.ldif +67 -0
  32. data/test/fixtures/seed.ldif +374 -0
  33. data/test/integration/test_add.rb +28 -0
  34. data/test/integration/test_ber.rb +30 -0
  35. data/test/integration/test_bind.rb +22 -0
  36. data/test/integration/test_delete.rb +31 -0
  37. data/test/integration/test_open.rb +88 -0
  38. data/test/integration/test_return_codes.rb +38 -0
  39. data/test/integration/test_search.rb +77 -0
  40. data/test/support/vm/openldap/.gitignore +1 -0
  41. data/test/support/vm/openldap/README.md +32 -0
  42. data/test/support/vm/openldap/Vagrantfile +33 -0
  43. data/test/test_dn.rb +44 -0
  44. data/test/test_entry.rb +62 -56
  45. data/test/test_filter.rb +98 -2
  46. data/test/test_filter_parser.rb +16 -0
  47. data/test/test_helper.rb +54 -0
  48. data/test/test_ldap.rb +60 -0
  49. data/test/test_ldap_connection.rb +382 -2
  50. data/test/test_ldif.rb +26 -1
  51. data/test/test_password.rb +3 -10
  52. data/test/test_rename.rb +2 -2
  53. data/test/test_search.rb +39 -0
  54. data/test/test_snmp.rb +1 -1
  55. data/test/test_ssl_ber.rb +40 -0
  56. metadata +70 -75
  57. data/.autotest +0 -11
  58. data/.gemtest +0 -0
  59. data/.rspec +0 -2
  60. data/autotest/discover.rb +0 -1
  61. data/spec/integration/ssl_ber_spec.rb +0 -39
  62. data/spec/spec.opts +0 -2
  63. data/spec/spec_helper.rb +0 -28
  64. data/spec/unit/ber/ber_spec.rb +0 -141
  65. data/spec/unit/ber/core_ext/array_spec.rb +0 -24
  66. data/spec/unit/ber/core_ext/string_spec.rb +0 -51
  67. data/spec/unit/ldap/dn_spec.rb +0 -80
  68. data/spec/unit/ldap/entry_spec.rb +0 -51
  69. data/spec/unit/ldap/filter_parser_spec.rb +0 -26
  70. data/spec/unit/ldap/filter_spec.rb +0 -115
  71. data/spec/unit/ldap/search_spec.rb +0 -49
  72. data/spec/unit/ldap_spec.rb +0 -223
  73. data/test/common.rb +0 -3
@@ -1,6 +1,6 @@
1
1
  # $Id: testldif.rb 61 2006-04-18 20:55:55Z blackhedd $
2
2
 
3
- require 'common'
3
+ require_relative 'test_helper'
4
4
 
5
5
  require 'digest/sha1'
6
6
  require 'base64'
@@ -13,6 +13,12 @@ class TestLdif < Test::Unit::TestCase
13
13
  assert_equal(true, ds.empty?)
14
14
  end
15
15
 
16
+ def test_ldif_with_version
17
+ io = StringIO.new("version: 1")
18
+ ds = Net::LDAP::Dataset.read_ldif(io)
19
+ assert_equal "1", ds.version
20
+ end
21
+
16
22
  def test_ldif_with_comments
17
23
  str = ["# Hello from LDIF-land", "# This is an unterminated comment"]
18
24
  io = StringIO.new(str[0] + "\r\n" + str[1])
@@ -47,6 +53,18 @@ class TestLdif < Test::Unit::TestCase
47
53
  assert_equal(true, ds.has_key?("key"))
48
54
  end
49
55
 
56
+ def test_ldif_with_base64_dn
57
+ str = "dn:: Q049QmFzZTY0IGRuIHRlc3QsT1U9VGVzdCxPVT1Vbml0cyxEQz1leGFtcGxlLERDPWNvbQ==\r\n\r\n"
58
+ ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
59
+ assert_equal(true, ds.has_key?("CN=Base64 dn test,OU=Test,OU=Units,DC=example,DC=com"))
60
+ end
61
+
62
+ def test_ldif_with_base64_dn_and_continuation_lines
63
+ str = "dn:: Q049QmFzZTY0IGRuIHRlc3Qgd2l0aCBjb250aW51YXRpb24gbGluZSxPVT1UZXN0LE9VPVVua\r\n XRzLERDPWV4YW1wbGUsREM9Y29t\r\n\r\n"
64
+ ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str))
65
+ assert_equal(true, ds.has_key?("CN=Base64 dn test with continuation line,OU=Test,OU=Units,DC=example,DC=com"))
66
+ end
67
+
50
68
  # TODO, INADEQUATE. We need some more tests
51
69
  # to verify the content.
52
70
  def test_ldif
@@ -76,4 +94,11 @@ class TestLdif < Test::Unit::TestCase
76
94
  assert_equal(entries.size, ds.size)
77
95
  assert_equal(entries.sort, ds.to_ldif.grep(/^dn:\s*/) { $'.chomp })
78
96
  end
97
+
98
+ def test_to_ldif_with_version
99
+ ds = Net::LDAP::Dataset.new
100
+ ds.version = "1"
101
+
102
+ assert_equal "version: 1", ds.to_ldif_string.chomp
103
+ end
79
104
  end
@@ -1,17 +1,10 @@
1
1
  # $Id: testpsw.rb 72 2006-04-24 21:58:14Z blackhedd $
2
2
 
3
- require 'common'
3
+ require_relative 'test_helper'
4
4
 
5
5
  class TestPassword < Test::Unit::TestCase
6
-
7
6
  def test_psw
8
- assert_equal(
9
- "{MD5}xq8jwrcfibi0sZdZYNkSng==",
10
- Net::LDAP::Password.generate( :md5, "cashflow" ))
11
-
12
- assert_equal(
13
- "{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=",
14
- Net::LDAP::Password.generate( :sha, "cashflow" ))
7
+ assert_equal("{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate( :md5, "cashflow" ))
8
+ assert_equal("{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate( :sha, "cashflow" ))
15
9
  end
16
-
17
10
  end
@@ -1,7 +1,7 @@
1
- require 'common'
1
+ require_relative 'test_helper'
2
2
 
3
3
  # Commented out since it assumes you have a live LDAP server somewhere. This
4
- # will be migrated to the integration specs, as soon as they are ready.
4
+ # will be migrated to the integration specs, as soon as they are ready.
5
5
  =begin
6
6
  class TestRename < Test::Unit::TestCase
7
7
  HOST= '10.10.10.71'
@@ -0,0 +1,39 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ require_relative 'test_helper'
3
+
4
+ class TestSearch < Test::Unit::TestCase
5
+ class FakeConnection
6
+ def search(args)
7
+ OpenStruct.new(:result_code => Net::LDAP::ResultCodeOperationsError, :message => "error", :success? => false)
8
+ end
9
+ end
10
+
11
+ def setup
12
+ @service = MockInstrumentationService.new
13
+ @connection = Net::LDAP.new :instrumentation_service => @service
14
+ @connection.instance_variable_set(:@open_connection, FakeConnection.new)
15
+ end
16
+
17
+ def test_true_result
18
+ assert_nil @connection.search(:return_result => true)
19
+ end
20
+
21
+ def test_false_result
22
+ refute @connection.search(:return_result => false)
23
+ end
24
+
25
+ def test_no_result
26
+ assert_nil @connection.search
27
+ end
28
+
29
+ def test_instrumentation_publishes_event
30
+ events = @service.subscribe "search.net_ldap"
31
+
32
+ @connection.search(:filter => "test")
33
+
34
+ payload, result = events.pop
35
+ assert payload.has_key?(:result)
36
+ assert payload.has_key?(:filter)
37
+ assert_equal "test", payload[:filter]
38
+ end
39
+ end
@@ -1,6 +1,6 @@
1
1
  # $Id: testsnmp.rb 231 2006-12-21 15:09:29Z blackhedd $
2
2
 
3
- require 'common'
3
+ require_relative 'test_helper'
4
4
  require 'net/snmp'
5
5
 
6
6
  class TestSnmp < Test::Unit::TestCase
@@ -0,0 +1,40 @@
1
+ require_relative 'test_helper'
2
+ require 'timeout'
3
+
4
+ class TestSSLBER < Test::Unit::TestCase
5
+ # Transmits str to @to and reads it back from @from.
6
+ #
7
+ def transmit(str)
8
+ Timeout::timeout(1) do
9
+ @to.write(str)
10
+ @to.close
11
+
12
+ @from.read
13
+ end
14
+ end
15
+
16
+ def setup
17
+ @from, @to = IO.pipe
18
+
19
+ # The production code operates on sockets, which do need #connect called
20
+ # on them to work. Pipes are more robust for this test, so we'll skip
21
+ # the #connect call since it fails.
22
+ #
23
+ # TODO: Replace test with real socket
24
+ # https://github.com/ruby-ldap/ruby-net-ldap/pull/121#discussion_r18746386
25
+ flexmock(OpenSSL::SSL::SSLSocket).
26
+ new_instances.should_receive(:connect => nil)
27
+
28
+ @to = Net::LDAP::Connection.wrap_with_ssl(@to)
29
+ @from = Net::LDAP::Connection.wrap_with_ssl(@from)
30
+ end
31
+
32
+ def test_transmit_strings
33
+ assert_equal "foo", transmit("foo")
34
+ end
35
+
36
+ def test_transmit_ber_encoded_numbers
37
+ @to.write 1234.to_ber
38
+ assert_equal 1234, @from.read_ber
39
+ end
40
+ end
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: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -13,106 +13,64 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-09-10 00:00:00.000000000 Z
16
+ date: 2012-02-28 00:00:00.000000000 Z
17
17
  dependencies:
18
- - !ruby/object:Gem::Dependency
19
- name: rdoc
20
- requirement: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - "~>"
23
- - !ruby/object:Gem::Version
24
- version: '4.0'
25
- type: :development
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - "~>"
30
- - !ruby/object:Gem::Version
31
- version: '4.0'
32
18
  - !ruby/object:Gem::Dependency
33
19
  name: hoe-git
34
20
  requirement: !ruby/object:Gem::Requirement
35
21
  requirements:
36
22
  - - "~>"
37
23
  - !ruby/object:Gem::Version
38
- version: '1'
24
+ version: '1.0'
39
25
  type: :development
40
26
  prerelease: false
41
27
  version_requirements: !ruby/object:Gem::Requirement
42
28
  requirements:
43
29
  - - "~>"
44
30
  - !ruby/object:Gem::Version
45
- version: '1'
31
+ version: '1.0'
46
32
  - !ruby/object:Gem::Dependency
47
33
  name: hoe-gemspec
48
34
  requirement: !ruby/object:Gem::Requirement
49
35
  requirements:
50
36
  - - "~>"
51
37
  - !ruby/object:Gem::Version
52
- version: '1'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '1'
60
- - !ruby/object:Gem::Dependency
61
- name: metaid
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '1'
38
+ version: '1.0'
67
39
  type: :development
68
40
  prerelease: false
69
41
  version_requirements: !ruby/object:Gem::Requirement
70
42
  requirements:
71
43
  - - "~>"
72
44
  - !ruby/object:Gem::Version
73
- version: '1'
45
+ version: '1.0'
74
46
  - !ruby/object:Gem::Dependency
75
47
  name: flexmock
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 1.3.0
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: 1.3.0
88
- - !ruby/object:Gem::Dependency
89
- name: rspec
90
48
  requirement: !ruby/object:Gem::Requirement
91
49
  requirements:
92
50
  - - "~>"
93
51
  - !ruby/object:Gem::Version
94
- version: '2.0'
52
+ version: '1.3'
95
53
  type: :development
96
54
  prerelease: false
97
55
  version_requirements: !ruby/object:Gem::Requirement
98
56
  requirements:
99
57
  - - "~>"
100
58
  - !ruby/object:Gem::Version
101
- version: '2.0'
59
+ version: '1.3'
102
60
  - !ruby/object:Gem::Dependency
103
61
  name: hoe
104
62
  requirement: !ruby/object:Gem::Requirement
105
63
  requirements:
106
64
  - - "~>"
107
65
  - !ruby/object:Gem::Version
108
- version: '3.10'
66
+ version: '2.9'
109
67
  type: :development
110
68
  prerelease: false
111
69
  version_requirements: !ruby/object:Gem::Requirement
112
70
  requirements:
113
71
  - - "~>"
114
72
  - !ruby/object:Gem::Version
115
- version: '3.10'
73
+ version: '2.9'
116
74
  description: |-
117
75
  Net::LDAP for Ruby (also called net-ldap) implements client access for the
118
76
  Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
@@ -122,30 +80,28 @@ description: |-
122
80
 
123
81
  Net::LDAP has been tested against modern popular LDAP servers including
124
82
  OpenLDAP and Active Directory. The current release is mostly compliant with
125
- earlier versions of the IETF LDAP RFCs (22512256, 28292830, 3377, and 3771).
83
+ earlier versions of the IETF LDAP RFCs (2251-2256, 2829-2830, 3377, and 3771).
126
84
  Our roadmap for Net::LDAP 1.0 is to gain full <em>client</em> compliance with
127
- the most recent LDAP RFCs (45104519, plus portions of 45204532).
85
+ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).
128
86
  email:
129
87
  - blackhedd@rubyforge.org
130
88
  - gemiel@gmail.com
131
89
  - rory.ocon@gmail.com
132
90
  - kaspar.schiess@absurd.li
133
91
  - austin@rubyforge.org
134
- - michael@schaaryworks.com
135
92
  executables: []
136
93
  extensions: []
137
94
  extra_rdoc_files:
95
+ - Manifest.txt
138
96
  - Contributors.rdoc
139
97
  - Hacking.rdoc
140
98
  - History.rdoc
141
99
  - License.rdoc
142
- - Manifest.txt
143
100
  - README.rdoc
144
101
  files:
145
- - ".autotest"
146
- - ".gemtest"
147
- - ".rspec"
102
+ - ".gitignore"
148
103
  - ".travis.yml"
104
+ - CONTRIBUTING.md
149
105
  - Contributors.rdoc
150
106
  - Gemfile
151
107
  - Hacking.rdoc
@@ -154,7 +110,6 @@ files:
154
110
  - Manifest.txt
155
111
  - README.rdoc
156
112
  - Rakefile
157
- - autotest/discover.rb
158
113
  - lib/net-ldap.rb
159
114
  - lib/net/ber.rb
160
115
  - lib/net/ber/ber_parser.rb
@@ -166,6 +121,7 @@ files:
166
121
  - lib/net/ber/core_ext/string.rb
167
122
  - lib/net/ber/core_ext/true_class.rb
168
123
  - lib/net/ldap.rb
124
+ - lib/net/ldap/connection.rb
169
125
  - lib/net/ldap/dataset.rb
170
126
  - lib/net/ldap/dn.rb
171
127
  - lib/net/ldap/entry.rb
@@ -176,30 +132,43 @@ files:
176
132
  - lib/net/ldap/version.rb
177
133
  - lib/net/snmp.rb
178
134
  - net-ldap.gemspec
179
- - spec/integration/ssl_ber_spec.rb
180
- - spec/spec.opts
181
- - spec/spec_helper.rb
182
- - spec/unit/ber/ber_spec.rb
183
- - spec/unit/ber/core_ext/array_spec.rb
184
- - spec/unit/ber/core_ext/string_spec.rb
185
- - spec/unit/ldap/dn_spec.rb
186
- - spec/unit/ldap/entry_spec.rb
187
- - spec/unit/ldap/filter_parser_spec.rb
188
- - spec/unit/ldap/filter_spec.rb
189
- - spec/unit/ldap/search_spec.rb
190
- - spec/unit/ldap_spec.rb
191
- - test/common.rb
135
+ - script/install-openldap
136
+ - script/package
137
+ - script/release
138
+ - test/ber/core_ext/test_array.rb
139
+ - test/ber/core_ext/test_string.rb
140
+ - test/ber/test_ber.rb
141
+ - test/fixtures/openldap/memberof.ldif
142
+ - test/fixtures/openldap/retcode.ldif
143
+ - test/fixtures/openldap/slapd.conf.ldif
144
+ - test/fixtures/seed.ldif
145
+ - test/integration/test_add.rb
146
+ - test/integration/test_ber.rb
147
+ - test/integration/test_bind.rb
148
+ - test/integration/test_delete.rb
149
+ - test/integration/test_open.rb
150
+ - test/integration/test_return_codes.rb
151
+ - test/integration/test_search.rb
152
+ - test/support/vm/openldap/.gitignore
153
+ - test/support/vm/openldap/README.md
154
+ - test/support/vm/openldap/Vagrantfile
155
+ - test/test_dn.rb
192
156
  - test/test_entry.rb
193
157
  - test/test_filter.rb
158
+ - test/test_filter_parser.rb
159
+ - test/test_helper.rb
160
+ - test/test_ldap.rb
194
161
  - test/test_ldap_connection.rb
195
162
  - test/test_ldif.rb
196
163
  - test/test_password.rb
197
164
  - test/test_rename.rb
165
+ - test/test_search.rb
198
166
  - test/test_snmp.rb
167
+ - test/test_ssl_ber.rb
199
168
  - test/testdata.ldif
200
169
  - testserver/ldapserver.rb
201
170
  - testserver/testdata.ldif
202
- homepage: http://rubyldap.com/'
171
+ homepage: http://github.com/ruby-ldap/ruby-net-ldap
203
172
  licenses:
204
173
  - MIT
205
174
  metadata: {}
@@ -213,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
182
  requirements:
214
183
  - - ">="
215
184
  - !ruby/object:Gem::Version
216
- version: 1.8.7
185
+ version: 1.9.3
217
186
  required_rubygems_version: !ruby/object:Gem::Requirement
218
187
  requirements:
219
188
  - - ">="
@@ -228,10 +197,36 @@ summary: Net::LDAP for Ruby (also called net-ldap) implements client access for
228
197
  Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing
229
198
  distributed directory services
230
199
  test_files:
200
+ - test/ber/core_ext/test_array.rb
201
+ - test/ber/core_ext/test_string.rb
202
+ - test/ber/test_ber.rb
203
+ - test/fixtures/openldap/memberof.ldif
204
+ - test/fixtures/openldap/retcode.ldif
205
+ - test/fixtures/openldap/slapd.conf.ldif
206
+ - test/fixtures/seed.ldif
207
+ - test/integration/test_add.rb
208
+ - test/integration/test_ber.rb
209
+ - test/integration/test_bind.rb
210
+ - test/integration/test_delete.rb
211
+ - test/integration/test_open.rb
212
+ - test/integration/test_return_codes.rb
213
+ - test/integration/test_search.rb
214
+ - test/support/vm/openldap/.gitignore
215
+ - test/support/vm/openldap/README.md
216
+ - test/support/vm/openldap/Vagrantfile
217
+ - test/test_dn.rb
231
218
  - test/test_entry.rb
232
219
  - test/test_filter.rb
220
+ - test/test_filter_parser.rb
221
+ - test/test_helper.rb
222
+ - test/test_ldap.rb
233
223
  - test/test_ldap_connection.rb
234
224
  - test/test_ldif.rb
235
225
  - test/test_password.rb
236
226
  - test/test_rename.rb
227
+ - test/test_search.rb
237
228
  - test/test_snmp.rb
229
+ - test/test_ssl_ber.rb
230
+ - test/testdata.ldif
231
+ - testserver/ldapserver.rb
232
+ - testserver/testdata.ldif