mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 01:06:00 +01:00
Replaced ruby-net-ldap with net-ldap 0.2.2 gem.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8751 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
80
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/dn_spec.rb
vendored
Normal file
80
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/dn_spec.rb
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
require 'spec_helper'
|
||||
require 'net/ldap/dn'
|
||||
|
||||
describe Net::LDAP::DN do
|
||||
describe "<- .construct" do
|
||||
attr_reader :dn
|
||||
|
||||
before(:each) do
|
||||
@dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company')
|
||||
end
|
||||
|
||||
it "should construct a Net::LDAP::DN" do
|
||||
dn.should be_an_instance_of(Net::LDAP::DN)
|
||||
end
|
||||
|
||||
it "should escape all the required characters" do
|
||||
dn.to_s.should == 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company'
|
||||
end
|
||||
end
|
||||
|
||||
describe "<- .to_a" do
|
||||
context "parsing" do
|
||||
{
|
||||
'cn=James, ou=Company\\,\\20LLC' => ['cn','James','ou','Company, LLC'],
|
||||
'cn = \ James , ou = "Comp\28ny" ' => ['cn',' James','ou','Comp(ny'],
|
||||
'1.23.4= #A3B4D5 ,ou=Company' => ['1.23.4','#A3B4D5','ou','Company'],
|
||||
}.each do |key, value|
|
||||
context "(#{key})" do
|
||||
attr_reader :dn
|
||||
|
||||
before(:each) do
|
||||
@dn = Net::LDAP::DN.new(key)
|
||||
end
|
||||
|
||||
it "should decode into a Net::LDAP::DN" do
|
||||
dn.should be_an_instance_of(Net::LDAP::DN)
|
||||
end
|
||||
|
||||
it "should return the correct array" do
|
||||
dn.to_a.should == value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "parsing bad input" do
|
||||
[
|
||||
'cn=James,',
|
||||
'cn=#aa aa',
|
||||
'cn="James',
|
||||
'cn=J\ames',
|
||||
'cn=\\',
|
||||
'1.2.d=Value',
|
||||
'd1.2=Value',
|
||||
].each do |value|
|
||||
context "(#{value})" do
|
||||
attr_reader :dn
|
||||
|
||||
before(:each) do
|
||||
@dn = Net::LDAP::DN.new(value)
|
||||
end
|
||||
|
||||
it "should decode into a Net::LDAP::DN" do
|
||||
dn.should be_an_instance_of(Net::LDAP::DN)
|
||||
end
|
||||
|
||||
it "should raise an error on parsing" do
|
||||
lambda { dn.to_a }.should raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "<- .escape(str)" do
|
||||
it "should escape ,, +, \", \\, <, >, and ;" do
|
||||
Net::LDAP::DN.escape(',+"\\<>;').should == '\\,\\+\\"\\\\\\<\\>\\;'
|
||||
end
|
||||
end
|
||||
end
|
||||
51
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/entry_spec.rb
vendored
Normal file
51
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/entry_spec.rb
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Net::LDAP::Entry do
|
||||
attr_reader :entry
|
||||
before(:each) do
|
||||
@entry = Net::LDAP::Entry.from_single_ldif_string(
|
||||
%Q{dn: something
|
||||
foo: foo
|
||||
barAttribute: bar
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
describe "entry access" do
|
||||
it "should always respond to #dn" do
|
||||
entry.should respond_to(:dn)
|
||||
end
|
||||
|
||||
context "<- #foo" do
|
||||
it "should respond_to?" do
|
||||
entry.should respond_to(:foo)
|
||||
end
|
||||
it "should return 'foo'" do
|
||||
entry.foo.should == ['foo']
|
||||
end
|
||||
end
|
||||
context "<- #Foo" do
|
||||
it "should respond_to?" do
|
||||
entry.should respond_to(:Foo)
|
||||
end
|
||||
it "should return 'foo'" do
|
||||
entry.foo.should == ['foo']
|
||||
end
|
||||
end
|
||||
context "<- #foo=" do
|
||||
it "should respond_to?" do
|
||||
entry.should respond_to(:foo=)
|
||||
end
|
||||
it "should set 'foo'" do
|
||||
entry.foo= 'bar'
|
||||
entry.foo.should == ['bar']
|
||||
end
|
||||
end
|
||||
context "<- #fOo=" do
|
||||
it "should return 'foo'" do
|
||||
entry.fOo= 'bar'
|
||||
entry.fOo.should == ['bar']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
84
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/filter_spec.rb
vendored
Normal file
84
vendor/gems/net-ldap-0.2.2/spec/unit/ldap/filter_spec.rb
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Net::LDAP::Filter do
|
||||
describe "<- .ex(attr, value)" do
|
||||
context "('foo', 'bar')" do
|
||||
attr_reader :filter
|
||||
before(:each) do
|
||||
@filter = Net::LDAP::Filter.ex('foo', 'bar')
|
||||
end
|
||||
it "should convert to 'foo:=bar'" do
|
||||
filter.to_s.should == '(foo:=bar)'
|
||||
end
|
||||
it "should survive roundtrip via to_s/from_rfc2254" do
|
||||
Net::LDAP::Filter.from_rfc2254(filter.to_s).should == filter
|
||||
end
|
||||
it "should survive roundtrip conversion to/from ber" do
|
||||
ber = filter.to_ber
|
||||
Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
|
||||
filter
|
||||
end
|
||||
end
|
||||
context "various legal inputs" do
|
||||
[
|
||||
'(o:dn:=Ace Industry)',
|
||||
'(:dn:2.4.8.10:=Dino)',
|
||||
'(cn:dn:1.2.3.4.5:=John Smith)',
|
||||
'(sn:dn:2.4.6.8.10:=Barbara Jones)',
|
||||
'(&(sn:dn:2.4.6.8.10:=Barbara Jones))'
|
||||
].each do |filter_str|
|
||||
context "from_rfc2254(#{filter_str.inspect})" do
|
||||
attr_reader :filter
|
||||
before(:each) do
|
||||
@filter = Net::LDAP::Filter.from_rfc2254(filter_str)
|
||||
end
|
||||
|
||||
it "should decode into a Net::LDAP::Filter" do
|
||||
filter.should be_an_instance_of(Net::LDAP::Filter)
|
||||
end
|
||||
it "should survive roundtrip conversion to/from ber" do
|
||||
ber = filter.to_ber
|
||||
Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax)).should ==
|
||||
filter
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "<- .construct" do
|
||||
it "should accept apostrophes in filters (regression)" do
|
||||
Net::LDAP::Filter.construct("uid=O'Keefe").to_rfc2254.should == "(uid=O'Keefe)"
|
||||
end
|
||||
end
|
||||
|
||||
describe "convenience filter constructors" do
|
||||
def eq(attribute, value)
|
||||
described_class.eq(attribute, value)
|
||||
end
|
||||
describe "<- .equals(attr, val)" do
|
||||
it "should delegate to .eq with escaping" do
|
||||
described_class.equals('dn', 'f*oo').should == eq('dn', 'f\2Aoo')
|
||||
end
|
||||
end
|
||||
describe "<- .begins(attr, val)" do
|
||||
it "should delegate to .eq with escaping" do
|
||||
described_class.begins('dn', 'f*oo').should == eq('dn', 'f\2Aoo*')
|
||||
end
|
||||
end
|
||||
describe "<- .ends(attr, val)" do
|
||||
it "should delegate to .eq with escaping" do
|
||||
described_class.ends('dn', 'f*oo').should == eq('dn', '*f\2Aoo')
|
||||
end
|
||||
end
|
||||
describe "<- .contains(attr, val)" do
|
||||
it "should delegate to .eq with escaping" do
|
||||
described_class.contains('dn', 'f*oo').should == eq('dn', '*f\2Aoo*')
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "<- .escape(str)" do
|
||||
it "should escape nul, *, (, ) and \\" do
|
||||
Net::LDAP::Filter.escape("\0*()\\").should == "\\00\\2A\\28\\29\\5C"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user