mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
Improve dn_matches_filter method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
@@ -107,12 +107,7 @@ module Gitlab
|
||||
end
|
||||
|
||||
def dn_matches_filter?(dn, filter)
|
||||
results = ldap_search(base: dn, filter: filter, attributes: %w{dn})
|
||||
if results.blank?
|
||||
false # Net::LDAP encountered an LDAP error
|
||||
else
|
||||
results.any?
|
||||
end
|
||||
ldap_search(base: dn, filter: filter, attributes: %w{dn}).any?
|
||||
end
|
||||
|
||||
def ldap_search(*args)
|
||||
|
||||
@@ -23,7 +23,7 @@ describe Gitlab::LDAP::Adapter do
|
||||
end
|
||||
|
||||
context "when the search encounters an error" do
|
||||
before { ldap.stub(search: nil) }
|
||||
before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) }
|
||||
|
||||
it { should be_false }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user