net-ldap 0.1.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of net-ldap might be problematic. Click here for more details.

Files changed (58) hide show
  1. data/.autotest +11 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +2 -0
  4. data/Contributors.rdoc +21 -0
  5. data/Hacking.rdoc +68 -0
  6. data/{History.txt → History.rdoc} +65 -1
  7. data/License.rdoc +29 -0
  8. data/Manifest.txt +25 -14
  9. data/README.rdoc +52 -0
  10. data/Rakefile +52 -96
  11. data/autotest/discover.rb +1 -0
  12. data/lib/net-ldap.rb +1 -0
  13. data/lib/net/ber.rb +302 -81
  14. data/lib/net/ber/ber_parser.rb +153 -97
  15. data/lib/net/ber/core_ext.rb +62 -0
  16. data/lib/net/ber/core_ext/array.rb +82 -0
  17. data/lib/net/ber/core_ext/bignum.rb +22 -0
  18. data/lib/net/ber/core_ext/false_class.rb +10 -0
  19. data/lib/net/ber/core_ext/fixnum.rb +66 -0
  20. data/lib/net/ber/core_ext/string.rb +48 -0
  21. data/lib/net/ber/core_ext/true_class.rb +12 -0
  22. data/lib/net/ldap.rb +1455 -1475
  23. data/lib/net/ldap/dataset.rb +134 -79
  24. data/lib/net/ldap/dn.rb +225 -0
  25. data/lib/net/ldap/entry.rb +168 -249
  26. data/lib/net/ldap/filter.rb +654 -387
  27. data/lib/net/ldap/password.rb +31 -0
  28. data/lib/net/ldap/pdu.rb +232 -233
  29. data/lib/net/snmp.rb +4 -31
  30. data/net-ldap.gemspec +59 -0
  31. data/spec/integration/ssl_ber_spec.rb +3 -0
  32. data/spec/spec_helper.rb +2 -2
  33. data/spec/unit/ber/ber_spec.rb +82 -6
  34. data/spec/unit/ber/core_ext/string_spec.rb +51 -0
  35. data/spec/unit/ldap/dn_spec.rb +80 -0
  36. data/spec/unit/ldap/entry_spec.rb +51 -0
  37. data/spec/unit/ldap/filter_spec.rb +84 -0
  38. data/spec/unit/ldap_spec.rb +48 -0
  39. data/test/test_entry.rb +54 -2
  40. data/test/test_filter.rb +93 -54
  41. data/test/test_ldap_connection.rb +24 -0
  42. data/test/test_ldif.rb +31 -23
  43. data/test/test_rename.rb +77 -0
  44. data/test/test_snmp.rb +34 -33
  45. metadata +88 -52
  46. data/COPYING +0 -272
  47. data/LICENSE +0 -56
  48. data/README.txt +0 -68
  49. data/lib/net/ldap/core_ext/all.rb +0 -43
  50. data/lib/net/ldap/core_ext/array.rb +0 -42
  51. data/lib/net/ldap/core_ext/bignum.rb +0 -25
  52. data/lib/net/ldap/core_ext/false_class.rb +0 -11
  53. data/lib/net/ldap/core_ext/fixnum.rb +0 -74
  54. data/lib/net/ldap/core_ext/string.rb +0 -40
  55. data/lib/net/ldap/core_ext/true_class.rb +0 -11
  56. data/lib/net/ldap/psw.rb +0 -57
  57. data/lib/net/ldif.rb +0 -34
  58. data/test/test_ber.rb +0 -78
@@ -1,35 +1,8 @@
1
- # $Id$
2
- #
3
- # NET::SNMP
4
- #
5
- #----------------------------------------------------------------------------
6
- #
7
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
8
- #
9
- # Gmail: garbagecat10
10
- #
11
- # This program is free software; you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation; either version 2 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # This program is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with this program; if not, write to the Free Software
23
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
- #
25
- #---------------------------------------------------------------------------
26
- #
27
- #
28
-
1
+ # -*- ruby encoding: utf-8 -*-
2
+ # :stopdoc:
29
3
  module Net
30
-
31
4
  class SNMP
32
- VERSION = '0.1.0'
5
+ VERSION = '0.2'
33
6
 
34
7
  AsnSyntax = Net::BER.compile_syntax({
35
8
  :application => {
@@ -292,4 +265,4 @@ module Net
292
265
 
293
266
  end
294
267
  end
295
-
268
+ # :startdoc:
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{net-ldap}
5
+ s.version = "0.2.20110317223538"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Rory O'Connell", "Kaspar Schiess", "Austin Ziegler"]
9
+ s.date = %q{2011-03-17}
10
+ s.description = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the
11
+ Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
12
+ accessing distributed directory services. Net::LDAP is written completely in
13
+ Ruby with no external dependencies. It supports most LDAP client features and a
14
+ subset of server features as well.
15
+
16
+ Net::LDAP has been tested against modern popular LDAP servers including
17
+ OpenLDAP and Active Directory. The current release is mostly compliant with
18
+ earlier versions of the IETF LDAP RFCs (2251–2256, 2829–2830, 3377, and 3771).
19
+ Our roadmap for Net::LDAP 1.0 is to gain full <em>client</em> compliance with
20
+ the most recent LDAP RFCs (4510–4519, plutions of 4520–4532).}
21
+ s.email = ["blackhedd@rubyforge.org", "gemiel@gmail.com", "rory.ocon@gmail.com", "kaspar.schiess@absurd.li", "austin@rubyforge.org"]
22
+ s.extra_rdoc_files = ["Manifest.txt", "Contributors.rdoc", "Hacking.rdoc", "History.rdoc", "License.rdoc", "README.rdoc"]
23
+ s.files = [".autotest", ".rspec", "Contributors.rdoc", "Hacking.rdoc", "History.rdoc", "License.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "autotest/discover.rb", "lib/net-ldap.rb", "lib/net/ber.rb", "lib/net/ber/ber_parser.rb", "lib/net/ber/core_ext.rb", "lib/net/ber/core_ext/array.rb", "lib/net/ber/core_ext/bignum.rb", "lib/net/ber/core_ext/false_class.rb", "lib/net/ber/core_ext/fixnum.rb", "lib/net/ber/core_ext/string.rb", "lib/net/ber/core_ext/true_class.rb", "lib/net/ldap.rb", "lib/net/ldap/dataset.rb", "lib/net/ldap/dn.rb", "lib/net/ldap/entry.rb", "lib/net/ldap/filter.rb", "lib/net/ldap/password.rb", "lib/net/ldap/pdu.rb", "lib/net/snmp.rb", "net-ldap.gemspec", "spec/integration/ssl_ber_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/unit/ber/ber_spec.rb", "spec/unit/ber/core_ext/string_spec.rb", "spec/unit/ldap/dn_spec.rb", "spec/unit/ldap/entry_spec.rb", "spec/unit/ldap/filter_spec.rb", "spec/unit/ldap_spec.rb", "test/common.rb", "test/test_entry.rb", "test/test_filter.rb", "test/test_ldap_connection.rb", "test/test_ldif.rb", "test/test_password.rb", "test/test_rename.rb", "test/test_snmp.rb", "test/testdata.ldif", "testserver/ldapserver.rb", "testserver/testdata.ldif", ".gemtest"]
24
+ s.homepage = %q{http://net-ldap.rubyforge.org/}
25
+ s.rdoc_options = ["--main", "README.rdoc"]
26
+ s.require_paths = ["lib"]
27
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
28
+ s.rubyforge_project = %q{net-ldap}
29
+ s.rubygems_version = %q{1.5.2}
30
+ s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services}
31
+ s.test_files = ["test/test_entry.rb", "test/test_filter.rb", "test/test_ldap_connection.rb", "test/test_ldif.rb", "test/test_password.rb", "test/test_rename.rb", "test/test_snmp.rb"]
32
+
33
+ if s.respond_to? :specification_version then
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ s.add_development_dependency(%q<hoe-git>, ["~> 1"])
38
+ s.add_development_dependency(%q<hoe-gemspec>, ["~> 1"])
39
+ s.add_development_dependency(%q<metaid>, ["~> 1"])
40
+ s.add_development_dependency(%q<flexmock>, ["~> 0.9.0"])
41
+ s.add_development_dependency(%q<rspec>, ["~> 2.0"])
42
+ s.add_development_dependency(%q<hoe>, [">= 2.9.1"])
43
+ else
44
+ s.add_dependency(%q<hoe-git>, ["~> 1"])
45
+ s.add_dependency(%q<hoe-gemspec>, ["~> 1"])
46
+ s.add_dependency(%q<metaid>, ["~> 1"])
47
+ s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
48
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
49
+ s.add_dependency(%q<hoe>, [">= 2.9.1"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<hoe-git>, ["~> 1"])
53
+ s.add_dependency(%q<hoe-gemspec>, ["~> 1"])
54
+ s.add_dependency(%q<metaid>, ["~> 1"])
55
+ s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
56
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
57
+ s.add_dependency(%q<hoe>, [">= 2.9.1"])
58
+ end
59
+ end
@@ -16,6 +16,9 @@ describe "BER serialisation (SSL)" do
16
16
  before(:each) do
17
17
  @from, @to = IO.pipe
18
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.
19
22
  flexmock(OpenSSL::SSL::SSLSocket).
20
23
  new_instances.should_receive(:connect => nil)
21
24
 
@@ -1,5 +1,5 @@
1
1
  require 'net/ldap'
2
2
 
3
- Spec::Runner.configure do |config|
3
+ RSpec.configure do |config|
4
4
  config.mock_with :flexmock
5
- end
5
+ end
@@ -3,16 +3,92 @@ require 'spec_helper'
3
3
  require 'net/ber'
4
4
  require 'net/ldap'
5
5
 
6
- describe "Ber encoding of various types" do
7
- def properly_encode_and_decode
8
- simple_matcher('properly encode and decode') do |given|
6
+ describe "BER encoding of" do
7
+
8
+ RSpec::Matchers.define :properly_encode_and_decode do
9
+ match do |given|
9
10
  given.to_ber.read_ber.should == given
10
11
  end
11
12
  end
12
-
13
- context "array" do
14
- it "should properly encode []" do
13
+
14
+ context "arrays" do
15
+ it "should properly encode/decode []" do
15
16
  [].should properly_encode_and_decode
16
17
  end
18
+ it "should properly encode/decode [1,2,3]" do
19
+ ary = [1,2,3]
20
+ encoded_ary = ary.map { |el| el.to_ber }.to_ber
21
+
22
+ encoded_ary.read_ber.should == ary
23
+ end
24
+ end
25
+ context "booleans" do
26
+ it "should encode true" do
27
+ true.to_ber.should == "\x01\x01\x01"
28
+ end
29
+ it "should encode false" do
30
+ false.to_ber.should == "\x01\x01\x00"
31
+ end
32
+ end
33
+ context "numbers" do
34
+ # Sample based
35
+ {
36
+ 0 => "\x02\x01\x00",
37
+ 1 => "\x02\x01\x01",
38
+ 127 => "\x02\x01\x7F",
39
+ 128 => "\x02\x01\x80",
40
+ 255 => "\x02\x01\xFF",
41
+ 256 => "\x02\x02\x01\x00",
42
+ 65535 => "\x02\x02\xFF\xFF",
43
+ 65536 => "\x02\x03\x01\x00\x00",
44
+ 16_777_215 => "\x02\x03\xFF\xFF\xFF",
45
+ 0x01000000 => "\x02\x04\x01\x00\x00\x00",
46
+ 0x3FFFFFFF => "\x02\x04\x3F\xFF\xFF\xFF",
47
+ 0x4FFFFFFF => "\x02\x04\x4F\xFF\xFF\xFF",
48
+
49
+ # Some odd samples...
50
+ 5 => "\002\001\005",
51
+ 500 => "\002\002\001\364",
52
+ 50_000 => "\x02\x02\xC3P",
53
+ 5_000_000_000 => "\002\005\001*\005\362\000"
54
+ }.each do |number, expected_encoding|
55
+ it "should encode #{number} as #{expected_encoding.inspect}" do
56
+ number.to_ber.should == expected_encoding
57
+ end
58
+ end
59
+
60
+ # Round-trip encoding: This is mostly to be sure to cover Bignums well.
61
+ context "when decoding with #read_ber" do
62
+ it "should correctly handle powers of two" do
63
+ 100.times do |p|
64
+ n = 2 << p
65
+
66
+ n.should properly_encode_and_decode
67
+ end
68
+ end
69
+ it "should correctly handle powers of ten" do
70
+ 100.times do |p|
71
+ n = 5 * 10**p
72
+
73
+ n.should properly_encode_and_decode
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ describe "BER decoding of" do
81
+ context "numbers" do
82
+ it "should decode #{"\002\001\006".inspect} (6)" do
83
+ "\002\001\006".read_ber(Net::LDAP::AsnSyntax).should == 6
84
+ end
85
+ it "should decode #{"\004\007testing".inspect} ('testing')" do
86
+ "\004\007testing".read_ber(Net::LDAP::AsnSyntax).should == 'testing'
87
+ end
88
+ it "should decode an ldap bind request" do
89
+ "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus".
90
+ read_ber(Net::LDAP::AsnSyntax).should ==
91
+ [1, [3, "Administrator", "ad_is_bogus"]]
92
+ end
17
93
  end
18
94
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'metaid'
3
+
4
+ describe String, "when extended with BER core extensions" do
5
+ describe "<- #read_ber! (consuming read_ber method)" do
6
+ context "when passed an ldap bind request and some extra data" do
7
+ attr_reader :str, :result
8
+ before(:each) do
9
+ @str = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus UNCONSUMED"
10
+ @result = str.read_ber!(Net::LDAP::AsnSyntax)
11
+ end
12
+
13
+ it "should correctly parse the ber message" do
14
+ result.should == [1, [3, "Administrator", "ad_is_bogus"]]
15
+ end
16
+ it "should leave unconsumed part of message in place" do
17
+ str.should == " UNCONSUMED"
18
+ end
19
+
20
+ context "if an exception occurs during #read_ber" do
21
+ attr_reader :initial_value
22
+ before(:each) do
23
+ stub_exception_class = Class.new(StandardError)
24
+
25
+ @initial_value = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus"
26
+ @str = initial_value.dup
27
+
28
+ # Defines a string
29
+ io = StringIO.new(initial_value)
30
+ io.meta_def :read_ber do |syntax|
31
+ read
32
+ raise stub_exception_class
33
+ end
34
+ flexmock(StringIO).should_receive(:new).and_return(io)
35
+
36
+ begin
37
+ str.read_ber!(Net::LDAP::AsnSyntax)
38
+ rescue stub_exception_class
39
+ # EMPTY ON PURPOSE
40
+ else
41
+ raise "The stub code should raise an exception!"
42
+ end
43
+ end
44
+
45
+ it "should not modify string" do
46
+ str.should == initial_value
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+ require 'net/ldap/dn'
3
+
4
+ describe Net::LDAP::DN do
5
+ describe "<- .construct" do
6
+ attr_reader :dn
7
+
8
+ before(:each) do
9
+ @dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company')
10
+ end
11
+
12
+ it "should construct a Net::LDAP::DN" do
13
+ dn.should be_an_instance_of(Net::LDAP::DN)
14
+ end
15
+
16
+ it "should escape all the required characters" do
17
+ dn.to_s.should == 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company'
18
+ end
19
+ end
20
+
21
+ describe "<- .to_a" do
22
+ context "parsing" do
23
+ {
24
+ 'cn=James, ou=Company\\,\\20LLC' => ['cn','James','ou','Company, LLC'],
25
+ 'cn = \ James , ou = "Comp\28ny" ' => ['cn',' James','ou','Comp(ny'],
26
+ '1.23.4= #A3B4D5 ,ou=Company' => ['1.23.4','#A3B4D5','ou','Company'],
27
+ }.each do |key, value|
28
+ context "(#{key})" do
29
+ attr_reader :dn
30
+
31
+ before(:each) do
32
+ @dn = Net::LDAP::DN.new(key)
33
+ end
34
+
35
+ it "should decode into a Net::LDAP::DN" do
36
+ dn.should be_an_instance_of(Net::LDAP::DN)
37
+ end
38
+
39
+ it "should return the correct array" do
40
+ dn.to_a.should == value
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ context "parsing bad input" do
47
+ [
48
+ 'cn=James,',
49
+ 'cn=#aa aa',
50
+ 'cn="James',
51
+ 'cn=J\ames',
52
+ 'cn=\\',
53
+ '1.2.d=Value',
54
+ 'd1.2=Value',
55
+ ].each do |value|
56
+ context "(#{value})" do
57
+ attr_reader :dn
58
+
59
+ before(:each) do
60
+ @dn = Net::LDAP::DN.new(value)
61
+ end
62
+
63
+ it "should decode into a Net::LDAP::DN" do
64
+ dn.should be_an_instance_of(Net::LDAP::DN)
65
+ end
66
+
67
+ it "should raise an error on parsing" do
68
+ lambda { dn.to_a }.should raise_error
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ describe "<- .escape(str)" do
76
+ it "should escape ,, +, \", \\, <, >, and ;" do
77
+ Net::LDAP::DN.escape(',+"\\<>;').should == '\\,\\+\\"\\\\\\<\\>\\;'
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Net::LDAP::Entry do
4
+ attr_reader :entry
5
+ before(:each) do
6
+ @entry = Net::LDAP::Entry.from_single_ldif_string(
7
+ %Q{dn: something
8
+ foo: foo
9
+ barAttribute: bar
10
+ }
11
+ )
12
+ end
13
+
14
+ describe "entry access" do
15
+ it "should always respond to #dn" do
16
+ entry.should respond_to(:dn)
17
+ end
18
+
19
+ context "<- #foo" do
20
+ it "should respond_to?" do
21
+ entry.should respond_to(:foo)
22
+ end
23
+ it "should return 'foo'" do
24
+ entry.foo.should == ['foo']
25
+ end
26
+ end
27
+ context "<- #Foo" do
28
+ it "should respond_to?" do
29
+ entry.should respond_to(:Foo)
30
+ end
31
+ it "should return 'foo'" do
32
+ entry.foo.should == ['foo']
33
+ end
34
+ end
35
+ context "<- #foo=" do
36
+ it "should respond_to?" do
37
+ entry.should respond_to(:foo=)
38
+ end
39
+ it "should set 'foo'" do
40
+ entry.foo= 'bar'
41
+ entry.foo.should == ['bar']
42
+ end
43
+ end
44
+ context "<- #fOo=" do
45
+ it "should return 'foo'" do
46
+ entry.fOo= 'bar'
47
+ entry.fOo.should == ['bar']
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Net::LDAP::Filter do
4
+ describe "<- .ex(attr, value)" do
5
+ context "('foo', 'bar')" do
6
+ attr_reader :filter
7
+ before(:each) do
8
+ @filter = Net::LDAP::Filter.ex('foo', 'bar')
9
+ end
10
+ it "should convert to 'foo:=bar'" do
11
+ filter.to_s.should == '(foo:=bar)'
12
+ end
13
+ it "should survive roundtrip via to_s/from_rfc2254" do
14
+ Net::LDAP::Filter.from_rfc2254(filter.to_s).should == filter
15
+ end
16
+ it "should survive roundtrip conversion to/from ber" do
17
+ ber = filter.to_ber
18
+ Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
19
+ filter
20
+ end
21
+ end
22
+ context "various legal inputs" do
23
+ [
24
+ '(o:dn:=Ace Industry)',
25
+ '(:dn:2.4.8.10:=Dino)',
26
+ '(cn:dn:1.2.3.4.5:=John Smith)',
27
+ '(sn:dn:2.4.6.8.10:=Barbara Jones)',
28
+ '(&(sn:dn:2.4.6.8.10:=Barbara Jones))'
29
+ ].each do |filter_str|
30
+ context "from_rfc2254(#{filter_str.inspect})" do
31
+ attr_reader :filter
32
+ before(:each) do
33
+ @filter = Net::LDAP::Filter.from_rfc2254(filter_str)
34
+ end
35
+
36
+ it "should decode into a Net::LDAP::Filter" do
37
+ filter.should be_an_instance_of(Net::LDAP::Filter)
38
+ end
39
+ it "should survive roundtrip conversion to/from ber" do
40
+ ber = filter.to_ber
41
+ Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
42
+ filter
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ describe "<- .construct" do
49
+ it "should accept apostrophes in filters (regression)" do
50
+ Net::LDAP::Filter.construct("uid=O'Keefe").to_rfc2254.should == "(uid=O'Keefe)"
51
+ end
52
+ end
53
+
54
+ describe "convenience filter constructors" do
55
+ def eq(attribute, value)
56
+ described_class.eq(attribute, value)
57
+ end
58
+ describe "<- .equals(attr, val)" do
59
+ it "should delegate to .eq with escaping" do
60
+ described_class.equals('dn', 'f*oo').should == eq('dn', 'f\2Aoo')
61
+ end
62
+ end
63
+ describe "<- .begins(attr, val)" do
64
+ it "should delegate to .eq with escaping" do
65
+ described_class.begins('dn', 'f*oo').should == eq('dn', 'f\2Aoo*')
66
+ end
67
+ end
68
+ describe "<- .ends(attr, val)" do
69
+ it "should delegate to .eq with escaping" do
70
+ described_class.ends('dn', 'f*oo').should == eq('dn', '*f\2Aoo')
71
+ end
72
+ end
73
+ describe "<- .contains(attr, val)" do
74
+ it "should delegate to .eq with escaping" do
75
+ described_class.contains('dn', 'f*oo').should == eq('dn', '*f\2Aoo*')
76
+ end
77
+ end
78
+ end
79
+ describe "<- .escape(str)" do
80
+ it "should escape nul, *, (, ) and \\" do
81
+ Net::LDAP::Filter.escape("\0*()\\").should == "\\00\\2A\\28\\29\\5C"
82
+ end
83
+ end
84
+ end