Merge branch 'filter_single_clauses' of https://github.com/Jamstah/ruby-net-ldap into jamstah-filter_single_clauses
This commit is contained in:
commit
7ae8e28550
|
@ -696,7 +696,7 @@ class Net::LDAP::Filter
|
||||||
filter = nil
|
filter = nil
|
||||||
branches = parse_branches(scanner)
|
branches = parse_branches(scanner)
|
||||||
|
|
||||||
if branches.size >= 2
|
if branches.size >= 1
|
||||||
filter = branches.shift
|
filter = branches.shift
|
||||||
while not branches.empty?
|
while not branches.empty?
|
||||||
filter = filter.__send__(op, branches.shift)
|
filter = filter.__send__(op, branches.shift)
|
||||||
|
|
|
@ -24,7 +24,8 @@ describe Net::LDAP::Filter do
|
||||||
'(o:dn:=Ace Industry)',
|
'(o:dn:=Ace Industry)',
|
||||||
'(:dn:2.4.8.10:=Dino)',
|
'(:dn:2.4.8.10:=Dino)',
|
||||||
'(cn:dn:1.2.3.4.5:=John Smith)',
|
'(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)',
|
||||||
|
'(&(sn:dn:2.4.6.8.10:=Barbara Jones))'
|
||||||
].each do |filter_str|
|
].each do |filter_str|
|
||||||
context "from_rfc2254(#{filter_str.inspect})" do
|
context "from_rfc2254(#{filter_str.inspect})" do
|
||||||
attr_reader :filter
|
attr_reader :filter
|
||||||
|
@ -80,4 +81,4 @@ describe Net::LDAP::Filter do
|
||||||
Net::LDAP::Filter.escape('!&*:|~').should == "\\21\\26\\2A\\3A\\7C\\7E"
|
Net::LDAP::Filter.escape('!&*:|~').should == "\\21\\26\\2A\\3A\\7C\\7E"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,6 +45,10 @@ class TestFilter < Test::Unit::TestCase
|
||||||
Filter.from_rfc2254("(! (mail=*))").to_rfc2254)
|
Filter.from_rfc2254("(! (mail=*))").to_rfc2254)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_filter_with_single_clause
|
||||||
|
assert_equal("(cn=name)", Net::LDAP::Filter.construct("(&(cn=name))").to_s)
|
||||||
|
end
|
||||||
|
|
||||||
def test_filters_from_ber
|
def test_filters_from_ber
|
||||||
[
|
[
|
||||||
Net::LDAP::Filter.eq("objectclass", "*"),
|
Net::LDAP::Filter.eq("objectclass", "*"),
|
||||||
|
@ -69,11 +73,11 @@ class TestFilter < Test::Unit::TestCase
|
||||||
Net::LDAP::Filter.eq("objectclass", "aaa*"),
|
Net::LDAP::Filter.eq("objectclass", "aaa*"),
|
||||||
Net::LDAP::Filter.eq("objectclass", "aaa*bbb*"),
|
Net::LDAP::Filter.eq("objectclass", "aaa*bbb*"),
|
||||||
Net::LDAP::Filter.eq("objectclass", "aaa*bbb*ccc*"),
|
Net::LDAP::Filter.eq("objectclass", "aaa*bbb*ccc*"),
|
||||||
].each {|ber|
|
].each do |ber|
|
||||||
f = Net::LDAP::Filter.parse_ber(ber.to_ber.read_ber(Net::LDAP::AsnSyntax))
|
f = Net::LDAP::Filter.parse_ber(ber.to_ber.read_ber(Net::LDAP::AsnSyntax))
|
||||||
assert(f == ber)
|
assert(f == ber)
|
||||||
assert_equal(f.to_ber, ber.to_ber)
|
assert_equal(f.to_ber, ber.to_ber)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ber_from_rfc2254_filter
|
def test_ber_from_rfc2254_filter
|
||||||
|
@ -102,10 +106,10 @@ class TestFilter < Test::Unit::TestCase
|
||||||
Net::LDAP::Filter.construct("objectclass=aaa*"),
|
Net::LDAP::Filter.construct("objectclass=aaa*"),
|
||||||
Net::LDAP::Filter.construct("objectclass=aaa*bbb*"),
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb*"),
|
||||||
Net::LDAP::Filter.construct("objectclass=aaa*bbb*ccc*"),
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb*ccc*"),
|
||||||
].each {|ber|
|
].each do |ber|
|
||||||
f = Net::LDAP::Filter.parse_ber(ber.to_ber.read_ber(Net::LDAP::AsnSyntax))
|
f = Net::LDAP::Filter.parse_ber(ber.to_ber.read_ber(Net::LDAP::AsnSyntax))
|
||||||
assert(f == ber)
|
assert(f == ber)
|
||||||
assert_equal(f.to_ber, ber.to_ber)
|
assert_equal(f.to_ber, ber.to_ber)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue