Commit eff30fff authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve dn_matches_filter method

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 1fe67799
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment