net-ldap 0.3.1 → 0.17.0
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 +7 -0
- data/Contributors.rdoc +4 -0
- data/Hacking.rdoc +3 -8
- data/History.rdoc +181 -0
- data/README.rdoc +44 -12
- data/lib/net-ldap.rb +1 -1
- data/lib/net/ber.rb +41 -7
- data/lib/net/ber/ber_parser.rb +21 -7
- data/lib/net/ber/core_ext.rb +11 -18
- data/lib/net/ber/core_ext/array.rb +14 -0
- data/lib/net/ber/core_ext/integer.rb +74 -0
- data/lib/net/ber/core_ext/string.rb +24 -4
- data/lib/net/ber/core_ext/true_class.rb +2 -3
- data/lib/net/ldap.rb +441 -639
- data/lib/net/ldap/auth_adapter.rb +29 -0
- 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/connection.rb +716 -0
- data/lib/net/ldap/dataset.rb +23 -9
- data/lib/net/ldap/dn.rb +13 -14
- data/lib/net/ldap/entry.rb +27 -9
- data/lib/net/ldap/error.rb +49 -0
- data/lib/net/ldap/filter.rb +58 -32
- data/lib/net/ldap/instrumentation.rb +23 -0
- data/lib/net/ldap/password.rb +23 -14
- data/lib/net/ldap/pdu.rb +70 -6
- data/lib/net/ldap/version.rb +5 -0
- data/lib/net/snmp.rb +237 -241
- metadata +71 -116
- data/.autotest +0 -11
- data/.gemtest +0 -0
- data/.rspec +0 -2
- data/Manifest.txt +0 -49
- data/Rakefile +0 -74
- data/autotest/discover.rb +0 -1
- data/lib/net/ber/core_ext/bignum.rb +0 -22
- data/lib/net/ber/core_ext/fixnum.rb +0 -66
- data/net-ldap.gemspec +0 -58
- data/spec/integration/ssl_ber_spec.rb +0 -36
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -5
- data/spec/unit/ber/ber_spec.rb +0 -109
- data/spec/unit/ber/core_ext/string_spec.rb +0 -51
- data/spec/unit/ldap/dn_spec.rb +0 -80
- data/spec/unit/ldap/entry_spec.rb +0 -51
- data/spec/unit/ldap/filter_spec.rb +0 -84
- data/spec/unit/ldap_spec.rb +0 -48
- data/test/common.rb +0 -3
- data/test/test_entry.rb +0 -59
- data/test/test_filter.rb +0 -122
- data/test/test_ldap_connection.rb +0 -24
- data/test/test_ldif.rb +0 -79
- data/test/test_password.rb +0 -17
- data/test/test_rename.rb +0 -77
- data/test/test_snmp.rb +0 -114
- data/test/testdata.ldif +0 -101
- data/testserver/ldapserver.rb +0 -210
- data/testserver/testdata.ldif +0 -101
@@ -1,66 +0,0 @@
|
|
1
|
-
# -*- ruby encoding: utf-8 -*-
|
2
|
-
##
|
3
|
-
# Ber extensions to the Fixnum class.
|
4
|
-
module Net::BER::Extensions::Fixnum
|
5
|
-
##
|
6
|
-
# Converts the fixnum to BER format.
|
7
|
-
def to_ber
|
8
|
-
"\002#{to_ber_internal}"
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Converts the fixnum to BER enumerated format.
|
13
|
-
def to_ber_enumerated
|
14
|
-
"\012#{to_ber_internal}"
|
15
|
-
end
|
16
|
-
|
17
|
-
##
|
18
|
-
# Converts the fixnum to BER length encodining format.
|
19
|
-
def to_ber_length_encoding
|
20
|
-
if self <= 127
|
21
|
-
[self].pack('C')
|
22
|
-
else
|
23
|
-
i = [self].pack('N').sub(/^[\0]+/,"")
|
24
|
-
[0x80 + i.length].pack('C') + i
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# Generate a BER-encoding for an application-defined INTEGER. Examples of
|
30
|
-
# such integers are SNMP's Counter, Gauge, and TimeTick types.
|
31
|
-
def to_ber_application(tag)
|
32
|
-
[0x40 + tag].pack("C") + to_ber_internal
|
33
|
-
end
|
34
|
-
|
35
|
-
##
|
36
|
-
# Used to BER-encode the length and content bytes of a Fixnum. Callers
|
37
|
-
# must prepend the tag byte for the contained value.
|
38
|
-
def to_ber_internal
|
39
|
-
# CAUTION: Bit twiddling ahead. You might want to shield your eyes or
|
40
|
-
# something.
|
41
|
-
|
42
|
-
# Looks for the first byte in the fixnum that is not all zeroes. It does
|
43
|
-
# this by masking one byte after another, checking the result for bits
|
44
|
-
# that are left on.
|
45
|
-
size = Net::BER::MAX_FIXNUM_SIZE
|
46
|
-
while size > 1
|
47
|
-
break if (self & (0xff << (size - 1) * 8)) > 0
|
48
|
-
size -= 1
|
49
|
-
end
|
50
|
-
|
51
|
-
# Store the size of the fixnum in the result
|
52
|
-
result = [size]
|
53
|
-
|
54
|
-
# Appends bytes to result, starting with higher orders first. Extraction
|
55
|
-
# of bytes is done by right shifting the original fixnum by an amount
|
56
|
-
# and then masking that with 0xff.
|
57
|
-
while size > 0
|
58
|
-
# right shift size - 1 bytes, mask with 0xff
|
59
|
-
result << ((self >> ((size - 1) * 8)) & 0xff)
|
60
|
-
size -= 1
|
61
|
-
end
|
62
|
-
|
63
|
-
result.pack('C*')
|
64
|
-
end
|
65
|
-
private :to_ber_internal
|
66
|
-
end
|
data/net-ldap.gemspec
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
Gem::Specification.new do |s|
|
3
|
-
s.name = %q{net-ldap}
|
4
|
-
s.version = "0.3.1"
|
5
|
-
|
6
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
7
|
-
s.authors = ["Francis Cianfrocca", "Emiel van de Laar", "Rory O'Connell", "Kaspar Schiess", "Austin Ziegler"]
|
8
|
-
s.date = %q{2011-03-17}
|
9
|
-
s.description = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
10
|
-
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
|
11
|
-
accessing distributed directory services. Net::LDAP is written completely in
|
12
|
-
Ruby with no external dependencies. It supports most LDAP client features and a
|
13
|
-
subset of server features as well.
|
14
|
-
|
15
|
-
Net::LDAP has been tested against modern popular LDAP servers including
|
16
|
-
OpenLDAP and Active Directory. The current release is mostly compliant with
|
17
|
-
earlier versions of the IETF LDAP RFCs (2251–2256, 2829–2830, 3377, and 3771).
|
18
|
-
Our roadmap for Net::LDAP 1.0 is to gain full <em>client</em> compliance with
|
19
|
-
the most recent LDAP RFCs (4510–4519, plutions of 4520–4532).}
|
20
|
-
s.email = ["blackhedd@rubyforge.org", "gemiel@gmail.com", "rory.ocon@gmail.com", "kaspar.schiess@absurd.li", "austin@rubyforge.org"]
|
21
|
-
s.extra_rdoc_files = ["Manifest.txt", "Contributors.rdoc", "Hacking.rdoc", "History.rdoc", "License.rdoc", "README.rdoc"]
|
22
|
-
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"]
|
23
|
-
s.homepage = %q{http://github.com.org/ruby-ldap/ruby-net-ldap}
|
24
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
25
|
-
s.require_paths = ["lib"]
|
26
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
27
|
-
s.rubyforge_project = %q{net-ldap}
|
28
|
-
s.rubygems_version = %q{1.5.2}
|
29
|
-
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}
|
30
|
-
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"]
|
31
|
-
|
32
|
-
if s.respond_to? :specification_version then
|
33
|
-
s.specification_version = 3
|
34
|
-
|
35
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
36
|
-
s.add_development_dependency(%q<hoe-git>, ["~> 1"])
|
37
|
-
s.add_development_dependency(%q<hoe-gemspec>, ["~> 1"])
|
38
|
-
s.add_development_dependency(%q<metaid>, ["~> 1"])
|
39
|
-
s.add_development_dependency(%q<flexmock>, ["~> 0.9.0"])
|
40
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.0"])
|
41
|
-
s.add_development_dependency(%q<hoe>, [">= 2.9.1"])
|
42
|
-
else
|
43
|
-
s.add_dependency(%q<hoe-git>, ["~> 1"])
|
44
|
-
s.add_dependency(%q<hoe-gemspec>, ["~> 1"])
|
45
|
-
s.add_dependency(%q<metaid>, ["~> 1"])
|
46
|
-
s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
|
47
|
-
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
48
|
-
s.add_dependency(%q<hoe>, [">= 2.9.1"])
|
49
|
-
end
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<hoe-git>, ["~> 1"])
|
52
|
-
s.add_dependency(%q<hoe-gemspec>, ["~> 1"])
|
53
|
-
s.add_dependency(%q<metaid>, ["~> 1"])
|
54
|
-
s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
|
55
|
-
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
56
|
-
s.add_dependency(%q<hoe>, [">= 2.9.1"])
|
57
|
-
end
|
58
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'net/ldap'
|
4
|
-
|
5
|
-
describe "BER serialisation (SSL)" do
|
6
|
-
# Transmits str to #to and reads it back from #from.
|
7
|
-
#
|
8
|
-
def transmit(str)
|
9
|
-
to.write(str)
|
10
|
-
to.close
|
11
|
-
|
12
|
-
from.read
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :to, :from
|
16
|
-
before(:each) do
|
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
|
-
flexmock(OpenSSL::SSL::SSLSocket).
|
23
|
-
new_instances.should_receive(:connect => nil)
|
24
|
-
|
25
|
-
@to = Net::LDAP::Connection.wrap_with_ssl(to)
|
26
|
-
@from = Net::LDAP::Connection.wrap_with_ssl(from)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should transmit strings" do
|
30
|
-
transmit('foo').should == 'foo'
|
31
|
-
end
|
32
|
-
it "should correctly transmit numbers" do
|
33
|
-
to.write 1234.to_ber
|
34
|
-
from.read_ber.should == 1234
|
35
|
-
end
|
36
|
-
end
|
data/spec/spec.opts
DELETED
data/spec/spec_helper.rb
DELETED
data/spec/unit/ber/ber_spec.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'net/ber'
|
4
|
-
require 'net/ldap'
|
5
|
-
|
6
|
-
describe "BER encoding of" do
|
7
|
-
|
8
|
-
RSpec::Matchers.define :properly_encode_and_decode do
|
9
|
-
match do |given|
|
10
|
-
given.to_ber.read_ber.should == given
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "arrays" do
|
15
|
-
it "should properly encode/decode []" do
|
16
|
-
[].should properly_encode_and_decode
|
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
|
-
if "Ruby 1.9".respond_to?(:encoding)
|
79
|
-
context "strings" do
|
80
|
-
it "should properly encode UTF-8 strings" do
|
81
|
-
"\u00e5".force_encoding("UTF-8").to_ber.should ==
|
82
|
-
"\x04\x02\xC3\xA5"
|
83
|
-
end
|
84
|
-
it "should properly encode strings encodable as UTF-8" do
|
85
|
-
"teststring".encode("US-ASCII").to_ber.should == "\x04\nteststring"
|
86
|
-
end
|
87
|
-
it "should fail on strings that can not be converted to UTF-8" do
|
88
|
-
error = Encoding::UndefinedConversionError
|
89
|
-
lambda {"\x81".to_ber }.should raise_exception(error)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "BER decoding of" do
|
96
|
-
context "numbers" do
|
97
|
-
it "should decode #{"\002\001\006".inspect} (6)" do
|
98
|
-
"\002\001\006".read_ber(Net::LDAP::AsnSyntax).should == 6
|
99
|
-
end
|
100
|
-
it "should decode #{"\004\007testing".inspect} ('testing')" do
|
101
|
-
"\004\007testing".read_ber(Net::LDAP::AsnSyntax).should == 'testing'
|
102
|
-
end
|
103
|
-
it "should decode an ldap bind request" do
|
104
|
-
"0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus".
|
105
|
-
read_ber(Net::LDAP::AsnSyntax).should ==
|
106
|
-
[1, [3, "Administrator", "ad_is_bogus"]]
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,51 +0,0 @@
|
|
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
|
data/spec/unit/ldap/dn_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
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
|
@@ -1,51 +0,0 @@
|
|
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
|