4
describe Net::LDAP::DN do
5
describe "<- .construct" do
9
@dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company')
12
it "should construct a Net::LDAP::DN" do
13
dn.should be_an_instance_of(Net::LDAP::DN)
16
it "should escape all the required characters" do
17
dn.to_s.should == 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company'
21
describe "<- .to_a" do
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|
32
@dn = Net::LDAP::DN.new(key)
35
it "should decode into a Net::LDAP::DN" do
36
dn.should be_an_instance_of(Net::LDAP::DN)
39
it "should return the correct array" do
40
dn.to_a.should == value
46
context "parsing bad input" do
56
context "(#{value})" do
60
@dn = Net::LDAP::DN.new(value)
63
it "should decode into a Net::LDAP::DN" do
64
dn.should be_an_instance_of(Net::LDAP::DN)
67
it "should raise an error on parsing" do
68
lambda { dn.to_a }.should raise_error
75
describe "<- .escape(str)" do
76
it "should escape ,, +, \", \\, <, >, and ;" do
77
Net::LDAP::DN.escape(',+"\\<>;').should == '\\,\\+\\"\\\\\\<\\>\\;'